The only restriction is that we cannot merge more than one KeepUnique
section together. This matches gold's behaviour and reduces code size
when using --icf=safe.
Details
Details
Diff Detail
Diff Detail
- Repository
- rLLD LLVM Linker
Event Timeline
lld/ELF/ICF.cpp | ||
---|---|---|
471 ↗ | (On Diff #156628) | I guess this could be a bit simpler: for (size_t I = Begin + 1; I < End; ++I) { if (Sections[Begin]->KeepUnique && Sections[I]->KeepUnique) Begin = I; else Sections[Begin]->replace(Sections[I]); } |
lld/ELF/ICF.cpp | ||
---|---|---|
471 ↗ | (On Diff #156628) | It doesn't look like this is correct. With this input: .globl _start _start: call f1 call f2 call f3 .section .text.f1,"ax" .globl f1 f1: ret .section .text.f2,"ax" .globl f2 f2: ret .section .text.f3,"ax" .globl f3 f3: ret I get: $ ra/bin/ld.lld foo.o --icf=all --print-icf-sections --keep-unique=f2 --keep-unique=f3 $ nm a.out 000000000020100f T f1 000000000020100f T f2 000000000020100f T f3 0000000000201000 T _start I'll add some comments to my version. |
Comment Actions
Hi Peter,
Thanks for your address significance tables work!
Specific to this change:
I was under the impression that the intention of --keep-unique was to prevent *all* folding?
I found this open bug against gold that supports this interpretation: https://sourceware.org/bugzilla/show_bug.cgi?id=18865
If I --keep-unique a symbol it seems like I am asking for a strong guarantee on the address of the symbol. The original behaviour matches this strong guarantee.