summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorDaniel Sanders <daniel.sanders@imgtec.com>2016-05-09 10:21:14 +0000
committerDaniel Sanders <daniel.sanders@imgtec.com>2016-05-09 10:21:14 +0000
commit3d000565153d6129424761ba610c8e266d0e29a2 (patch)
tree09c956a603fc738fd5fe04a34cb1afe56a574e53 /llvm/lib/Target
parent5d0f2d21354f78bae1f9efc1bc2f657ae1df72ae (diff)
downloadbcm5719-llvm-3d000565153d6129424761ba610c8e266d0e29a2.tar.gz
bcm5719-llvm-3d000565153d6129424761ba610c8e266d0e29a2.zip
[mips][ias] R_MIPS_(GOT|HI|LO|PC)16 and R_MIPS_GPREL32 do not need symbols.
Summary: In theory, care must be taken to ensure that pairs of R_MIPS_(GOT|HI|LO)16 make the same decision on both relocs in the reloc pair but in practice this isn't as hard as it sounds and only limits the complexity of the predicate used. We handle all three with the same code to ensure their decisions always agree with each other. Reviewers: sdardis Subscribers: rafael, dsanders, sdardis, llvm-commits Differential Revision: http://reviews.llvm.org/D19016 llvm-svn: 268900
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
index d8516001b7e..fb184bb3807 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -476,30 +476,27 @@ void MipsELFObjectWriter::sortRelocs(const MCAssembler &Asm,
bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCSymbol &Sym,
unsigned Type) const {
- // FIXME: This is extremely conservative. This really needs to use a
- // whitelist with a clear explanation for why each realocation needs to
- // point to the symbol, not to the section.
switch (Type) {
default:
return true;
+ // On REL ABI's (e.g. O32), these relocations form pairs. The pairing is done
+ // by the static linker by matching the symbol and offset.
+ // We only see one relocation at a time but it's still safe to relocate with
+ // the section so long as both relocations make the same decision.
+ //
+ // Some older linkers may require the symbol for particular cases. Such cases
+ // are not supported yet but can be added as required.
case ELF::R_MIPS_GOT16:
case ELF::R_MIPS16_GOT16:
case ELF::R_MICROMIPS_GOT16:
- return true;
-
- // These relocations might be paired with another relocation. The pairing is
- // done by the static linker by matching the symbol. Since we only see one
- // relocation at a time, we have to force them to relocate with a symbol to
- // avoid ending up with a pair where one points to a section and another
- // points to a symbol.
case ELF::R_MIPS_HI16:
case ELF::R_MIPS16_HI16:
case ELF::R_MICROMIPS_HI16:
case ELF::R_MIPS_LO16:
case ELF::R_MIPS16_LO16:
case ELF::R_MICROMIPS_LO16:
- return true;
+ return false;
case ELF::R_MIPS_16:
case ELF::R_MIPS_32:
@@ -509,6 +506,8 @@ bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCSymbol &Sym,
case ELF::R_MIPS_26:
case ELF::R_MIPS_64:
case ELF::R_MIPS_GPREL16:
+ case ELF::R_MIPS_GPREL32:
+ case ELF::R_MIPS_PC16:
return false;
}
}
OpenPOWER on IntegriCloud