aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2020-12-20 18:37:14 -0800
committerFangrui Song <i@maskray.me>2020-12-20 18:37:14 -0800
commit72e75ca343c6ff927a2242efee3f4640943eedd6 (patch)
tree227a0c62a19162149a86062d91de7311bdd19c27 /llvm/lib/MC/ELFObjectWriter.cpp
parent9e4b682baf2c1eab8f47b8eaa8ffea2d846a68b2 (diff)
downloadllvm-72e75ca343c6ff927a2242efee3f4640943eedd6.zip
llvm-72e75ca343c6ff927a2242efee3f4640943eedd6.tar.gz
llvm-72e75ca343c6ff927a2242efee3f4640943eedd6.tar.bz2
[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).
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 10c61fc..9cf29ba 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1395,9 +1395,10 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm,
if (C != 0)
return true;
- // It looks like gold has a bug (http://sourceware.org/PR16794) and can
- // only handle section relocations to mergeable sections if using RELA.
- if (!hasRelocationAddend())
+ // gold<2.34 incorrectly ignored the addend for R_386_GOTOFF (9)
+ // (http://sourceware.org/PR16794).
+ if (TargetObjectWriter->getEMachine() == ELF::EM_386 &&
+ Type == ELF::R_386_GOTOFF)
return true;
}