diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Object/RelocationResolver.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Object/RelocationResolver.cpp | 64 |
1 files changed, 4 insertions, 60 deletions
diff --git a/contrib/llvm-project/llvm/lib/Object/RelocationResolver.cpp b/contrib/llvm-project/llvm/lib/Object/RelocationResolver.cpp index 31478be7899e..55b315a20d17 100644 --- a/contrib/llvm-project/llvm/lib/Object/RelocationResolver.cpp +++ b/contrib/llvm-project/llvm/lib/Object/RelocationResolver.cpp @@ -30,7 +30,6 @@ static bool supportsX86_64(uint64_t Type) { case ELF::R_X86_64_DTPOFF32: case ELF::R_X86_64_DTPOFF64: case ELF::R_X86_64_PC32: - case ELF::R_X86_64_PC64: case ELF::R_X86_64_32: case ELF::R_X86_64_32S: return true; @@ -48,7 +47,6 @@ static uint64_t resolveX86_64(RelocationRef R, uint64_t S, uint64_t A) { case ELF::R_X86_64_DTPOFF64: return S + getELFAddend(R); case ELF::R_X86_64_PC32: - case ELF::R_X86_64_PC64: return S + getELFAddend(R) - R.getOffset(); case ELF::R_X86_64_32: case ELF::R_X86_64_32S: @@ -339,7 +337,6 @@ static bool supportsRISCV(uint64_t Type) { switch (Type) { case ELF::R_RISCV_NONE: case ELF::R_RISCV_32: - case ELF::R_RISCV_32_PCREL: case ELF::R_RISCV_64: case ELF::R_RISCV_SET6: case ELF::R_RISCV_SUB6: @@ -364,14 +361,12 @@ static uint64_t resolveRISCV(RelocationRef R, uint64_t S, uint64_t A) { return A; case ELF::R_RISCV_32: return (S + RA) & 0xFFFFFFFF; - case ELF::R_RISCV_32_PCREL: - return (S + RA - R.getOffset()) & 0xFFFFFFFF; case ELF::R_RISCV_64: return S + RA; case ELF::R_RISCV_SET6: - return (A & 0xC0) | ((S + RA) & 0x3F); + return (A + (S + RA)) & 0xFF; case ELF::R_RISCV_SUB6: - return (A & 0xC0) | (((A & 0x3F) - (S + RA)) & 0x3F); + return (A - (S + RA)) & 0xFF; case ELF::R_RISCV_ADD8: return (A + (S + RA)) & 0xFF; case ELF::R_RISCV_SUB8: @@ -434,47 +429,6 @@ static uint64_t resolveCOFFX86_64(RelocationRef R, uint64_t S, uint64_t A) { } } -static bool supportsCOFFARM(uint64_t Type) { - switch (Type) { - case COFF::IMAGE_REL_ARM_SECREL: - case COFF::IMAGE_REL_ARM_ADDR32: - return true; - default: - return false; - } -} - -static uint64_t resolveCOFFARM(RelocationRef R, uint64_t S, uint64_t A) { - switch (R.getType()) { - case COFF::IMAGE_REL_ARM_SECREL: - case COFF::IMAGE_REL_ARM_ADDR32: - return (S + A) & 0xFFFFFFFF; - default: - llvm_unreachable("Invalid relocation type"); - } -} - -static bool supportsCOFFARM64(uint64_t Type) { - switch (Type) { - case COFF::IMAGE_REL_ARM64_SECREL: - case COFF::IMAGE_REL_ARM64_ADDR64: - return true; - default: - return false; - } -} - -static uint64_t resolveCOFFARM64(RelocationRef R, uint64_t S, uint64_t A) { - switch (R.getType()) { - case COFF::IMAGE_REL_ARM64_SECREL: - return (S + A) & 0xFFFFFFFF; - case COFF::IMAGE_REL_ARM64_ADDR64: - return S + A; - default: - llvm_unreachable("Invalid relocation type"); - } -} - static bool supportsMachOX86_64(uint64_t Type) { return Type == MachO::X86_64_RELOC_UNSIGNED; } @@ -527,19 +481,9 @@ static uint64_t resolveWasm32(RelocationRef R, uint64_t S, uint64_t A) { std::pair<bool (*)(uint64_t), RelocationResolver> getRelocationResolver(const ObjectFile &Obj) { if (Obj.isCOFF()) { - switch (Obj.getArch()) { - case Triple::x86_64: + if (Obj.getBytesInAddress() == 8) return {supportsCOFFX86_64, resolveCOFFX86_64}; - case Triple::x86: - return {supportsCOFFX86, resolveCOFFX86}; - case Triple::arm: - case Triple::thumb: - return {supportsCOFFARM, resolveCOFFARM}; - case Triple::aarch64: - return {supportsCOFFARM64, resolveCOFFARM64}; - default: - return {nullptr, nullptr}; - } + return {supportsCOFFX86, resolveCOFFX86}; } else if (Obj.isELF()) { if (Obj.getBytesInAddress() == 8) { switch (Obj.getArch()) { |
