Relocations against sections with no SHF_ALLOC bit are R_ABS relocations.
Currently we are creating Relocations vector for them, but that is wasteful.
This patch is to skip vector construction and to directly apply relocations
in place.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
ELF/InputSection.h | ||
---|---|---|
222 ↗ | (On Diff #55375) | Do you have any suggestions for better name? |
test/ELF/relocation-non-alloc.s | ||
36 ↗ | (On Diff #55375) | Yes. BFD and gold both produces this pattern rather than the old one. This is a test to produce a DSO file with a non-alloc section pointing to an interruptible symbol. This seems to be unrealistic test case. LLD previously handle interruptible symbols addresses as 0 because it can change at runtime, but GNU linkers don't seem to bother it. |
LGTM with the name changed and the IsAlloc bool replaced with false.
ELF/InputSection.cpp | ||
---|---|---|
230 ↗ | (On Diff #55375) | Debug section is -> Debug sections are. |
ELF/InputSection.h | ||
222 ↗ | (On Diff #55375) | Maybe just relocateNonAlloc? |
test/ELF/relocation-non-alloc.s | ||
36 ↗ | (On Diff #55375) | OK, I think I see what is going on. For preemptable symbols in alloc sections we have to create a dynamic relocation. Having created one, we know the dynamic linker will take care of everything and we don't need to do anything else. I am not sure if these show up in practice in non alloc sections, but it seems reasonable to have them point to the symbol in the file we are producing since there will be no dynamic relocation. |
So, this patch seems to be pretty effective for large executables with debug info. r266158 (Rafael's patch to change the way how we apply relocations) caused a temporary performance degradation for such executables, but this patch makes it even faster than before.
Time to link clang with debug info (output size is 1070 MB):
before r266158: 15.312 seconds (0%) r266158: 17.301 seconds (+13.0%) Head: 16.484 seconds (+7.7%) w/patch: 13.166 seconds (-14.0%)