From: Simon Atanasyan Date: Sun, 25 May 2014 09:04:15 +0000 (+0000) Subject: [Mips] Reduce code duplication. Join relocation handling functions which X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d1a09f39fb18ba8513cd47fbcdcf65518411e7c;p=platform%2Fupstream%2Fllvm.git [Mips] Reduce code duplication. Join relocation handling functions which perform similar calculations. llvm-svn: 209590 --- diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp index 8ee6766..a8a9abe 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.