[lld] r209590 - [Mips] Reduce code duplication. Join relocation handling functions which

Simon Atanasyan simon at atanasyan.com
Sun May 25 02:04:26 PDT 2014


Author: atanasyan
Date: Sun May 25 04:04:15 2014
New Revision: 209590

URL: http://llvm.org/viewvc/llvm-project?rev=209590&view=rev
Log:
[Mips] Reduce code duplication. Join relocation handling functions which
perform similar calculations.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp?rev=209590&r1=209589&r2=209590&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp Sun May 25 04:04:15 2014
@@ -101,16 +101,16 @@ static void relocCall16(uint8_t *locatio
   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 *locatio
   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::
     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::
     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.





More information about the llvm-commits mailing list