[lld] r319367 - Don't crash on broken debug info.
Matt Morehouse via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 15:41:39 PST 2017
Hi Rafael,
This test is failing under UBSan. See
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/10690.
******************** TEST 'lld :: ELF/undef-broken-debug.test' FAILED
********************
Script:
--
/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/yaml2obj
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/ELF/undef-broken-debug.test
-o /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/ELF/Output/undef-broken-debug.test.tmp.o
not /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/ld.lld
--full-shutdown
/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/ELF/Output/undef-broken-debug.test.tmp.o
-o /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/ELF/Output/undef-broken-debug.test.tmp.exe
2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/ELF/undef-broken-debug.test
--
Exit Code: 1
Command Output (stderr):
--
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/ELF/undef-broken-debug.test:8:10:
error: expected string not found in input
# CHECK: error: undefined symbol: bar
^
<stdin>:1:1: note: scanning from here
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/predefined_ops.h:147:24:
runtime error: reference binding to misaligned address 0x000007d9cdd7
for type 'const
llvm::object::Elf_Rel_Impl<llvm::object::ELFType<llvm::support::endianness::little,
true>, true>', which requires 2 byte alignment
^
On Wed, Nov 29, 2017 at 2:09 PM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: rafael
> Date: Wed Nov 29 14:09:16 2017
> New Revision: 319367
>
> URL: http://llvm.org/viewvc/llvm-project?rev=319367&view=rev
> Log:
> Don't crash on broken debug info.
>
> Added:
> lld/trunk/test/ELF/undef-broken-debug.test
> Modified:
> lld/trunk/ELF/GdbIndex.cpp
>
> Modified: lld/trunk/ELF/GdbIndex.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> GdbIndex.cpp?rev=319367&r1=319366&r2=319367&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/GdbIndex.cpp (original)
> +++ lld/trunk/ELF/GdbIndex.cpp Wed Nov 29 14:09:16 2017
> @@ -68,14 +68,17 @@ LLDDwarfObj<ELFT>::findAux(const InputSe
> uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
> const typename ELFT::Sym &Sym = File->getELFSyms()[SymIndex];
> uint32_t SecIndex = File->getSectionIndex(Sym);
> - Symbol &B = File->getRelocTargetSym(Rel);
> - auto &DR = cast<Defined>(B);
> - uint64_t Val = DR.Value + getAddend<ELFT>(Rel);
> +
> + // Broken debug info can point to a non-Defined symbol, just ignore it.
> + auto *DR = dyn_cast<Defined>(&File->getRelocTargetSym(Rel));
> + if (!DR)
> + return None;
> + uint64_t Val = DR->Value + getAddend<ELFT>(Rel);
>
> // FIXME: We should be consistent about always adding the file
> // offset or not.
> - if (DR.Section->Flags & ELF::SHF_ALLOC)
> - Val += cast<InputSection>(DR.Section)->getOffsetInFile();
> + if (DR->Section->Flags & ELF::SHF_ALLOC)
> + Val += cast<InputSection>(DR->Section)->getOffsetInFile();
>
> return RelocAddrEntry{SecIndex, Val};
> }
>
> Added: lld/trunk/test/ELF/undef-broken-debug.test
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> undef-broken-debug.test?rev=319367&view=auto
> ============================================================
> ==================
> --- lld/trunk/test/ELF/undef-broken-debug.test (added)
> +++ lld/trunk/test/ELF/undef-broken-debug.test Wed Nov 29 14:09:16 2017
> @@ -0,0 +1,44 @@
> +# REQUIRES: x86
> +# RUN: yaml2obj %s -o %t.o
> +# RUN: not ld.lld %t.o -o %t.exe 2>&1 | FileCheck %s
> +
> +# The debug info has a broken relocation. Check that we don't crash
> +# and still report the undefined symbol.
> +
> +# CHECK: error: undefined symbol: bar
> +
> +--- !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
> + Link: .symtab
> + Info: .text
> + Relocations:
> + - Offset: 0x0000000000000000
> + Symbol: bar
> + Type: R_X86_64_64
> + - Name: .debug_line
> + Type: SHT_PROGBITS
> + Content: 3300000002001C0000000101FB0E0D
> 000101010100000001000001006162632E73000000000000090200000000
> 00000000140208000101
> + - Name: .rela.debug_line
> + Type: SHT_RELA
> + Link: .symtab
> + Info: .debug_line
> + Relocations:
> + - Offset: 0x0000000000000029
> + Symbol: bar
> + Type: R_X86_64_64
> +Symbols:
> + Global:
> + - Name: _start
> + Section: .text
> + - Name: bar
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171129/6f95b820/attachment.html>
More information about the llvm-commits
mailing list