Message ID | 20230512230135.133162-3-CFSworks@gmail.com |
---|---|
State | Handled Elsewhere, archived |
Delegated to: | Tom Rini |
Headers | show |
Series | [1/3] makefile: Fix symbol typo in binary_size_check | expand |
On Fri, May 12, 2023 at 05:01:35PM -0600, Sam Edwards wrote: > The goal of using --apply-dynamic-relocs seems to be to have all > relocations applied "statically" to the output binary, so that > the dynamic segment can be dropped safely. However, LLD still > creates sections to support the dynamic section, and platform > linker scripts may not know to discard these. > > Since the build process does not appear to make use of the dynamic > segment at all, it would be more sensible to suppress it entirely. > > Signed-off-by: Sam Edwards <CFSworks@gmail.com> > --- > Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index 20785860f7..d71127e412 100644 > --- a/Makefile > +++ b/Makefile > @@ -1024,7 +1024,7 @@ LDFLAGS_u-boot += $(LDFLAGS_FINAL) > LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) > > # ld.lld support > -LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs) > +LDFLAGS_u-boot += -z notext $(call ld-option,--no-pie) > > LDFLAGS_u-boot += --build-id=none > How extensively have you tested this change? We don't install ld.lld in our container environment right now (but should..) and from some local testing I forget if we need to pass further make logic in to have ld.lld be used instead.
On 5/14/23 09:28, Tom Rini wrote: Hi Tom! > How extensively have you tested this change? I tested it in building for the arm/sunxi target. U-Boot does not build at all (on Clang+LLD) in its current state: ld.lld: error: section type mismatch for .gnu.version_r >>> <internal>:(.gnu.version_r): SHT_GNU_verneed >>> output section .gnu: SHT_GNU_versym However, I don't think I've reasoned correctly that --no-pie is the correct flag to pass, since I do see in arch/arm/config.mk: # needed for relocation LDFLAGS_u-boot += -pie ...and by passing --no-pie, I am just turning that right back off, getting a non-relocatable binary. So I should (and do) withdraw this patch, and will work to understand the situation better before retrying. It does seem that the present rule in the ARM target is to make a binary that assumes a .text base but includes some .rel.dyn relocations to make it optionally relocatable, so whatever flag we pass to LLD should preserve that behavior without bringing in unwanted sections (versym sections, .dynsym, .dynstr, ...) > We don't install ld.lld in > our container environment right now (but should..) and from some local > testing I forget if we need to pass further make logic in to have ld.lld > be used instead. To support both LTO and non-LTO cases, I pass: LTO_FINAL_LDFLAGS=-fuse-ld=lld LD=ld.lld Cheers, Sam
diff --git a/Makefile b/Makefile index 20785860f7..d71127e412 100644 --- a/Makefile +++ b/Makefile @@ -1024,7 +1024,7 @@ LDFLAGS_u-boot += $(LDFLAGS_FINAL) LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) # ld.lld support -LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs) +LDFLAGS_u-boot += -z notext $(call ld-option,--no-pie) LDFLAGS_u-boot += --build-id=none
The goal of using --apply-dynamic-relocs seems to be to have all relocations applied "statically" to the output binary, so that the dynamic segment can be dropped safely. However, LLD still creates sections to support the dynamic section, and platform linker scripts may not know to discard these. Since the build process does not appear to make use of the dynamic segment at all, it would be more sensible to suppress it entirely. Signed-off-by: Sam Edwards <CFSworks@gmail.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)