summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-02-26 19:17:20 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-02-26 19:17:20 +0000
commit46ff3ce2bd268f9e79aa9724879b26942c9d4a3a (patch)
treed7fe45169143b8ea375897aec38ebbf0942a7155
parent2043ee167ced6fc6a85d2266da141bc9ffa8a6ba (diff)
downloadbcm5719-llvm-46ff3ce2bd268f9e79aa9724879b26942c9d4a3a.tar.gz
bcm5719-llvm-46ff3ce2bd268f9e79aa9724879b26942c9d4a3a.zip
[Mips] Split reloc26 function into two parts - for processing local and
external relocations. llvm-svn: 202289
-rw-r--r--lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
index 7ea9feac0a1..12bbf026cfc 100644
--- a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
+++ b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
@@ -46,12 +46,16 @@ void reloc32(uint8_t *location, uint64_t P, uint64_t S, int64_t A) {
/// \brief R_MIPS_26
/// local : ((A | ((P + 4) & 0x3F000000)) + S) >> 2
+void reloc26loc(uint8_t *location, uint64_t P, uint64_t S, int32_t A) {
+ uint32_t result = ((A << 2) | ((P + 4) & 0x3f000000)) + S;
+ applyReloc(location, result >> 2, 0x03ffffff);
+}
+
+/// \brief LLD_R_MIPS_GLOBAL_26
/// external: (sign–extend(A) + S) >> 2
-void reloc26(uint8_t *location, uint64_t P, uint64_t S, bool isLocal) {
- int32_t A = (*(uint32_t*)location & 0x03FFFFFFU) << 2;
- uint32_t result = isLocal ? (A | ((P + 4) & 0x3F000000)) : signExtend<28>(A);
- result = (result + S) >> 2;
- applyReloc(location, result, 0x03ffffff);
+void reloc26ext(uint8_t *location, uint64_t S, int32_t A) {
+ uint32_t result = signExtend<28>(A << 2) + S;
+ applyReloc(location, result >> 2, 0x03ffffff);
}
/// \brief R_MIPS_HI16
@@ -183,7 +187,7 @@ error_code MipsTargetRelocationHandler::applyRelocation(
reloc32(location, relocVAddress, targetVAddress, ref.addend());
break;
case R_MIPS_26:
- reloc26(location, relocVAddress, targetVAddress, true);
+ reloc26loc(location, relocVAddress, targetVAddress, ref.addend());
break;
case R_MIPS_HI16:
savePairedRelocation(atom, ref);
@@ -212,7 +216,7 @@ error_code MipsTargetRelocationHandler::applyRelocation(
relocGOT16(location, relocVAddress, targetVAddress, ref.addend(), gpAddr);
break;
case LLD_R_MIPS_GLOBAL_26:
- reloc26(location, relocVAddress, targetVAddress, false);
+ reloc26ext(location, targetVAddress, ref.addend());
break;
case LLD_R_MIPS_HI16:
relocLldHi16(location, targetVAddress);
OpenPOWER on IntegriCloud