[AArch64] Optimize .gnu.hash table size for executable
Jiong Wang
jiong.wang@foss.arm.com
Tue Jan 17 12:03:00 GMT 2017
For a loadable obj, if the one symbol is satisfied by another external obj,
then it's not necessary to be added into .gnu.hash (except that function's
address is taken in which case we need a undefined symbol with an absolute
value). For the testcase attached, I found dec is added into the executable's
.gnu.hash section on AArch64.
I am seeing the default hash hook is using the following check:
_bfd_elf_hash_symbol:
! (...
|| ((h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
&& h->root.u.def.section->output_section == NULL));
While for function symbol defined in shared library and referenced in
executable, the output_section is not NULL.
This patch borrows the same code from X86-64 and Powerpc to avoid such symbol
be added into .gnu.hash.
For example like "Clang" binary, the .gnu.hash size reduced from 0x0c6820
into 0x0c630c after this patch.
OK for master?
2017-01-17 Jiong Wang <jiong.wang@arm.com>
bfd/
* elfnn-aarch64.c (elf_aarch64_hash_symbol): New function.
(elf_backend_hash_symbol): Define.
ld/
* testsuite/ld-aarch64/aarch64-elf.exp (aarch64elflinktests): New tests.
* testsuite/ld-aarch64/func-in-so.s: New test source file.
* testsuite/ld-aarch64/func-sym-hash-opt.s: Likewise.
* testsuite/ld-aarch64/func-sym-hash-opt.d: New expected test result.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s.patch
Type: text/x-diff
Size: 3355 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20170117/205cb5eb/attachment.bin>
More information about the Binutils
mailing list