[PATCH] D61477: [ELF] -z combreloc: sort dynamic relocations by (!is_relative,symbol_index,r_offset)

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 6 23:57:37 PDT 2019


MaskRay added a comment.

I can't find a spec of DT_RELACOUNT in gABI or psABI. I find its definition in Linux Standard Base but can't find its description. elfutils has a lint tool, it checks some properties of DT_RELACOUNT but doesn't require its entries to be sorted.

In glibc, there is a commit with changelog "If DT_GNU_PRELINKED, DT_RELACOUNT relocations can be skipped."
In Oracle Solaris Linkers and Libraries Guide, it is describe but nothing is said about the sorted r_offset: "Combining relocation records in this manner enables all RELATIVE relocations to be grouped together. All symbolic relocations are sorted by symbol name. The grouping of RELATIVE relocations permits optimized runtime processing using the DT_RELACOUNT/DT_RELCOUNT .dynamic entries. Sorted symbolic entries help reduce runtime symbol lookup"
FreeBSD copied the definition to their sys/sys/elf_common.h in 2016 from somewhere, but its rtld doesn't use DT_RELACOUNT. musl doesn't use DT_RELACOUNT.

I don't know if DT_RELACOUNT was a glibc invention or a Sun invention. To be honest, if it is not that we've added it in the first place, I wouldn't suggest adding it :D

To me this is a cosmetic change. You make the decision if it is worth doing.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61477/new/

https://reviews.llvm.org/D61477





More information about the llvm-commits mailing list