Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75dc7070 authored by Sami Tolvanen's avatar Sami Tolvanen Committed by Alistair Strachan
Browse files

ANDROID: arm64: add atomic_ll_sc.o to obj-y if using lld

__ll_sc_* functions are only referenced in inline assembly, which means lld
won't see them when CONFIG_LTO_CLANG is enabled due to a bug in LLVM:

  https://bugs.llvm.org/show_bug.cgi?id=35841



When LTO and CONFIG_ARM64_LSE_ATOMICS are both enabled, linking fails with
the following type of errors:

ld.lld: error: relocation R_AARCH64_CALL26 cannot refer to absolute
  symbol: __ll_sc_atomic64_add_return_acquire
>>> defined in vmlinux.o
>>> referenced by atomic_lse.h:299 (arch/arm64/include/asm/atomic_lse.h:299)
>>>               vmlinux.o:(kernel_init_freeable)
...

This change works around the problem by always linking in atomic_ll_sc.o to
vmlinux, instead of placing it in arch/arm64/lib/lib.a.

Bug: 63740206
Bug: 117299373
Bug: 124318741
Change-Id: Idf2211034cce9cb0b6b2007bbdb1dfc1c1a1053d
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent d31b9814
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -11,7 +11,12 @@ lib-y := clear_user.o delay.o copy_from_user.o \
# patching of the bl instruction in the caller with an atomic instruction
# when supported by the CPU. Result and argument registers are handled
# correctly, based on the function prototype.
ifeq ($(CONFIG_LD_IS_LLD), y)
# https://bugs.llvm.org/show_bug.cgi?id=35841
obj-$(CONFIG_ARM64_LSE_ATOMICS) += atomic_ll_sc.o
else
lib-$(CONFIG_ARM64_LSE_ATOMICS) += atomic_ll_sc.o
endif
CFLAGS_atomic_ll_sc.o	:= -ffixed-x1 -ffixed-x2        		\
		   -ffixed-x3 -ffixed-x4 -ffixed-x5 -ffixed-x6		\
		   -ffixed-x7 -fcall-saved-x8 -fcall-saved-x9		\