[lld] r350070 - Use error() instead of fatal() to report an invalid address range.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 26 11:15:05 PST 2018
Author: ruiu
Date: Wed Dec 26 11:15:04 2018
New Revision: 350070
URL: http://llvm.org/viewvc/llvm-project?rev=350070&view=rev
Log:
Use error() instead of fatal() to report an invalid address range.
In this patch we also use toString() to stringize a section.
Modified:
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/test/ELF/gdb-index-invalid-ranges.s
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=350070&r1=350069&r2=350070&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Wed Dec 26 11:15:04 2018
@@ -2408,15 +2408,17 @@ static std::vector<GdbIndexSection::CuEn
return Ret;
}
-static Expected<std::vector<GdbIndexSection::AddressEntry>>
+static std::vector<GdbIndexSection::AddressEntry>
readAddressAreas(DWARFContext &Dwarf, InputSection *Sec) {
std::vector<GdbIndexSection::AddressEntry> Ret;
uint32_t CuIdx = 0;
for (std::unique_ptr<DWARFUnit> &Cu : Dwarf.compile_units()) {
Expected<DWARFAddressRangesVector> Ranges = Cu->collectAddressRanges();
- if (!Ranges)
- return Ranges.takeError();
+ if (!Ranges) {
+ error(toString(Sec) + ": " + toString(Ranges.takeError()));
+ return {};
+ }
ArrayRef<InputSectionBase *> Sections = Sec->File->getSections();
for (DWARFAddressRange &R : *Ranges) {
@@ -2433,7 +2435,7 @@ readAddressAreas(DWARFContext &Dwarf, In
++CuIdx;
}
- return std::move(Ret);
+ return Ret;
}
template <class ELFT>
@@ -2565,17 +2567,7 @@ template <class ELFT> GdbIndexSection *G
Chunks[I].Sec = Sections[I];
Chunks[I].CompilationUnits = readCuList(Dwarf);
- Expected<std::vector<GdbIndexSection::AddressEntry>> AddressAreas =
- readAddressAreas(Dwarf, Sections[I]);
- if (!AddressAreas) {
- std::string Msg = File->getName();
- Msg += ": ";
- if (!File->ArchiveName.empty())
- Msg += "in archive " + File->ArchiveName + ": ";
- Msg += toString(AddressAreas.takeError());
- fatal(Msg);
- }
- Chunks[I].AddressAreas = *AddressAreas;
+ Chunks[I].AddressAreas = readAddressAreas(Dwarf, Sections[I]);
NameAttrs[I] = readPubNamesAndTypes<ELFT>(
static_cast<const LLDDwarfObj<ELFT> &>(Dwarf.getDWARFObj()),
Chunks[I].CompilationUnits);
Modified: lld/trunk/test/ELF/gdb-index-invalid-ranges.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gdb-index-invalid-ranges.s?rev=350070&r1=350069&r2=350070&view=diff
==============================================================================
--- lld/trunk/test/ELF/gdb-index-invalid-ranges.s (original)
+++ lld/trunk/test/ELF/gdb-index-invalid-ranges.s Wed Dec 26 11:15:04 2018
@@ -5,8 +5,8 @@
# RUN: llvm-ar rc %t.a %t.o
# RUN: not ld.lld --gdb-index -e main %t2.o %t.a -o %t 2>&1 | FileCheck --check-prefix=ARCHIVE %s
-# CHECK: ld.lld: error: {{.*}}gdb-index-invalid-ranges.s.tmp.o: decoding address ranges: invalid range list entry at offset 0x10
-# ARCHIVE: ld.lld: error: gdb-index-invalid-ranges.s.tmp.o: in archive {{.*}}gdb-index-invalid-ranges.s.tmp.a: decoding address ranges: invalid range list entry at offset 0x10
+# CHECK: ld.lld: error: {{.*}}gdb-index-invalid-ranges.s.tmp.o:(.debug_info): decoding address ranges: invalid range list entry at offset 0x10
+# ARCHIVE: ld.lld: error: {{.*}}gdb-index-invalid-ranges.s.tmp.a(gdb-index-invalid-ranges.s.tmp.o):(.debug_info): decoding address ranges: invalid range list entry at offset 0x10
.section .text.foo1,"ax", at progbits
.globl f1
More information about the llvm-commits
mailing list