On 29.02.2020 19:00, Taylor R Campbell wrote: >> Module Name: src >> Committed By: kamil >> Date: Sat Feb 29 04:27:01 UTC 2020 >> >> Modified Files: >> src/doc: CHANGES >> >> Log Message: >> ld.elf_so(1): Implement DT_GNU_HASH > > Was this discussed anywhere? In the toolchain circles, for some time now (2+ years). It was one of the pending task to modernize our ELF loader on par with at least FreeBSD. > What are the advantages and drawbacks of > this over what we were doing before? Reading: https://blogs.oracle.com/solaris/gnu-hash-elf-sections-v2 https://flapenguin.me/2017/05/10/elf-lookup-dt-gnu-hash/ 1. Advantages. We support now an alternative hash format that is ~50% faster, de facto standard in ELF Operating Systems and thinner in size. 2. Disadvantages. If we switch to GNU Hash only we are no longer producing compliant ELF binaries. Once we will deliver GNU Hash binaries, delivering sysv hash for compatibility and conformance reason, binaries will be fatter for 0.5-5kb. Some OSs like FreeBSD and most Linux distros decided to build both hashes concurrently. Upstream LLD developers attempted to switch as many OSs as possible to GNU Hash only, but it was resisted. ps(1) sizes ----------- 54064 sysv hash 54216 both hashes 53520 gnu hash > What other toolchain changes are > involved in using it? 1. On the ld level. - dynamically: make LDFLAGS="-Wl,--hash-style=both" - statically: possibly flipping /* Define to 1 if you want to emit gnu hash in the ELF linker by default. */ #define DEFAULT_EMIT_GNU_HASH 0 in config.h 2. gcc/clang pass - -Wl,--hash-style=both > What maintenance burden does it put on us for > compatibility? After designing in 10+ years ago, it works as is without changes in other OSs. Stable interface and if someone will invent new hash, we will likely get a new type of: DT_*_HASH. LLVM and GNU toolchains support it and recommend for ELF targets. > What's the impact on systems that prioritize size over > speed? > We win both size and speed with GNU Hash shipped exclusively. We pay cost of extra around 1 kbyte per binary if we want both hashes. If we want minimum size we can generate only one hash type.
Attachment:
signature.asc
Description: OpenPGP digital signature