summaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-12-26 19:15:04 +0000
committerRui Ueyama <ruiu@google.com>2018-12-26 19:15:04 +0000
commit5fa59576a8133b2d8682af53921820873e35bc10 (patch)
treeee5c807e475a53b4cfcf65d174812c45e84d67a5 /lld
parente1e1965a52af03a76f13559a3d06af70d237c244 (diff)
Use error() instead of fatal() to report an invalid address range.
In this patch we also use toString() to stringize a section.
Diffstat (limited to 'lld')
-rw-r--r--lld/ELF/SyntheticSections.cpp22
-rw-r--r--lld/test/ELF/gdb-index-invalid-ranges.s4
2 files changed, 9 insertions, 17 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index d84d9472e40..f459c1b6b47 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2408,15 +2408,17 @@ static std::vector<GdbIndexSection::CuEntry> readCuList(DWARFContext &Dwarf) {
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, InputSection *Sec) {
++CuIdx;
}
- return std::move(Ret);
+ return Ret;
}
template <class ELFT>
@@ -2565,17 +2567,7 @@ template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
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);
diff --git a/lld/test/ELF/gdb-index-invalid-ranges.s b/lld/test/ELF/gdb-index-invalid-ranges.s
index 05165a24bc5..1aac98d87cf 100644
--- a/lld/test/ELF/gdb-index-invalid-ranges.s
+++ b/lld/test/ELF/gdb-index-invalid-ranges.s
@@ -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",@progbits
.globl f1