[lld] 2cb3d28 - [lld/mac] Add some comments and asserts
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 12:43:44 PDT 2022
Author: Nico Weber
Date: 2022-04-07T15:43:28-04:00
New Revision: 2cb3d28b173570c4b34c5ce85bc18713670d07e1
URL: https://github.com/llvm/llvm-project/commit/2cb3d28b173570c4b34c5ce85bc18713670d07e1
DIFF: https://github.com/llvm/llvm-project/commit/2cb3d28b173570c4b34c5ce85bc18713670d07e1.diff
LOG: [lld/mac] Add some comments and asserts
I was wondering if SymtabSection::emitStabs() should check
defined->includeInSymtab. Add asserts and comments explaining why that's not
necessary.
No behavior change.
Differential Revision: https://reviews.llvm.org/D123302
Added:
Modified:
lld/MachO/SymbolTable.cpp
lld/MachO/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index 2b6fb77f08aa4..a3e32537dc4f8 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -230,8 +230,9 @@ Defined *SymbolTable::addSynthetic(StringRef name, InputSection *isec,
uint64_t value, bool isPrivateExtern,
bool includeInSymtab,
bool referencedDynamically) {
+ assert(!isec || !isec->getFile()); // See makeSyntheticInputSection().
Defined *s =
- addDefined(name, nullptr, isec, value, /*size=*/0,
+ addDefined(name, /*file=*/nullptr, isec, value, /*size=*/0,
/*isWeakDef=*/false, isPrivateExtern,
/*isThumb=*/false, referencedDynamically,
/*noDeadStrip=*/false, /*isWeakDefCanBeHidden=*/false);
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index fd6f5e432e9ab..8ed6f5c2d51c2 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -908,6 +908,11 @@ void SymtabSection::emitStabs() {
ObjFile *file = dyn_cast_or_null<ObjFile>(isec->getFile());
if (!file || !file->compileUnit)
continue;
+
+ // All symbols that set includeInSymtab to false are synthetic symbols.
+ // Those have `file` set to nullptr and were already skipped due to that.
+ assert(defined->includeInSymtab);
+
symbolsNeedingStabs.push_back(defined);
}
}
More information about the llvm-commits
mailing list