This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by MaskRay on May 20 2019, 7:23 AM.

Details

Summary

We currently sort dynamic relocations by (!is_relative,symbol_index).
Add r_offset as the third key. This makes readelf -r debugging easier
(relocations to the same symbol are ordered by r_offset).

Refactor the test combreloc.s (renamed from combrelocs.s) to check
R_X86_64_RELATIVE, and delete --expand-relocs.

The difference from the reverted D61477 is that we add !is_relative as
the first key. In local dynamic TLS model, DTPMOD (e.g.
R_ARM_TLS_DTPMOD32 R_X86_64_DTPMOD and R_PPC{,64}_DTPMOD) may use 0 as
the symbol index.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.May 20 2019, 7:23 AM
grimar accepted this revision.May 20 2019, 7:45 AM

LGTM

This revision is now accepted and ready to land.May 20 2019, 7:45 AM

FreeBSD ld.so/musl don't use DT_RELACOUNT. In glibc, glibc/sysdeps/x86_64/dl-machine.h (but not on other arch) has an assertion that the first DT_REL[A]COUNT relocations must all be relative.

@evgeny777 I'm curious how your dynamic loader uses DT_REL{,A}COUNT since you created D23661:)

This revision was automatically updated to reflect the committed changes.
lld/trunk/test/ELF/combreloc.s