From 450479189072fcbadf17f7f6d94d3ed0dc1d124f Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Sat, 25 Jul 2015 10:18:39 +0000 Subject: [PATCH] [Mips] Remove duplicated code by joining the same functions llvm-svn: 243209 --- .../ELF/Mips/MipsRelocationHandler.cpp | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp index 34e900b3efa9..4d01d0b59d9f 100644 --- a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp @@ -268,25 +268,10 @@ static ErrorOr relocPc18(uint64_t P, uint64_t S, int64_t A) { return S + A - ((P | 7) ^ 7); } -/// \brief R_MIPS_PC19_S2, R_MICROMIPS_PC19_S2 +/// \brief R_MIPS_PC19_S2, R_MICROMIPS_PC19_S2, R_MIPS_PC21_S2, +/// R_MICROMIPS_PC21_S2, R_MIPS_PC26_S2, R_MICROMIPS_PC26_S2 /// local/external: (S + A - P) >> 2 -static ErrorOr relocPc19(uint64_t P, uint64_t S, int64_t A) { - if ((S + A) & 2) - return make_unaligned_range_reloc_error(); - return S + A - P; -} - -/// \brief R_MIPS_PC21_S2, R_MICROMIPS_PC21_S2 -/// local/external: (S + A - P) >> 2 -static ErrorOr relocPc21(uint64_t P, uint64_t S, int64_t A) { - if ((S + A) & 2) - return make_unaligned_range_reloc_error(); - return S + A - P; -} - -/// \brief R_MIPS_PC26_S2, R_MICROMIPS_PC26_S2 -/// local/external: (S + A - P) >> 2 -static ErrorOr relocPc26(uint64_t P, uint64_t S, int64_t A) { +static ErrorOr relocPcS2(uint64_t P, uint64_t S, int64_t A) { if ((S + A) & 2) return make_unaligned_range_reloc_error(); return S + A - P; @@ -443,13 +428,11 @@ calculateRelocation(Reference::KindValue kind, Reference::Addend addend, return relocPc18(relAddr, tgtAddr, addend); case R_MIPS_PC19_S2: case R_MICROMIPS_PC19_S2: - return relocPc19(relAddr, tgtAddr, addend); case R_MIPS_PC21_S2: case R_MICROMIPS_PC21_S2: - return relocPc21(relAddr, tgtAddr, addend); case R_MIPS_PC26_S2: case R_MICROMIPS_PC26_S2: - return relocPc26(relAddr, tgtAddr, addend); + return relocPcS2(relAddr, tgtAddr, addend); case R_MICROMIPS_PC7_S1: case R_MICROMIPS_PC10_S1: case R_MICROMIPS_PC16_S1: