From: Alistair Delva <adelva@google.com>
To: u-boot@lists.denx.de
Cc: Nick Desaulniers <ndesaulniers@google.com>,
Simon Glass <sjg@chromium.org>, Bin Meng <bmeng.cn@gmail.com>
Subject: [PATCH] x86: Fix linking u-boot with ld.lld
Date: Wed, 20 Oct 2021 21:31:33 +0000 [thread overview]
Message-ID: <20211020213134.7534-5-adelva@google.com> (raw)
In-Reply-To: <20211020213134.7534-1-adelva@google.com>
When linking the final u-boot binary with LLD, the following link errors
are seen:
ld.lld: error: can't create dynamic relocation R_386_32 against local
symbol in readonly segment; recompile object files with
-fPIC or pass '-Wl,-z,notext' to allow text relocations
in the output
>>> defined in arch/x86/cpu/start.o
>>> referenced by arch/x86/cpu/start.o:(.text.start+0x32)
[...]
>>> defined in arch/x86/cpu/start16.o
>>> referenced by arch/x86/cpu/start16.o:(.start16+0x1C)
According to Nick Desaulniers:
"This is a known difference between GNU and LLVM linkers; the GNU
linkers permit relocations in readonly segments (making them not read
only), LLVM does not (by default)."
Since U-Boot apparently seems to use relocations in readonly segments,
change the global linker flags to permit them when linking with LLD by
specifying '-z notext'.
Signed-off-by: Alistair Delva <adelva@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
---
Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Makefile b/Makefile
index 6f2474baeb..3488b83e14 100644
--- a/Makefile
+++ b/Makefile
@@ -997,6 +997,9 @@ LDFLAGS_u-boot += $(LDFLAGS_FINAL)
# Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker)
+# ld.lld support
+LDFLAGS_u-boot += -z notext
+
LDFLAGS_u-boot += --build-id=none
ifeq ($(CONFIG_ARC)$(CONFIG_NIOS2)$(CONFIG_X86)$(CONFIG_XTENSA),)
--
2.30.2
next prev parent reply other threads:[~2021-10-20 21:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-20 21:31 [PATCH] x86: chromebook_coral: fix C block comment Alistair Delva
2021-10-20 21:31 ` [PATCH] x86: Fix i8254 ifdef include guard Alistair Delva
2021-10-21 20:18 ` Simon Glass
2021-10-27 3:08 ` Bin Meng
2021-10-27 3:28 ` Bin Meng
2021-10-20 21:31 ` [PATCH] efi_loader: Fix link of EFI apps with ld.lld Alistair Delva
2021-10-20 22:05 ` Heinrich Schuchardt
2021-10-20 21:31 ` [PATCH] arm64: relocate-rela: Add support for ld.lld Alistair Delva
2021-10-25 13:30 ` Tom Rini
2021-10-25 17:46 ` Alistair Delva
2021-10-25 18:17 ` Tom Rini
2021-11-16 19:25 ` Tom Rini
2021-10-20 21:31 ` Alistair Delva [this message]
2021-10-21 20:18 ` [PATCH] x86: Fix linking u-boot with ld.lld Simon Glass
2021-10-31 12:57 ` Simon Glass
2021-10-20 21:31 ` [PATCH] RFC: arm: pci: Add PCI cam support to PCI-E ecam driver Alistair Delva
2021-11-18 19:15 ` Tom Rini
2021-10-21 20:18 ` [PATCH] x86: chromebook_coral: fix C block comment Simon Glass
2021-10-27 3:07 ` Bin Meng
2021-10-27 3:27 ` Bin Meng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211020213134.7534-5-adelva@google.com \
--to=adelva@google.com \
--cc=bmeng.cn@gmail.com \
--cc=ndesaulniers@google.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox