diff options
| -rw-r--r-- | lld/ELF/Arch/AArch64.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/AMDGPU.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/ARM.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/AVR.cpp | 3 | ||||
| -rw-r--r-- | lld/ELF/Arch/Hexagon.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/Mips.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/PPC.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/PPC64.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/RISCV.cpp | 3 | ||||
| -rw-r--r-- | lld/ELF/Arch/SPARCV9.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/X86.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Arch/X86_64.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/DWARF.cpp | 6 | ||||
| -rw-r--r-- | lld/ELF/Target.h | 1 | ||||
| -rw-r--r-- | lld/test/ELF/debug-relocation-none.test | 58 | ||||
| -rw-r--r-- | lld/test/ELF/undef-broken-debug.test | 2 |
16 files changed, 81 insertions, 2 deletions
diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index 59c8d15794c..7a0d28ed56b 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -58,6 +58,7 @@ AArch64::AArch64() { RelativeRel = R_AARCH64_RELATIVE; IRelativeRel = R_AARCH64_IRELATIVE; GotRel = R_AARCH64_GLOB_DAT; + NoneRel = R_AARCH64_NONE; PltRel = R_AARCH64_JUMP_SLOT; TlsDescRel = R_AARCH64_TLSDESC; TlsGotRel = R_AARCH64_TLS_TPREL64; diff --git a/lld/ELF/Arch/AMDGPU.cpp b/lld/ELF/Arch/AMDGPU.cpp index 48b27f23510..a7c6c84ceec 100644 --- a/lld/ELF/Arch/AMDGPU.cpp +++ b/lld/ELF/Arch/AMDGPU.cpp @@ -35,6 +35,7 @@ public: AMDGPU::AMDGPU() { RelativeRel = R_AMDGPU_RELATIVE64; GotRel = R_AMDGPU_ABS64; + NoneRel = R_AMDGPU_NONE; GotEntrySize = 8; } diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp index 1fa2acdd506..13a04fe6b3c 100644 --- a/lld/ELF/Arch/ARM.cpp +++ b/lld/ELF/Arch/ARM.cpp @@ -51,6 +51,7 @@ ARM::ARM() { RelativeRel = R_ARM_RELATIVE; IRelativeRel = R_ARM_IRELATIVE; GotRel = R_ARM_GLOB_DAT; + NoneRel = R_ARM_NONE; PltRel = R_ARM_JUMP_SLOT; TlsGotRel = R_ARM_TLS_TPOFF32; TlsModuleIndexRel = R_ARM_TLS_DTPMOD32; diff --git a/lld/ELF/Arch/AVR.cpp b/lld/ELF/Arch/AVR.cpp index 02ac770127b..637da3778bd 100644 --- a/lld/ELF/Arch/AVR.cpp +++ b/lld/ELF/Arch/AVR.cpp @@ -43,12 +43,15 @@ using namespace lld::elf; namespace { class AVR final : public TargetInfo { public: + AVR(); RelExpr getRelExpr(RelType Type, const Symbol &S, const uint8_t *Loc) const override; void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override; }; } // namespace +AVR::AVR() { NoneRel = R_AVR_NONE; } + RelExpr AVR::getRelExpr(RelType Type, const Symbol &S, const uint8_t *Loc) const { return R_ABS; diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp index 4d4bf25b210..afbf76d2948 100644 --- a/lld/ELF/Arch/Hexagon.cpp +++ b/lld/ELF/Arch/Hexagon.cpp @@ -36,6 +36,7 @@ public: Hexagon::Hexagon() { // Hexagon Linux uses 64K pages by default. DefaultMaxPageSize = 0x10000; + NoneRel = R_HEX_NONE; } // Support V60 only at the moment. diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp index 6fb4531ef49..f6402f80a5b 100644 --- a/lld/ELF/Arch/Mips.cpp +++ b/lld/ELF/Arch/Mips.cpp @@ -53,6 +53,7 @@ template <class ELFT> MIPS<ELFT>::MIPS() { PltEntrySize = 16; PltHeaderSize = 32; CopyRel = R_MIPS_COPY; + NoneRel = R_MIPS_NONE; PltRel = R_MIPS_JUMP_SLOT; NeedsThunks = true; TrapInstr = 0xefefefef; diff --git a/lld/ELF/Arch/PPC.cpp b/lld/ELF/Arch/PPC.cpp index 20cae0e59cf..a01068ccd36 100644 --- a/lld/ELF/Arch/PPC.cpp +++ b/lld/ELF/Arch/PPC.cpp @@ -29,6 +29,7 @@ public: } // namespace PPC::PPC() { + NoneRel = R_PPC_NONE; GotBaseSymOff = 0x8000; GotBaseSymInGotPlt = false; } diff --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp index 25dc8a65a30..eb01955e093 100644 --- a/lld/ELF/Arch/PPC64.cpp +++ b/lld/ELF/Arch/PPC64.cpp @@ -192,6 +192,7 @@ static uint32_t readInstrFromHalf16(const uint8_t *Loc) { PPC64::PPC64() { GotRel = R_PPC64_GLOB_DAT; + NoneRel = R_PPC64_NONE; PltRel = R_PPC64_JMP_SLOT; RelativeRel = R_PPC64_RELATIVE; IRelativeRel = R_PPC64_IRELATIVE; diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp index 18a9c51758e..ef727224698 100644 --- a/lld/ELF/Arch/RISCV.cpp +++ b/lld/ELF/Arch/RISCV.cpp @@ -21,6 +21,7 @@ namespace { class RISCV final : public TargetInfo { public: + RISCV(); virtual uint32_t calcEFlags() const override; RelExpr getRelExpr(RelType Type, const Symbol &S, const uint8_t *Loc) const override; @@ -29,6 +30,8 @@ public: } // end anonymous namespace +RISCV::RISCV() { NoneRel = R_RISCV_NONE; } + static uint32_t getEFlags(InputFile *F) { if (Config->Is64) return cast<ObjFile<ELF64LE>>(F)->getObj().getHeader()->e_flags; diff --git a/lld/ELF/Arch/SPARCV9.cpp b/lld/ELF/Arch/SPARCV9.cpp index 36f5c836930..831aa2028e7 100644 --- a/lld/ELF/Arch/SPARCV9.cpp +++ b/lld/ELF/Arch/SPARCV9.cpp @@ -35,6 +35,7 @@ public: SPARCV9::SPARCV9() { CopyRel = R_SPARC_COPY; GotRel = R_SPARC_GLOB_DAT; + NoneRel = R_SPARC_NONE; PltRel = R_SPARC_JMP_SLOT; RelativeRel = R_SPARC_RELATIVE; GotEntrySize = 8; diff --git a/lld/ELF/Arch/X86.cpp b/lld/ELF/Arch/X86.cpp index a0921cd6b21..82246e68966 100644 --- a/lld/ELF/Arch/X86.cpp +++ b/lld/ELF/Arch/X86.cpp @@ -48,6 +48,7 @@ public: X86::X86() { CopyRel = R_386_COPY; GotRel = R_386_GLOB_DAT; + NoneRel = R_386_NONE; PltRel = R_386_JUMP_SLOT; IRelativeRel = R_386_IRELATIVE; RelativeRel = R_386_RELATIVE; diff --git a/lld/ELF/Arch/X86_64.cpp b/lld/ELF/Arch/X86_64.cpp index 3e7f04de17c..960bf782aa7 100644 --- a/lld/ELF/Arch/X86_64.cpp +++ b/lld/ELF/Arch/X86_64.cpp @@ -55,6 +55,7 @@ private: template <class ELFT> X86_64<ELFT>::X86_64() { CopyRel = R_X86_64_COPY; GotRel = R_X86_64_GLOB_DAT; + NoneRel = R_X86_64_NONE; PltRel = R_X86_64_JUMP_SLOT; RelativeRel = R_X86_64_RELATIVE; IRelativeRel = R_X86_64_IRELATIVE; diff --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp index 2b622363e23..11c61053d90 100644 --- a/lld/ELF/DWARF.cpp +++ b/lld/ELF/DWARF.cpp @@ -16,6 +16,7 @@ #include "DWARF.h" #include "Symbols.h" +#include "Target.h" #include "lld/Common/Memory.h" #include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h" #include "llvm/Object/ELFObjectFile.h" @@ -73,7 +74,10 @@ LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos, // Broken debug info can point to a non-Defined symbol. auto *DR = dyn_cast<Defined>(&File->getRelocTargetSym(Rel)); if (!DR) { - error("unsupported relocation target while parsing debug info"); + RelType Type = Rel.getType(Config->IsMips64EL); + if (Type != Target->NoneRel) + error(toString(File) + ": relocation " + lld::toString(Type) + " at 0x" + + llvm::utohexstr(Rel.r_offset) + " has unsupported target"); return None; } uint64_t Val = DR->Value + getAddend<ELFT>(Rel); diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index d48a9cdf2e3..1764963d614 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -95,6 +95,7 @@ public: RelType CopyRel; RelType GotRel; + RelType NoneRel; RelType PltRel; RelType RelativeRel; RelType IRelativeRel; diff --git a/lld/test/ELF/debug-relocation-none.test b/lld/test/ELF/debug-relocation-none.test new file mode 100644 index 00000000000..d22941db222 --- /dev/null +++ b/lld/test/ELF/debug-relocation-none.test @@ -0,0 +1,58 @@ +# REQUIRES: x86 +# RUN: yaml2obj %s -o %t.o +# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s + +## Previously we would report an error saying the relocation in .debug_info +## has an unsupported target. +## Check we do not report debug information parsing errors when relocation +## used is of type R_*_NONE, what actually means it should be ignored. + +# CHECK-NOT: error +# CHECK: error: undefined symbol: bar +# CHECK-NOT: error + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: '0000000000000000' + - Name: .rela.text + Type: SHT_RELA + AddressAlign: 8 + Link: .symtab + Info: .text + Relocations: + - Offset: 0x0000000000000000 + Symbol: bar + Type: R_X86_64_64 + - Name: .debug_line + Type: SHT_PROGBITS + Content: 3300000002001C0000000101FB0E0D000101010100000001000001006162632E7300000000000009020000000000000000140208000101 + - Name: .rela.debug_line + AddressAlign: 8 + Type: SHT_RELA + Link: .symtab + Info: .debug_line + Relocations: + - Offset: 0x0000000000000029 + Type: R_X86_64_NONE + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 0C000000040000000000080100000000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '0111001017000000' + +Symbols: + Global: + - Name: _start + Section: .text + - Name: bar diff --git a/lld/test/ELF/undef-broken-debug.test b/lld/test/ELF/undef-broken-debug.test index b93d399f36c..c3405ad0b9e 100644 --- a/lld/test/ELF/undef-broken-debug.test +++ b/lld/test/ELF/undef-broken-debug.test @@ -5,7 +5,7 @@ # The debug info has a broken relocation. Check that we don't crash # and still report the undefined symbol. -# CHECK: error: unsupported relocation target while parsing debug info +# CHECK: error: {{.*}}.o: relocation R_X86_64_64 at 0x29 has unsupported target # CHECK: error: undefined symbol: bar --- !ELF |

