ELF: Use short variable names in <Arch>RelocationHandlers.cpp.

Functions in the files are hard to read because of line wrapping.
Use shorter names for local variables so that the lines fit
within 80 columns.

llvm-svn: 234087
This commit is contained in:
Rui Ueyama 2015-04-04 04:22:27 +00:00
parent 7ea899a15f
commit a5f1ae1ad0
5 changed files with 108 additions and 142 deletions

View File

@ -322,9 +322,10 @@ std::error_code AArch64TargetRelocationHandler::applyRelocation(
ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *location = atomContent + ref.offsetInAtom();
uint64_t targetVAddress = writer.addressOfAtom(ref.target());
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
uint8_t *loc = atomContent + ref.offsetInAtom();
uint64_t target = writer.addressOfAtom(ref.target());
uint64_t reloc = atom._virtualAddr + ref.offsetInAtom();
int64_t addend = ref.addend();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
return std::error_code();
@ -333,15 +334,13 @@ std::error_code AArch64TargetRelocationHandler::applyRelocation(
case R_AARCH64_NONE:
break;
case R_AARCH64_ABS64:
relocR_AARCH64_ABS64(location, relocVAddress, targetVAddress, ref.addend());
relocR_AARCH64_ABS64(loc, reloc, target, addend);
break;
case R_AARCH64_PREL32:
relocR_AARCH64_PREL32(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_PREL32(loc, reloc, target, addend);
break;
case R_AARCH64_ABS32:
return relocR_AARCH64_ABS32(location, relocVAddress, targetVAddress,
ref.addend());
return relocR_AARCH64_ABS32(loc, reloc, target, addend);
// Runtime only relocations. Ignore here.
case R_AARCH64_RELATIVE:
case R_AARCH64_IRELATIVE:
@ -349,76 +348,59 @@ std::error_code AArch64TargetRelocationHandler::applyRelocation(
case R_AARCH64_GLOB_DAT:
break;
case R_AARCH64_ADR_PREL_PG_HI21:
relocR_AARCH64_ADR_PREL_PG_HI21(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_ADR_PREL_PG_HI21(loc, reloc, target, addend);
break;
case R_AARCH64_ADR_PREL_LO21:
relocR_AARCH64_ADR_PREL_LO21(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_ADR_PREL_LO21(loc, reloc, target, addend);
break;
case R_AARCH64_ADD_ABS_LO12_NC:
relocR_AARCH64_ADD_ABS_LO12_NC(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_ADD_ABS_LO12_NC(loc, reloc, target, addend);
break;
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
relocJump26(location, relocVAddress, targetVAddress, ref.addend());
relocJump26(loc, reloc, target, addend);
break;
case R_AARCH64_CONDBR19:
relocR_AARCH64_CONDBR19(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_CONDBR19(loc, reloc, target, addend);
break;
case R_AARCH64_ADR_GOT_PAGE:
relocR_AARCH64_ADR_GOT_PAGE(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_ADR_GOT_PAGE(loc, reloc, target, addend);
break;
case R_AARCH64_LD64_GOT_LO12_NC:
relocR_AARCH64_LD64_GOT_LO12_NC(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_LD64_GOT_LO12_NC(loc, reloc, target, addend);
break;
case R_AARCH64_LDST8_ABS_LO12_NC:
relocR_AARCH64_LDST8_ABS_LO12_NC(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_LDST8_ABS_LO12_NC(loc, reloc, target, addend);
break;
case R_AARCH64_LDST16_ABS_LO12_NC:
relocR_AARCH64_LDST16_ABS_LO12_NC(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_LDST16_ABS_LO12_NC(loc, reloc, target, addend);
break;
case R_AARCH64_LDST32_ABS_LO12_NC:
relocR_AARCH64_LDST32_ABS_LO12_NC(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_LDST32_ABS_LO12_NC(loc, reloc, target, addend);
break;
case R_AARCH64_LDST64_ABS_LO12_NC:
relocR_AARCH64_LDST64_ABS_LO12_NC(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_LDST64_ABS_LO12_NC(loc, reloc, target, addend);
break;
case R_AARCH64_LDST128_ABS_LO12_NC:
relocR_AARCH64_LDST128_ABS_LO12_NC(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_LDST128_ABS_LO12_NC(loc, reloc, target, addend);
break;
case ADD_AARCH64_GOTRELINDEX:
relocADD_AARCH64_GOTRELINDEX(location, relocVAddress, targetVAddress,
ref.addend());
relocADD_AARCH64_GOTRELINDEX(loc, reloc, target, addend);
break;
case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
relocR_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21(location, relocVAddress,
targetVAddress, ref.addend());
relocR_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21(loc, reloc, target, addend);
break;
case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
relocR_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC(location, relocVAddress,
targetVAddress, ref.addend());
relocR_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC(loc, reloc, target, addend);
break;
case R_AARCH64_TLSLE_ADD_TPREL_HI12:
relocR_AARCH64_TLSLE_ADD_TPREL_HI12(location, relocVAddress, targetVAddress,
ref.addend());
relocR_AARCH64_TLSLE_ADD_TPREL_HI12(loc, reloc, target, addend);
break;
case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
relocR_AARCH64_TLSLE_ADD_TPREL_LO12_NC(location, relocVAddress,
targetVAddress, ref.addend());
relocR_AARCH64_TLSLE_ADD_TPREL_LO12_NC(loc, reloc, target, addend);
break;
default:
return make_unhandled_reloc_error();
}
return std::error_code();
}

View File

@ -500,9 +500,9 @@ std::error_code ARMTargetRelocationHandler::applyRelocation(
ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *location = atomContent + ref.offsetInAtom();
uint64_t targetVAddress = writer.addressOfAtom(ref.target());
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
uint8_t *loc = atomContent + ref.offsetInAtom();
uint64_t target = writer.addressOfAtom(ref.target());
uint64_t reloc = atom._virtualAddr + ref.offsetInAtom();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
return std::error_code();
@ -510,102 +510,87 @@ std::error_code ARMTargetRelocationHandler::applyRelocation(
// Calculate proper initial addend for the relocation
const Reference::Addend addend =
readAddend(location, ref.kindValue()) + ref.addend();
readAddend(loc, ref.kindValue()) + ref.addend();
// Flags that the relocation addresses Thumb instruction
bool addressesThumb = false;
bool thumb = false;
if (const auto *definedAtom = dyn_cast<DefinedAtom>(ref.target())) {
addressesThumb = isThumbCode(definedAtom);
thumb = isThumbCode(definedAtom);
}
switch (ref.kindValue()) {
case R_ARM_NONE:
break;
case R_ARM_ABS32:
relocR_ARM_ABS32(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_ABS32(loc, reloc, target, addend, thumb);
break;
case R_ARM_REL32:
relocR_ARM_REL32(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_REL32(loc, reloc, target, addend, thumb);
break;
case R_ARM_TARGET1:
if (_armLayout.target1Rel())
relocR_ARM_REL32(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_REL32(loc, reloc, target, addend, thumb);
else
relocR_ARM_ABS32(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_ABS32(loc, reloc, target, addend, thumb);
break;
case R_ARM_THM_CALL:
// TODO: consider adding bool variable to disable J1 & J2 for archs
// before ARMv6
relocR_ARM_THM_CALL(location, relocVAddress, targetVAddress, addend, true,
addressesThumb);
relocR_ARM_THM_CALL(loc, reloc, target, addend, true, thumb);
break;
case R_ARM_CALL:
relocR_ARM_CALL(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_CALL(loc, reloc, target, addend, thumb);
break;
case R_ARM_JUMP24:
relocR_ARM_JUMP24(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_JUMP24(loc, reloc, target, addend, thumb);
break;
case R_ARM_THM_JUMP24:
relocR_ARM_THM_JUMP24(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_THM_JUMP24(loc, reloc, target, addend, thumb);
break;
case R_ARM_THM_JUMP11:
relocR_ARM_THM_JUMP11(location, relocVAddress, targetVAddress, addend);
relocR_ARM_THM_JUMP11(loc, reloc, target, addend);
break;
case R_ARM_MOVW_ABS_NC:
relocR_ARM_MOVW_ABS_NC(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_MOVW_ABS_NC(loc, reloc, target, addend, thumb);
break;
case R_ARM_MOVT_ABS:
relocR_ARM_MOVT_ABS(location, relocVAddress, targetVAddress, addend);
relocR_ARM_MOVT_ABS(loc, reloc, target, addend);
break;
case R_ARM_THM_MOVW_ABS_NC:
relocR_ARM_THM_MOVW_ABS_NC(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_THM_MOVW_ABS_NC(loc, reloc, target, addend, thumb);
break;
case R_ARM_THM_MOVT_ABS:
relocR_ARM_THM_MOVT_ABS(location, relocVAddress, targetVAddress, addend);
relocR_ARM_THM_MOVT_ABS(loc, reloc, target, addend);
break;
case R_ARM_PREL31:
relocR_ARM_PREL31(location, relocVAddress, targetVAddress, addend,
addressesThumb);
relocR_ARM_PREL31(loc, reloc, target, addend, thumb);
break;
case R_ARM_TLS_IE32:
relocR_ARM_TLS_IE32(location, relocVAddress, targetVAddress, addend);
relocR_ARM_TLS_IE32(loc, reloc, target, addend);
break;
case R_ARM_TLS_LE32:
relocR_ARM_TLS_LE32(location, relocVAddress, targetVAddress, addend,
_armLayout.getTPOffset());
relocR_ARM_TLS_LE32(loc, reloc, target, addend, _armLayout.getTPOffset());
break;
case R_ARM_GOT_BREL:
relocR_ARM_GOT_BREL(location, relocVAddress, targetVAddress, addend,
_armLayout.getGOTSymAddr());
relocR_ARM_GOT_BREL(loc, reloc, target, addend, _armLayout.getGOTSymAddr());
break;
case R_ARM_BASE_PREL:
// GOT origin is used for NULL symbol and when explicitly specified
if (!targetVAddress ||
ref.target()->name().equals("_GLOBAL_OFFSET_TABLE_")) {
targetVAddress = _armLayout.getGOTSymAddr();
if (!target || ref.target()->name().equals("_GLOBAL_OFFSET_TABLE_")) {
target = _armLayout.getGOTSymAddr();
} else {
llvm_unreachable("Segment-base relative addressing is not supported");
}
relocR_ARM_BASE_PREL(location, relocVAddress, targetVAddress, addend);
relocR_ARM_BASE_PREL(loc, reloc, target, addend);
break;
case R_ARM_ALU_PC_G0_NC:
relocR_ARM_ALU_PC_G0_NC(location, relocVAddress, targetVAddress, addend);
relocR_ARM_ALU_PC_G0_NC(loc, reloc, target, addend);
break;
case R_ARM_ALU_PC_G1_NC:
relocR_ARM_ALU_PC_G1_NC(location, relocVAddress, targetVAddress, addend);
relocR_ARM_ALU_PC_G1_NC(loc, reloc, target, addend);
break;
case R_ARM_LDR_PC_G2:
relocR_ARM_LDR_PC_G2(location, relocVAddress, targetVAddress, addend);
relocR_ARM_LDR_PC_G2(loc, reloc, target, addend);
break;
case R_ARM_IRELATIVE:
// Runtime only relocations. Ignore here.

View File

@ -214,67 +214,67 @@ std::error_code HexagonTargetRelocationHandler::applyRelocation(
ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *location = atomContent + ref.offsetInAtom();
uint64_t targetVAddress = writer.addressOfAtom(ref.target());
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
uint8_t *loc = atomContent + ref.offsetInAtom();
uint64_t target = writer.addressOfAtom(ref.target());
uint64_t reloc = atom._virtualAddr + ref.offsetInAtom();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
return std::error_code();
assert(ref.kindArch() == Reference::KindArch::Hexagon);
switch (ref.kindValue()) {
case R_HEX_B22_PCREL:
relocBNPCREL(location, relocVAddress, targetVAddress, ref.addend(), 21);
relocBNPCREL(loc, reloc, target, ref.addend(), 21);
break;
case R_HEX_B15_PCREL:
relocBNPCREL(location, relocVAddress, targetVAddress, ref.addend(), 14);
relocBNPCREL(loc, reloc, target, ref.addend(), 14);
break;
case R_HEX_B9_PCREL:
relocBNPCREL(location, relocVAddress, targetVAddress, ref.addend(), 8);
relocBNPCREL(loc, reloc, target, ref.addend(), 8);
break;
case R_HEX_LO16:
relocLO16(location, relocVAddress, targetVAddress, ref.addend());
relocLO16(loc, reloc, target, ref.addend());
break;
case R_HEX_HI16:
relocHI16(location, relocVAddress, targetVAddress, ref.addend());
relocHI16(loc, reloc, target, ref.addend());
break;
case R_HEX_32:
reloc32(location, relocVAddress, targetVAddress, ref.addend());
reloc32(loc, reloc, target, ref.addend());
break;
case R_HEX_32_6_X:
reloc32_6_X(location, relocVAddress, targetVAddress, ref.addend());
reloc32_6_X(loc, reloc, target, ref.addend());
break;
case R_HEX_B32_PCREL_X:
relocHexB32PCRELX(location, relocVAddress, targetVAddress, ref.addend());
relocHexB32PCRELX(loc, reloc, target, ref.addend());
break;
case R_HEX_B22_PCREL_X:
relocHexBNPCRELX(location, relocVAddress, targetVAddress, ref.addend(), 21);
relocHexBNPCRELX(loc, reloc, target, ref.addend(), 21);
break;
case R_HEX_B15_PCREL_X:
relocHexBNPCRELX(location, relocVAddress, targetVAddress, ref.addend(), 14);
relocHexBNPCRELX(loc, reloc, target, ref.addend(), 14);
break;
case R_HEX_B13_PCREL_X:
relocHexBNPCRELX(location, relocVAddress, targetVAddress, ref.addend(), 12);
relocHexBNPCRELX(loc, reloc, target, ref.addend(), 12);
break;
case R_HEX_B9_PCREL_X:
relocHexBNPCRELX(location, relocVAddress, targetVAddress, ref.addend(), 8);
relocHexBNPCRELX(loc, reloc, target, ref.addend(), 8);
break;
case R_HEX_B7_PCREL_X:
relocHexBNPCRELX(location, relocVAddress, targetVAddress, ref.addend(), 6);
relocHexBNPCRELX(loc, reloc, target, ref.addend(), 6);
break;
case R_HEX_GPREL16_0:
relocHexGPRELN(location, relocVAddress, targetVAddress, ref.addend(),
relocHexGPRELN(loc, reloc, target, ref.addend(),
_targetLayout.getSDataSection()->virtualAddr(), 0);
break;
case R_HEX_GPREL16_1:
relocHexGPRELN(location, relocVAddress, targetVAddress, ref.addend(),
relocHexGPRELN(loc, reloc, target, ref.addend(),
_targetLayout.getSDataSection()->virtualAddr(), 1);
break;
case R_HEX_GPREL16_2:
relocHexGPRELN(location, relocVAddress, targetVAddress, ref.addend(),
relocHexGPRELN(loc, reloc, target, ref.addend(),
_targetLayout.getSDataSection()->virtualAddr(), 2);
break;
case R_HEX_GPREL16_3:
relocHexGPRELN(location, relocVAddress, targetVAddress, ref.addend(),
relocHexGPRELN(loc, reloc, target, ref.addend(),
_targetLayout.getSDataSection()->virtualAddr(), 3);
break;
case R_HEX_16_X:
@ -285,55 +285,55 @@ std::error_code HexagonTargetRelocationHandler::applyRelocation(
case R_HEX_8_X:
case R_HEX_7_X:
case R_HEX_6_X:
relocHex_N_X(location, relocVAddress, targetVAddress, ref.addend());
relocHex_N_X(loc, reloc, target, ref.addend());
break;
case R_HEX_6_PCREL_X:
relocHex6PCRELX(location, relocVAddress, targetVAddress, ref.addend());
relocHex6PCRELX(loc, reloc, target, ref.addend());
break;
case R_HEX_JMP_SLOT:
case R_HEX_GLOB_DAT:
break;
case R_HEX_GOTREL_32:
relocHexGOTREL_32(location, relocVAddress, targetVAddress, ref.addend(),
relocHexGOTREL_32(loc, reloc, target, ref.addend(),
_targetLayout.getGOTSymAddr());
break;
case R_HEX_GOTREL_LO16:
relocHexGOTREL_HILO16(location, relocVAddress, targetVAddress, ref.addend(),
relocHexGOTREL_HILO16(loc, reloc, target, ref.addend(),
_targetLayout.getGOTSymAddr());
break;
case R_HEX_GOTREL_HI16:
relocHexGOTREL_HILO16(location, relocVAddress, targetVAddress, ref.addend(),
relocHexGOTREL_HILO16(loc, reloc, target, ref.addend(),
_targetLayout.getGOTSymAddr(), 16);
break;
case R_HEX_GOT_LO16:
relocHexGOTLO16(location, targetVAddress, _targetLayout.getGOTSymAddr());
relocHexGOTLO16(loc, target, _targetLayout.getGOTSymAddr());
break;
case R_HEX_GOT_HI16:
relocHexGOTHI16(location, targetVAddress, _targetLayout.getGOTSymAddr());
relocHexGOTHI16(loc, target, _targetLayout.getGOTSymAddr());
break;
case R_HEX_GOT_32:
relocHexGOT32(location, targetVAddress, _targetLayout.getGOTSymAddr());
relocHexGOT32(loc, target, _targetLayout.getGOTSymAddr());
break;
case R_HEX_GOT_16:
relocHexGOT16(location, targetVAddress, _targetLayout.getGOTSymAddr());
relocHexGOT16(loc, target, _targetLayout.getGOTSymAddr());
break;
case R_HEX_GOT_32_6_X:
relocHexGOT32_6_X(location, targetVAddress, _targetLayout.getGOTSymAddr());
relocHexGOT32_6_X(loc, target, _targetLayout.getGOTSymAddr());
break;
case R_HEX_GOT_16_X:
relocHexGOT16_X(location, targetVAddress, _targetLayout.getGOTSymAddr());
relocHexGOT16_X(loc, target, _targetLayout.getGOTSymAddr());
break;
case R_HEX_GOT_11_X:
relocHexGOT11_X(location, targetVAddress, _targetLayout.getGOTSymAddr());
relocHexGOT11_X(loc, target, _targetLayout.getGOTSymAddr());
break;
case R_HEX_GOTREL_32_6_X:
relocHexGOTRELSigned(location, relocVAddress, targetVAddress, ref.addend(),
relocHexGOTRELSigned(loc, reloc, target, ref.addend(),
_targetLayout.getGOTSymAddr(), 6);
break;
case R_HEX_GOTREL_16_X:
case R_HEX_GOTREL_11_X:
relocHexGOTRELUnsigned(location, relocVAddress, targetVAddress,
ref.addend(), _targetLayout.getGOTSymAddr());
relocHexGOTRELUnsigned(loc, reloc, target, ref.addend(),
_targetLayout.getGOTSymAddr());
break;
default:

View File

@ -33,23 +33,22 @@ std::error_code X86TargetRelocationHandler::applyRelocation(
ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *location = atomContent + ref.offsetInAtom();
uint64_t targetVAddress = writer.addressOfAtom(ref.target());
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
uint8_t *loc = atomContent + ref.offsetInAtom();
uint64_t target = writer.addressOfAtom(ref.target());
uint64_t reloc = atom._virtualAddr + ref.offsetInAtom();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
return std::error_code();
assert(ref.kindArch() == Reference::KindArch::x86);
switch (ref.kindValue()) {
case R_386_32:
reloc32(location, relocVAddress, targetVAddress, ref.addend());
reloc32(loc, reloc, target, ref.addend());
break;
case R_386_PC32:
relocPC32(location, relocVAddress, targetVAddress, ref.addend());
relocPC32(loc, reloc, target, ref.addend());
break;
default:
return make_unhandled_reloc_error();
}
return std::error_code();
}

View File

@ -65,9 +65,9 @@ std::error_code X86_64TargetRelocationHandler::applyRelocation(
ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *location = atomContent + ref.offsetInAtom();
uint64_t targetVAddress = writer.addressOfAtom(ref.target());
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
uint8_t *loc = atomContent + ref.offsetInAtom();
uint64_t target = writer.addressOfAtom(ref.target());
uint64_t reloc = atom._virtualAddr + ref.offsetInAtom();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
return std::error_code();
@ -76,23 +76,23 @@ std::error_code X86_64TargetRelocationHandler::applyRelocation(
case R_X86_64_NONE:
break;
case R_X86_64_64:
reloc64(location, relocVAddress, targetVAddress, ref.addend());
reloc64(loc, reloc, target, ref.addend());
break;
case R_X86_64_PC32:
case R_X86_64_GOTPCREL:
relocPC32(location, relocVAddress, targetVAddress, ref.addend());
relocPC32(loc, reloc, target, ref.addend());
break;
case R_X86_64_32:
reloc32(location, relocVAddress, targetVAddress, ref.addend());
reloc32(loc, reloc, target, ref.addend());
break;
case R_X86_64_32S:
reloc32S(location, relocVAddress, targetVAddress, ref.addend());
reloc32S(loc, reloc, target, ref.addend());
break;
case R_X86_64_16:
reloc16(location, relocVAddress, targetVAddress, ref.addend());
reloc16(loc, reloc, target, ref.addend());
break;
case R_X86_64_PC16:
relocPC16(location, relocVAddress, targetVAddress, ref.addend());
relocPC16(loc, reloc, target, ref.addend());
break;
case R_X86_64_TPOFF64:
case R_X86_64_DTPOFF32:
@ -100,14 +100,14 @@ std::error_code X86_64TargetRelocationHandler::applyRelocation(
_tlsSize = _layout.getTLSSize();
if (ref.kindValue() == R_X86_64_TPOFF32 ||
ref.kindValue() == R_X86_64_DTPOFF32) {
write32le(location, targetVAddress - _tlsSize);
write32le(loc, target - _tlsSize);
} else {
write64le(location, targetVAddress - _tlsSize);
write64le(loc, target - _tlsSize);
}
break;
}
case R_X86_64_TLSGD: {
relocPC32(location, relocVAddress, targetVAddress, ref.addend());
relocPC32(loc, reloc, target, ref.addend());
break;
}
case R_X86_64_TLSLD: {
@ -115,11 +115,11 @@ std::error_code X86_64TargetRelocationHandler::applyRelocation(
// next relocation is a PC32 to __tls_get_addr...
static uint8_t instr[] = { 0x66, 0x66, 0x66, 0x64, 0x48, 0x8b, 0x04, 0x25,
0x00, 0x00, 0x00, 0x00 };
std::memcpy(location - 3, instr, sizeof(instr));
std::memcpy(loc - 3, instr, sizeof(instr));
break;
}
case R_X86_64_PC64:
relocPC64(location, relocVAddress, targetVAddress, ref.addend());
relocPC64(loc, reloc, target, ref.addend());
break;
case LLD_R_X86_64_GOTRELINDEX: {
const DefinedAtom *target = cast<const DefinedAtom>(ref.target());
@ -128,7 +128,7 @@ std::error_code X86_64TargetRelocationHandler::applyRelocation(
uint32_t index;
if (!_layout.getPLTRelocationTable()->getRelocationIndex(*r, index))
llvm_unreachable("Relocation doesn't exist");
reloc32(location, 0, index, 0);
reloc32(loc, 0, index, 0);
break;
}
}