[lld] r234552 - ELF: Don't use APPLY_RELOC macro.
Rui Ueyama
ruiu at google.com
Thu Apr 9 17:19:41 PDT 2015
Author: ruiu
Date: Thu Apr 9 19:19:41 2015
New Revision: 234552
URL: http://llvm.org/viewvc/llvm-project?rev=234552&view=rev
Log:
ELF: Don't use APPLY_RELOC macro.
In other ELF ports, we don't use the macro. This patch removes the
macro for consistency and readability.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp?rev=234552&r1=234551&r2=234552&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp Thu Apr 9 19:19:41 2015
@@ -36,194 +36,189 @@ static uint32_t scatterBits(uint32_t val
return result;
}
-#define APPLY_RELOC(result) \
- write32le(location, result | read32le(location));
-
-static int relocBNPCREL(uint8_t *location, uint64_t P, uint64_t S, uint64_t A,
+static int relocBNPCREL(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A,
int32_t nBits) {
int32_t result = (uint32_t)(((S + A) - P) >> 2);
int32_t range = 1 << nBits;
if (result < range && result > -range) {
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
return 1;
}
/// \brief Word32_LO: 0x00c03fff : (S + A) : Truncate
-static int relocLO16(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
+static int relocLO16(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) {
uint32_t result = (uint32_t)(S + A);
result = scatterBits(result, 0x00c03fff);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
/// \brief Word32_LO: 0x00c03fff : (S + A) >> 16 : Truncate
-static int relocHI16(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
+static int relocHI16(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) {
uint32_t result = (uint32_t)((S + A) >> 16);
result = scatterBits(result, 0x00c03fff);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
/// \brief Word32: 0xffffffff : (S + A) : Truncate
-static int reloc32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
+static int reloc32(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) {
uint32_t result = (uint32_t)(S + A);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
-static int reloc32_6_X(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
+static int reloc32_6_X(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) {
int64_t result = ((S + A) >> 6);
int64_t range = ((int64_t)1) << 32;
if (result > range)
return 1;
result = scatterBits(result, 0xfff3fff);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
// R_HEX_B32_PCREL_X
-static int relocHexB32PCRELX(uint8_t *location, uint64_t P, uint64_t S,
- uint64_t A) {
+static int relocHexB32PCRELX(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) {
int64_t result = ((S + A - P) >> 6);
result = scatterBits(result, 0xfff3fff);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
// R_HEX_BN_PCREL_X
-static int relocHexBNPCRELX(uint8_t *location, uint64_t P, uint64_t S,
- uint64_t A, int nbits) {
+static int relocHexBNPCRELX(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A,
+ int nbits) {
int32_t result = ((S + A - P) & 0x3f);
int32_t range = 1 << nbits;
if (result < range && result > -range) {
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
return 1;
}
// R_HEX_6_PCREL_X
-static int relocHex6PCRELX(uint8_t *location, uint64_t P, uint64_t S,
- uint64_t A) {
+static int relocHex6PCRELX(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) {
int32_t result = (S + A - P);
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
// R_HEX_N_X : Word32_U6 : (S + A) : Unsigned Truncate
-static int relocHex_N_X(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
+static int relocHex_N_X(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) {
uint32_t result = (S + A);
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
-// GP REL relocations
-static int relocHexGPRELN(uint8_t *location, uint64_t P, uint64_t S, uint64_t A,
+// GP REL relocs
+static int relocHexGPRELN(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A,
uint64_t GP, int nShiftBits) {
int32_t result = (int64_t)((S + A - GP) >> nShiftBits);
int32_t range = 1L << 16;
if (result <= range) {
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
return 1;
}
/// \brief Word32_LO: 0x00c03fff : (G) : Truncate
-static int relocHexGOTLO16(uint8_t *location, uint64_t A, uint64_t GOT) {
+static int relocHexGOTLO16(uint8_t *loc, uint64_t A, uint64_t GOT) {
int32_t result = (int32_t)(A-GOT);
result = scatterBits(result, 0x00c03fff);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
/// \brief Word32_LO: 0x00c03fff : (G) >> 16 : Truncate
-static int relocHexGOTHI16(uint8_t *location, uint64_t A, uint64_t GOT) {
+static int relocHexGOTHI16(uint8_t *loc, uint64_t A, uint64_t GOT) {
int32_t result = (int32_t)((A-GOT) >> 16);
result = scatterBits(result, 0x00c03fff);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
/// \brief Word32: 0xffffffff : (G) : Truncate
-static int relocHexGOT32(uint8_t *location, uint64_t A, uint64_t GOT) {
+static int relocHexGOT32(uint8_t *loc, uint64_t A, uint64_t GOT) {
int32_t result = (int32_t)(GOT - A);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
/// \brief Word32_U16 : (G) : Truncate
-static int relocHexGOT16(uint8_t *location, uint64_t A, uint64_t GOT) {
+static int relocHexGOT16(uint8_t *loc, uint64_t A, uint64_t GOT) {
int32_t result = (int32_t)(GOT-A);
int32_t range = 1L << 16;
if (result <= range) {
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
return 1;
}
-static int relocHexGOT32_6_X(uint8_t *location, uint64_t A, uint64_t GOT) {
+static int relocHexGOT32_6_X(uint8_t *loc, uint64_t A, uint64_t GOT) {
int32_t result = (int32_t)((A-GOT) >> 6);
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
-static int relocHexGOT16_X(uint8_t *location, uint64_t A, uint64_t GOT) {
+static int relocHexGOT16_X(uint8_t *loc, uint64_t A, uint64_t GOT) {
int32_t result = (int32_t)(A-GOT);
int32_t range = 1L << 6;
if (result <= range) {
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
return 1;
}
-static int relocHexGOT11_X(uint8_t *location, uint64_t A, uint64_t GOT) {
+static int relocHexGOT11_X(uint8_t *loc, uint64_t A, uint64_t GOT) {
uint32_t result = (uint32_t)(A-GOT);
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
-static int relocHexGOTRELSigned(uint8_t *location, uint64_t P, uint64_t S,
+static int relocHexGOTRELSigned(uint8_t *loc, uint64_t P, uint64_t S,
uint64_t A, uint64_t GOT, int shiftBits = 0) {
int32_t result = (int32_t)((S + A - GOT) >> shiftBits);
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
-static int relocHexGOTRELUnsigned(uint8_t *location, uint64_t P, uint64_t S,
+static int relocHexGOTRELUnsigned(uint8_t *loc, uint64_t P, uint64_t S,
uint64_t A, uint64_t GOT, int shiftBits = 0) {
uint32_t result = (uint32_t)((S + A - GOT) >> shiftBits);
- result = scatterBits(result, findv4bitmask(location));
- APPLY_RELOC(result);
+ result = scatterBits(result, findv4bitmask(loc));
+ write32le(loc, result | read32le(loc));
return 0;
}
-static int relocHexGOTREL_HILO16(uint8_t *location, uint64_t P, uint64_t S,
+static int relocHexGOTREL_HILO16(uint8_t *loc, uint64_t P, uint64_t S,
uint64_t A, uint64_t GOT, int shiftBits = 0) {
int32_t result = (int32_t)((S + A - GOT) >> shiftBits);
result = scatterBits(result, 0x00c03fff);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
-static int relocHexGOTREL_32(uint8_t *location, uint64_t P, uint64_t S,
- uint64_t A, uint64_t GOT) {
+static int relocHexGOTREL_32(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A,
+ uint64_t GOT) {
int32_t result = (int32_t)(S + A - GOT);
- APPLY_RELOC(result);
+ write32le(loc, result | read32le(loc));
return 0;
}
More information about the llvm-commits
mailing list