[ELF] More dynamic relocation packing
authorFangrui Song <maskray@google.com>
Wed, 21 Aug 2019 03:02:08 +0000 (03:02 +0000)
committerFangrui Song <maskray@google.com>
Wed, 21 Aug 2019 03:02:08 +0000 (03:02 +0000)
commit35f9a84a15d15d70e8aa35cc5a750309f49ea640
treef31142866ce1e2409bdeb74c188c9ea94f369f97
parentf938755a331206f017eaa5e8ab6a122b162e8de3
[ELF] More dynamic relocation packing

Currently, with Android dynamic relocation packing, only relative
relocations are grouped together. This patch implements similar
packing for non-relative relocations.

The implementation groups non-relative relocations with the same
r_info and r_addend, if using RELA. By requiring a minimum group
size of 3, this achieves smaller relocation sections. Building Android
for an ARM32 device, I see the total size of /system/lib decrease by
392 KB.

Grouping by r_info also allows the runtime dynamic linker to implement
an 1-entry cache to reduce the number of symbol lookup required. With
such 1-entry cache implemented on Android, I'm seeing 10% to 20%
reduction in total time spent in runtime linker for several executables
that I tested.

As a simple correctness check, I've also built x86_64 Android and booted
successfully.

Differential Revision: https://reviews.llvm.org/D66491
Patch by Vic Yang!

llvm-svn: 369488
lld/ELF/SyntheticSections.cpp
lld/test/ELF/pack-dyn-relocs.s