[PATCH 3/3] clang: Link with --no-pie instead of --apply-dynamic-relocs

Sam Edwards cfsworks at gmail.com
Tue May 16 04:08:59 CEST 2023


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


More information about the U-Boot mailing list