Skip to content

Commit

Permalink
DebugInfo: Explicitly handle errors when parsing unit DIEs
Browse files Browse the repository at this point in the history
This ensures these errors produce a non-zero exit and improves the
context (providing the name of the input object and section being
parsed).

llvm-svn: 368378
  • Loading branch information
dwblaikie committed Aug 9, 2019
1 parent 0fcc1f7 commit 84b55e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lld/ELF/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,10 @@ readAddressAreas(DWARFContext &dwarf, InputSection *sec) {

uint32_t cuIdx = 0;
for (std::unique_ptr<DWARFUnit> &cu : dwarf.compile_units()) {
if (Error e = cu->tryExtractDIEsIfNeeded(false)) {
error(toString(sec) + ": " + toString(std::move(e)));
return {};
}
Expected<DWARFAddressRangesVector> ranges = cu->collectAddressRanges();
if (!ranges) {
error(toString(sec) + ": " + toString(ranges.takeError()));
Expand Down
6 changes: 2 additions & 4 deletions lld/test/ELF/gdb-index-parse-fail.s
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
# RUN: ld.lld --gdb-index %t1.o -o %t 2>&1 | FileCheck %s
# RUN: not ld.lld --gdb-index %t1.o -o %t 2>&1 | FileCheck %s

# FIXME: ld.lld should return non-zero (add a "NOT" to start once this bug is fixed)

# CHECK: error: invalid contribution to string offsets table
# CHECK: error: {{.*}}:(.debug_info): invalid reference to or invalid content in .debug_str_offsets[.dwo]: insufficient space for 32 bit header prefix

.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code
Expand Down

0 comments on commit 84b55e6

Please sign in to comment.