summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-05-25 09:04:15 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-05-25 09:04:15 +0000
commit6d1a09f39fb18ba8513cd47fbcdcf65518411e7c (patch)
tree0b7510a1c7960a2e50dc4b0bf8734cb8d316d8f1
parent12d1e24da2ee58f7c4a1eaf2f7752f89a1550c29 (diff)
downloadbcm5719-llvm-6d1a09f39fb18ba8513cd47fbcdcf65518411e7c.tar.gz
bcm5719-llvm-6d1a09f39fb18ba8513cd47fbcdcf65518411e7c.zip
[Mips] Reduce code duplication. Join relocation handling functions which
perform similar calculations. llvm-svn: 209590
-rw-r--r--lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
index 8ee6766aae1..a8a9abe1ff8 100644
--- a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
+++ b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
@@ -101,16 +101,16 @@ static void relocCall16(uint8_t *location, uint64_t P, uint64_t S, int64_t A,
applyReloc(location, G, 0xffff);
}
-/// \brief R_MIPS_TLS_TPREL_HI16
+/// \brief R_MIPS_TLS_TPREL_HI16, LLD_R_MIPS_HI16
/// (S + A) >> 16
-static void relocTLSTpRelHi16(uint8_t *location, uint64_t S, int64_t A) {
+static void relocGeneralHi16(uint8_t *location, uint64_t S, int64_t A) {
int32_t result = S + A + 0x8000;
applyReloc(location, result >> 16, 0xffff);
}
-/// \brief R_MIPS_TLS_TPREL_LO16
+/// \brief R_MIPS_TLS_TPREL_LO16, LLD_R_MIPS_LO16
/// S + A
-static void relocTLSTpRelLo16(uint8_t *location, uint64_t S, int64_t A) {
+static void relocGeneralLo16(uint8_t *location, uint64_t S, int64_t A) {
int32_t result = S + A;
applyReloc(location, result, 0xffff);
}
@@ -128,16 +128,6 @@ static void reloc32hi16(uint8_t *location, uint64_t S, int64_t A) {
applyReloc(location, (S + A + 0x8000) & 0xffff0000, 0xffffffff);
}
-/// \brief LLD_R_MIPS_HI16
-static void relocLldHi16(uint8_t *location, uint64_t S) {
- applyReloc(location, (S + 0x8000) >> 16, 0xffff);
-}
-
-/// \brief LLD_R_MIPS_LO16
-static void relocLldLo16(uint8_t *location, uint64_t S) {
- applyReloc(location, S, 0xffff);
-}
-
error_code MipsTargetRelocationHandler::applyRelocation(
ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
const Reference &ref) const {
@@ -177,10 +167,10 @@ error_code MipsTargetRelocationHandler::applyRelocation(
relocCall16(location, relocVAddress, targetVAddress, ref.addend(), gpAddr);
break;
case R_MIPS_TLS_TPREL_HI16:
- relocTLSTpRelHi16(location, targetVAddress, ref.addend());
+ relocGeneralHi16(location, targetVAddress, ref.addend());
break;
case R_MIPS_TLS_TPREL_LO16:
- relocTLSTpRelLo16(location, targetVAddress, ref.addend());
+ relocGeneralLo16(location, targetVAddress, ref.addend());
break;
case R_MIPS_GPREL32:
relocGPRel32(location, relocVAddress, targetVAddress, ref.addend(), gpAddr);
@@ -206,10 +196,10 @@ error_code MipsTargetRelocationHandler::applyRelocation(
reloc26ext(location, targetVAddress, ref.addend());
break;
case LLD_R_MIPS_HI16:
- relocLldHi16(location, targetVAddress);
+ relocGeneralHi16(location, targetVAddress, 0);
break;
case LLD_R_MIPS_LO16:
- relocLldLo16(location, targetVAddress);
+ relocGeneralLo16(location, targetVAddress, 0);
break;
case LLD_R_MIPS_STO_PLT:
// Do nothing.
OpenPOWER on IntegriCloud