Message ID | 20211020213134.7534-5-adelva@google.com |
---|---|
State | Accepted |
Commit | 58772283210e15f8d803db4aa67c877d668db867 |
Delegated to: | Simon Glass |
Headers | show |
Series | x86: Fix linking u-boot with ld.lld | expand |
On Wed, 20 Oct 2021 at 15:31, Alistair Delva <adelva@google.com> wrote: > > 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(+) Reviewed-by: Simon Glass <sjg@chromium.org> > > 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 >
On Wed, 20 Oct 2021 at 15:31, Alistair Delva <adelva@google.com> wrote: > > 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(+) Reviewed-by: Simon Glass <sjg@chromium.org> > Applied to u-boot-dm, thanks!
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),)