uint64_t pltEntryAddr) const override;
void relocate(uint8_t *loc, const Relocation &rel,
uint64_t val) const override;
+ int64_t getImplicitAddend(const uint8_t *buf, RelType type) const override;
void applyJumpInstrMod(uint8_t *loc, JumpModType type,
unsigned size) const override;
}
}
+int64_t X86_64::getImplicitAddend(const uint8_t *buf, RelType type) const {
+ switch (type) {
+ case R_X86_64_8:
+ case R_X86_64_PC8:
+ return SignExtend64<8>(*buf);
+ case R_X86_64_16:
+ case R_X86_64_PC16:
+ return SignExtend64<16>(read16le(buf));
+ case R_X86_64_32:
+ case R_X86_64_32S:
+ case R_X86_64_TPOFF32:
+ case R_X86_64_GOT32:
+ case R_X86_64_GOTPC32:
+ case R_X86_64_GOTPC32_TLSDESC:
+ case R_X86_64_GOTPCREL:
+ case R_X86_64_GOTPCRELX:
+ case R_X86_64_REX_GOTPCRELX:
+ case R_X86_64_PC32:
+ case R_X86_64_GOTTPOFF:
+ case R_X86_64_PLT32:
+ case R_X86_64_TLSGD:
+ case R_X86_64_TLSLD:
+ case R_X86_64_DTPOFF32:
+ case R_X86_64_SIZE32:
+ return SignExtend64<32>(read32le(buf));
+ case R_X86_64_64:
+ case R_X86_64_TPOFF64:
+ case R_X86_64_DTPOFF64:
+ case R_X86_64_DTPMOD64:
+ case R_X86_64_PC64:
+ case R_X86_64_SIZE64:
+ case R_X86_64_GLOB_DAT:
+ case R_X86_64_GOT64:
+ case R_X86_64_GOTOFF64:
+ case R_X86_64_GOTPC64:
+ case R_X86_64_IRELATIVE:
+ case R_X86_64_RELATIVE:
+ return read64le(buf);
+ case R_X86_64_JUMP_SLOT:
+ case R_X86_64_NONE:
+ // These relocations are defined as not having an implicit addend.
+ return 0;
+ default:
+ internalLinkerError(getErrorLocation(buf),
+ "cannot read addend for relocation " + toString(type));
+ return 0;
+ }
+}
+
void X86_64::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
switch (rel.type) {
case R_X86_64_8:
// enable the debug checks for all targets, but currently not all targets
// have support for reading Elf_Rel addends, so we only enable for a subset.
#ifndef NDEBUG
- bool checkDynamicRelocsDefault = m == EM_ARM || m == EM_386 || m == EM_MIPS;
+ bool checkDynamicRelocsDefault =
+ m == EM_ARM || m == EM_386 || m == EM_MIPS || m == EM_X86_64;
#else
bool checkDynamicRelocsDefault = false;
#endif
## want to use this feature, which is not restricted by ELF gABI.
## GNU ld supports this as well.
-# Needs https://reviews.llvm.org/D101451 to read the implicit addends.
-# XFAIL: *
-
# RUN: yaml2obj %s -DTYPE=SHT_RELA -o %t1.o
# RUN: ld.lld -shared %t1.o -o %t1
# RUN: llvm-readelf --relocs %t1 | FileCheck %s