sym->partition = newPart.getNumber();
}
-static Symbol *addUndefined(StringRef name) {
- return symtab->addSymbol(
- Undefined{nullptr, name, STB_GLOBAL, STV_DEFAULT, 0});
-}
-
static Symbol *addUnusedUndefined(StringRef name,
uint8_t binding = STB_GLOBAL) {
- Undefined sym{nullptr, name, binding, STV_DEFAULT, 0};
- sym.isUsedInRegularObj = false;
- return symtab->addSymbol(sym);
+ return symtab->addSymbol(Undefined{nullptr, name, binding, STV_DEFAULT, 0});
}
static void markBuffersAsDontNeed(bool skipLinkedOutput) {
// Some symbols (such as __ehdr_start) are defined lazily only when there
// are undefined symbols for them, so we add these to trigger that logic.
for (StringRef name : script->referencedSymbols)
- addUndefined(name);
+ addUnusedUndefined(name)->isUsedInRegularObj = true;
// Prevent LTO from removing any definition referenced by -u.
for (StringRef name : config->undefined)
else
new (symbols[i]) Defined(this, name, STB_LOCAL, eSym.st_other, type,
eSym.st_value, eSym.st_size, sec);
+ symbols[i]->isUsedInRegularObj = true;
}
// Some entries have been filled by LazyObjFile.
uint64_t size = eSym.st_size;
Symbol *sym = symbols[i];
+ sym->isUsedInRegularObj = true;
if (LLVM_UNLIKELY(eSym.st_shndx == SHN_COMMON)) {
if (value == 0 || value >= UINT32_MAX)
fatal(toString(this) + ": common symbol '" + sym->getName() +
// extract. We should demote the lazy symbol to an Undefined so that any
// relocations outside of the group to it will trigger a discarded section
// error.
- if (sym->symbolKind == Symbol::LazyObjectKind && !sym->file->lazy) {
+ if (sym->symbolKind == Symbol::LazyObjectKind && !sym->file->lazy)
sym->replace(und);
- // Prevent LTO from internalizing the symbol in case there is a
- // reference to this symbol from this file.
- sym->isUsedInRegularObj = true;
- } else
+ else
sym->resolve(und);
continue;
}
Symbol *sym = symbols[i];
sym->resolve(Undefined{this, StringRef(), eSym.getBinding(), eSym.st_other,
eSym.getType()});
+ sym->isUsedInRegularObj = true;
sym->referenced = true;
}
}
Symbol *sym = symtab->insert(cmd->name);
sym->mergeProperties(newSym);
sym->replace(newSym);
+ sym->isUsedInRegularObj = true;
cmd->sym = cast<Defined>(sym);
}
cmd->sym = cast<Defined>(sym);
cmd->provide = false;
+ sym->isUsedInRegularObj = true;
sym->scriptDefined = true;
}
if (sym->isDefined())
sym->checkDuplicate(newSym);
sym->resolve(newSym);
+ sym->isUsedInRegularObj = true;
return sym;
}
void Symbol::mergeProperties(const Symbol &other) {
if (other.exportDynamic)
exportDynamic = true;
- if (other.isUsedInRegularObj)
- isUsedInRegularObj = true;
// DSO symbols do not affect visibility in the output.
if (!other.isShared())
: file(file), nameData(name.data()), nameSize(name.size()),
binding(binding), type(type), stOther(stOther), symbolKind(k),
visibility(stOther & 3), isPreemptible(false),
- isUsedInRegularObj(!file || file->kind() == InputFile::ObjKind),
- used(false), exportDynamic(false), inDynamicList(false),
- referenced(false), traced(false), hasVersionSuffix(false),
- isInIplt(false), gotInIgot(false), folded(false),
- needsTocRestore(false), scriptDefined(false), needsCopy(false),
- needsGot(false), needsPlt(false), needsTlsDesc(false),
+ isUsedInRegularObj(false), used(false), exportDynamic(false),
+ inDynamicList(false), referenced(false), traced(false),
+ hasVersionSuffix(false), isInIplt(false), gotInIgot(false),
+ folded(false), needsTocRestore(false), scriptDefined(false),
+ needsCopy(false), needsGot(false), needsPlt(false), needsTlsDesc(false),
needsTlsGd(false), needsTlsGdToIe(false), needsGotDtprel(false),
needsTlsIe(false), hasDirectReloc(false) {}
public:
LazyObject(InputFile &file)
: Symbol(LazyObjectKind, &file, {}, llvm::ELF::STB_GLOBAL,
- llvm::ELF::STV_DEFAULT, llvm::ELF::STT_NOTYPE) {
- isUsedInRegularObj = false;
- }
+ llvm::ELF::STV_DEFAULT, llvm::ELF::STT_NOTYPE) {}
static bool classof(const Symbol *s) { return s->kind() == LazyObjectKind; }
};
s->resolve(Defined{nullptr, StringRef(), STB_GLOBAL, stOther, STT_NOTYPE, val,
/*size=*/0, sec});
+ s->isUsedInRegularObj = true;
return cast<Defined>(s);
}
static Defined *addAbsolute(StringRef name) {
Symbol *sym = symtab->addSymbol(Defined{nullptr, name, STB_GLOBAL, STV_HIDDEN,
STT_NOTYPE, 0, 0, nullptr});
+ sym->isUsedInRegularObj = true;
return cast<Defined>(sym);
}
// Even the author of gold doesn't remember why gold behaves that way.
// https://sourceware.org/ml/binutils/2002-03/msg00360.html
if (mainPart->dynamic->parent)
- symtab->addSymbol(
- Defined{/*file=*/nullptr, "_DYNAMIC", STB_WEAK, STV_HIDDEN, STT_NOTYPE,
- /*value=*/0, /*size=*/0, mainPart->dynamic.get()});
+ symtab->addSymbol(Defined{/*file=*/nullptr, "_DYNAMIC", STB_WEAK, STV_HIDDEN, STT_NOTYPE,
+ /*value=*/0, /*size=*/0, mainPart->dynamic.get()})->isUsedInRegularObj = true;
// Define __rel[a]_iplt_{start,end} symbols if needed.
addRelIpltSymbols();