[ELF] -z combreloc: sort dynamic relocations by (symbol_index,r_offset)
authorFangrui Song <maskray@google.com>
Mon, 20 May 2019 07:22:55 +0000 (07:22 +0000)
committerFangrui Song <maskray@google.com>
Mon, 20 May 2019 07:22:55 +0000 (07:22 +0000)
commit9f1a6de6311489801fe32a5e45a37a6953ccdcf3
tree79d0746246776ea9b861d0caf768a012147fc432
parent34e95ce2595ff350bd9773174d73f0f4a749a459
[ELF] -z combreloc: sort dynamic relocations by (symbol_index,r_offset)

Fixes PR41692.

We currently sort dynamic relocations by (!is_relative,symbol_index).
Change it to (symbol_index,r_offset). We still place relative
relocations first because R_*_RELATIVE are the only dynamic relocations
with 0 symbol index (except on MIPS, which doesn't use DT_REL[A]COUNT
anyway).

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.

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D61477

llvm-svn: 361125
lld/ELF/SyntheticSections.cpp
lld/test/ELF/combreloc.s [new file with mode: 0644]
lld/test/ELF/combrelocs.s [deleted file]
lld/test/ELF/i386-got-and-copy.s
lld/test/ELF/mips-mgot.s