[MC][ELF] Allow STT_SECTION referencing SHF_MERGE on REL targets
authorFangrui Song <i@maskray.me>
Mon, 21 Dec 2020 02:37:14 +0000 (18:37 -0800)
committerFangrui Song <i@maskray.me>
Mon, 21 Dec 2020 02:37:14 +0000 (18:37 -0800)
commit72e75ca343c6ff927a2242efee3f4640943eedd6
tree227a0c62a19162149a86062d91de7311bdd19c27
parent9e4b682baf2c1eab8f47b8eaa8ffea2d846a68b2
[MC][ELF] Allow STT_SECTION referencing SHF_MERGE on REL targets

This relands D64327 with a more specific workaround for R_386_GOTOFF
(gold<2.34 bug https://sourceware.org/bugzilla/show_bug.cgi?id=16794)

.debug_info has quite a few .debug_str relocations (R_386_32/R_ARM_ABS32).
The original workaround was too general and introduced too many .L symbols
used just as relocation targets.

From the original review:

  ... it reduced the size of a big ARM-32 debug image by 33%. It contained ~68M
  of relocations symbols out of total ~71M symbols (96% of symbols table was
  generated for relocations with symbol).
llvm/lib/MC/ELFObjectWriter.cpp
llvm/test/MC/ELF/basic-elf-32.s
llvm/test/MC/ELF/compression.s
llvm/test/MC/ELF/relocation-386.s
llvm/test/MC/Mips/elf-relsym.s
llvm/test/MC/Mips/xgot.s