]> Git Repo - linux.git/commitdiff
arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
authorNathan Chancellor <[email protected]>
Wed, 26 Jun 2019 04:20:17 +0000 (21:20 -0700)
committerWill Deacon <[email protected]>
Wed, 26 Jun 2019 10:40:20 +0000 (11:40 +0100)
After r363059 and r363928 in LLVM, a build using ld.lld as the linker
with CONFIG_RANDOMIZE_BASE enabled fails like so:

ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
__efistub_stext_offset; recompile with -fPIC

Fangrui and Peter figured out that ld.lld is incorrectly considering
__efistub_stext_offset as a relative symbol because of the order in
which symbols are evaluated. _text is treated as an absolute symbol
and stext is a relative symbol, making __efistub_stext_offset a
relative symbol.

Adding ABSOLUTE will force ld.lld to evalute this expression in the
right context and does not change ld.bfd's behavior. ld.lld will
need to be fixed but the developers do not see a quick or simple fix
without some research (see the linked issue for further explanation).
Add this simple workaround so that ld.lld can continue to link kernels.

Link: https://github.com/ClangBuiltLinux/linux/issues/561
Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
Acked-by: Ard Biesheuvel <[email protected]>
Debugged-by: Fangrui Song <[email protected]>
Debugged-by: Peter Smith <[email protected]>
Suggested-by: Fangrui Song <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
[will: add comment]
Signed-off-by: Will Deacon <[email protected]>
arch/arm64/kernel/image.h

index 33f14e484040c69601645c4fa7645f629474e589..b22e8ad071b1d99186fbc3c9202d6518f9ed3c1c 100644 (file)
 
 #ifdef CONFIG_EFI
 
-__efistub_stext_offset = stext - _text;
+/*
+ * Use ABSOLUTE() to avoid ld.lld treating this as a relative symbol:
+ * https://github.com/ClangBuiltLinux/linux/issues/561
+ */
+__efistub_stext_offset = ABSOLUTE(stext - _text);
 
 /*
  * The EFI stub has its own symbol namespace prefixed by __efistub_, to
This page took 0.058754 seconds and 4 git commands to generate.