summaryrefslogtreecommitdiff
path: root/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp')
-rw-r--r--lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp b/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp
index da5a24c6ec37..15774bc33123 100644
--- a/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp
+++ b/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp
@@ -15,7 +15,6 @@ using namespace lld;
using namespace lld::elf;
using namespace llvm::support::endian;
-namespace {
/// \brief R_386_32 - word32: S + A
static int reloc32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
int32_t result = (uint32_t)(S + A);
@@ -25,33 +24,31 @@ static int reloc32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
/// \brief R_386_PC32 - word32: S + A - P
static int relocPC32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
- uint32_t result = (uint32_t)((S + A) - P);
+ uint32_t result = (uint32_t)(S + A - P);
write32le(location, result + read32le(location));
return 0;
}
-}
std::error_code X86TargetRelocationHandler::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
+ ELFWriter &writer, llvm::FileOutputBuffer &buf, const 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();
}