[lld] 3c19b4f - [lld-macho] Skip over symbols in un-parsed debug info sections
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 5 14:24:41 PST 2021
Author: Jez Ng
Date: 2021-03-05T17:24:32-05:00
New Revision: 3c19b4f34d6a2a2fb628a3db9225a5167e363234
URL: https://github.com/llvm/llvm-project/commit/3c19b4f34d6a2a2fb628a3db9225a5167e363234
DIFF: https://github.com/llvm/llvm-project/commit/3c19b4f34d6a2a2fb628a3db9225a5167e363234.diff
LOG: [lld-macho] Skip over symbols in un-parsed debug info sections
clang appears to emit symbols in `__debug_aranges`, at least
for arm64... in the examples I've seen, it doesn't seem like those
symbols are referenced outside of `__DWARF`, so I think they're safe to
ignore. But hopefully @clayborg can confirm.
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D98073
Added:
Modified:
lld/MachO/InputFiles.cpp
lld/MachO/SyntheticSections.cpp
lld/test/MachO/stabs.s
Removed:
################################################################################
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index ed3e73e201c6..a426a8cea66f 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -407,7 +407,11 @@ void ObjFile::parseSymbols(ArrayRef<structs::nlist_64> nList,
const section_64 &sec = sectionHeaders[sym.n_sect - 1];
SubsectionMap &subsecMap = subsections[sym.n_sect - 1];
- assert(!subsecMap.empty());
+
+ // parseSections() may have chosen not to parse this section.
+ if (subsecMap.empty())
+ continue;
+
uint64_t offset = sym.n_value - sec.addr;
// If the input file does not use subsections-via-symbols, all symbols can
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 49f5deffd002..b38ffeacf27c 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -733,6 +733,8 @@ void SymtabSection::finalizeContents() {
for (InputFile *file : inputFiles) {
if (auto *objFile = dyn_cast<ObjFile>(file)) {
for (Symbol *sym : objFile->symbols) {
+ if (sym == nullptr)
+ continue;
// TODO: when we implement -dead_strip, we should filter out symbols
// that belong to dead sections.
if (auto *defined = dyn_cast<Defined>(sym)) {
diff --git a/lld/test/MachO/stabs.s b/lld/test/MachO/stabs.s
index ad9dacc62804..09735feb5b26 100644
--- a/lld/test/MachO/stabs.s
+++ b/lld/test/MachO/stabs.s
@@ -181,6 +181,10 @@ Ldebug_info_end0:
.subsections_via_symbols
.section __DWARF,__debug_line,regular,debug
+.section __DWARF,__debug_aranges,regular,debug
+ltmp1:
+ .byte 0
+
#--- no-debug.s
## This file has no debug info.
.text
More information about the llvm-commits
mailing list