[lld] bb4eacd - [ELF] Refactor how Symbol::used is set. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 5 11:09:44 PST 2022
Author: Fangrui Song
Date: 2022-02-05T11:09:40-08:00
New Revision: bb4eacdb7079eee9429b1abc0b7acd9481dfa337
URL: https://github.com/llvm/llvm-project/commit/bb4eacdb7079eee9429b1abc0b7acd9481dfa337
DIFF: https://github.com/llvm/llvm-project/commit/bb4eacdb7079eee9429b1abc0b7acd9481dfa337.diff
LOG: [ELF] Refactor how Symbol::used is set. NFC
Added:
Modified:
lld/ELF/Symbols.h
lld/ELF/Writer.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index a306cdd3a01f..8333e02bae63 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -248,12 +248,11 @@ class Symbol {
isUsedInRegularObj(!file || file->kind() == InputFile::ObjKind),
exportDynamic(false), inDynamicList(false), canInline(false),
referenced(false), traced(false), hasVersionSuffix(false),
- isInIplt(false), gotInIgot(false), isPreemptible(false),
- used(!config->gcSections), folded(false), needsTocRestore(false),
- scriptDefined(false), needsCopy(false), needsGot(false),
- needsPlt(false), needsTlsDesc(false), needsTlsGd(false),
- needsTlsGdToIe(false), needsTlsLd(false), needsGotDtprel(false),
- needsTlsIe(false), hasDirectReloc(false) {}
+ isInIplt(false), gotInIgot(false), isPreemptible(false), used(false),
+ folded(false), needsTocRestore(false), scriptDefined(false),
+ needsCopy(false), needsGot(false), needsPlt(false), needsTlsDesc(false),
+ needsTlsGd(false), needsTlsGdToIe(false), needsTlsLd(false),
+ needsGotDtprel(false), needsTlsIe(false), hasDirectReloc(false) {}
public:
// True if this symbol is in the Iplt sub-section of the Plt and the Igot
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 9383ac46c8e7..0bcf3dec2509 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -619,12 +619,8 @@ template <class ELFT> static void markUsedLocalSymbols() {
// See MarkLive<ELFT>::resolveReloc().
if (config->gcSections)
return;
- // Without --gc-sections, the field is initialized with "true".
- // Drop the flag first and then rise for symbols referenced in relocations.
for (ELFFileBase *file : objectFiles) {
ObjFile<ELFT> *f = cast<ObjFile<ELFT>>(file);
- for (Symbol *b : f->getLocalSymbols())
- b->used = false;
for (InputSectionBase *s : f->getSections()) {
InputSection *isec = dyn_cast_or_null<InputSection>(s);
if (!isec)
@@ -688,7 +684,7 @@ static bool includeInSymtab(const Symbol &b) {
return false;
return true;
}
- return b.used;
+ return b.used || !config->gcSections;
}
// Local symbols are not in the linker's symbol table. This function scans
More information about the llvm-commits
mailing list