Index: lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp +++ lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp @@ -36,190 +36,165 @@ return result; } -static int relocBNPCREL(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A, - int32_t nBits) { +static void 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(loc)); write32le(loc, result | read32le(loc)); - return 0; } - return 1; } /// \brief Word32_LO: 0x00c03fff : (S + A) : Truncate -static int relocLO16(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { +static void relocLO16(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { uint32_t result = (uint32_t)(S + A); result = scatterBits(result, 0x00c03fff); write32le(loc, result | read32le(loc)); - return 0; } /// \brief Word32_LO: 0x00c03fff : (S + A) >> 16 : Truncate -static int relocHI16(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { +static void 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); write32le(loc, result | read32le(loc)); - return 0; } /// \brief Word32: 0xffffffff : (S + A) : Truncate -static int reloc32(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { +static void reloc32(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { uint32_t result = (uint32_t)(S + A); write32le(loc, result | read32le(loc)); - return 0; } -static int reloc32_6_X(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { +static void 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); write32le(loc, result | read32le(loc)); - return 0; } // R_HEX_B32_PCREL_X -static int relocHexB32PCRELX(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { +static void relocHexB32PCRELX(uint8_t *loc, uint64_t P, uint64_t S, + uint64_t A) { int64_t result = ((S + A - P) >> 6); result = scatterBits(result, 0xfff3fff); write32le(loc, result | read32le(loc)); - return 0; } // R_HEX_BN_PCREL_X -static int relocHexBNPCRELX(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A, - int nbits) { +static void 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(loc)); write32le(loc, result | read32le(loc)); - return 0; } - return 1; } // R_HEX_6_PCREL_X -static int relocHex6PCRELX(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { +static void relocHex6PCRELX(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { int32_t result = (S + A - P); 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 *loc, uint64_t P, uint64_t S, uint64_t A) { +static void relocHex_N_X(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A) { uint32_t result = (S + A); result = scatterBits(result, findv4bitmask(loc)); write32le(loc, result | read32le(loc)); - return 0; } // GP REL relocs -static int relocHexGPRELN(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A, - uint64_t GP, int nShiftBits) { +static void 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(loc)); write32le(loc, result | read32le(loc)); - return 0; } - return 1; } /// \brief Word32_LO: 0x00c03fff : (G) : Truncate -static int relocHexGOTLO16(uint8_t *loc, uint64_t A, uint64_t GOT) { +static void relocHexGOTLO16(uint8_t *loc, uint64_t A, uint64_t GOT) { int32_t result = (int32_t)(A-GOT); result = scatterBits(result, 0x00c03fff); write32le(loc, result | read32le(loc)); - return 0; } /// \brief Word32_LO: 0x00c03fff : (G) >> 16 : Truncate -static int relocHexGOTHI16(uint8_t *loc, uint64_t A, uint64_t GOT) { +static void relocHexGOTHI16(uint8_t *loc, uint64_t A, uint64_t GOT) { int32_t result = (int32_t)((A-GOT) >> 16); result = scatterBits(result, 0x00c03fff); write32le(loc, result | read32le(loc)); - return 0; } /// \brief Word32: 0xffffffff : (G) : Truncate -static int relocHexGOT32(uint8_t *loc, uint64_t A, uint64_t GOT) { +static void relocHexGOT32(uint8_t *loc, uint64_t A, uint64_t GOT) { int32_t result = (int32_t)(GOT - A); write32le(loc, result | read32le(loc)); - return 0; } /// \brief Word32_U16 : (G) : Truncate -static int relocHexGOT16(uint8_t *loc, uint64_t A, uint64_t GOT) { +static void 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(loc)); write32le(loc, result | read32le(loc)); - return 0; } - return 1; } -static int relocHexGOT32_6_X(uint8_t *loc, uint64_t A, uint64_t GOT) { +static void relocHexGOT32_6_X(uint8_t *loc, uint64_t A, uint64_t GOT) { int32_t result = (int32_t)((A-GOT) >> 6); result = scatterBits(result, findv4bitmask(loc)); write32le(loc, result | read32le(loc)); - return 0; } -static int relocHexGOT16_X(uint8_t *loc, uint64_t A, uint64_t GOT) { +static void 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(loc)); write32le(loc, result | read32le(loc)); - return 0; } - return 1; } -static int relocHexGOT11_X(uint8_t *loc, uint64_t A, uint64_t GOT) { +static void relocHexGOT11_X(uint8_t *loc, uint64_t A, uint64_t GOT) { uint32_t result = (uint32_t)(A-GOT); result = scatterBits(result, findv4bitmask(loc)); write32le(loc, result | read32le(loc)); - return 0; } -static int relocHexGOTRELSigned(uint8_t *loc, uint64_t P, uint64_t S, - uint64_t A, uint64_t GOT, int shiftBits = 0) { +static void 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(loc)); write32le(loc, result | read32le(loc)); - return 0; } -static int relocHexGOTRELUnsigned(uint8_t *loc, uint64_t P, uint64_t S, - uint64_t A, uint64_t GOT, int shiftBits = 0) { +static void 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(loc)); write32le(loc, result | read32le(loc)); - return 0; } -static int relocHexGOTREL_HILO16(uint8_t *loc, uint64_t P, uint64_t S, - uint64_t A, uint64_t GOT, int shiftBits = 0) { +static void 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); write32le(loc, result | read32le(loc)); - return 0; } -static int relocHexGOTREL_32(uint8_t *loc, uint64_t P, uint64_t S, uint64_t A, - uint64_t GOT) { +static void 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); write32le(loc, result | read32le(loc)); - return 0; } std::error_code HexagonTargetRelocationHandler::applyRelocation(