if (!sym->isLazy())
return;
- sym->fetch();
+ sym->extract();
if (!config->whyExtract.empty())
whyExtract.emplace_back(option, sym->file, *sym);
}
return;
}
+ // Calling sym->extract() in the loop is not safe because it may add new
+ // symbols to the symbol table, invalidating the current iterator.
std::vector<Symbol *> syms;
- for (Symbol *sym : symtab->symbols()) {
- // Calling Sym->fetch() from here is not safe because it may
- // add new symbols to the symbol table, invalidating the
- // current iterator. So we just keep a note.
+ for (Symbol *sym : symtab->symbols())
if (pat->match(sym->getName()))
syms.push_back(sym);
- }
for (Symbol *sym : syms)
handleUndefined(sym, "--undefined-glob");
mb = cast<LazyArchive>(sym)->getMemberBuffer();
if (isBitcode(mb))
- sym->fetch();
+ sym->extract();
}
// Handle --dependency-file=<path>. If that option is given, lld creates a
symtab->insert(arg->getValue())->traced = true;
// Handle -u/--undefined before input files. If both a.a and b.so define foo,
- // -u foo a.a b.so will fetch a.a.
+ // -u foo a.a b.so will extract a.a.
for (StringRef name : config->undefined)
addUnusedUndefined(name)->referenced = true;
if (sec == &InputSection::discarded) {
Undefined und{this, name, binding, stOther, type, secIdx};
Symbol *sym = this->symbols[i];
- // !ArchiveFile::parsed or LazyObjFile::fetched means that the file
+ // !ArchiveFile::parsed or LazyObjFile::extracted means that the file
// containing this object has not finished processing, i.e. this symbol is
- // a result of a lazy symbol fetch. We should demote the lazy symbol to an
- // Undefined so that any relocations outside of the group to it will
+ // a result of a lazy symbol 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::LazyArchiveKind &&
!cast<ArchiveFile>(sym->file)->parsed) ||
(sym->symbolKind == Symbol::LazyObjectKind &&
- cast<LazyObjFile>(sym->file)->fetched))
+ cast<LazyObjFile>(sym->file)->extracted))
sym->replace(und);
else
sym->resolve(und);
}
// Undefined symbols (excluding those defined relative to non-prevailing
- // sections) can trigger recursive fetch. Process defined symbols first so
+ // sections) can trigger recursive extract. Process defined symbols first so
// that the relative order between a defined symbol and an undefined symbol
// does not change the symbol resolution behavior. In addition, a set of
// interconnected symbols will all be resolved to the same file, instead of
}
// Returns a buffer pointing to a member file containing a given symbol.
-void ArchiveFile::fetch(const Archive::Symbol &sym) {
+void ArchiveFile::extract(const Archive::Symbol &sym) {
Archive::Child c =
CHECK(sym.getMember(), toString(this) +
": could not get the member for symbol " +
}
}
-bool ArchiveFile::shouldFetchForCommon(const Archive::Symbol &sym) {
+bool ArchiveFile::shouldExtractForCommon(const Archive::Symbol &sym) {
Archive::Child c =
CHECK(sym.getMember(), toString(this) +
": could not get the member for symbol " +
}
}
-void LazyObjFile::fetch() {
- if (fetched)
+void LazyObjFile::extract() {
+ if (extracted)
return;
- fetched = true;
+ extracted = true;
InputFile *file = createObjectFile(mb, archiveName, offsetInArchive);
file->groupId = groupId;
// Replace existing symbols with LazyObject symbols.
//
- // resolve() may trigger this->fetch() if an existing symbol is an
+ // resolve() may trigger this->extract() if an existing symbol is an
// undefined symbol. If that happens, this LazyObjFile has served
// its purpose, and we can exit from the loop early.
for (Symbol *sym : this->symbols) {
continue;
sym->resolve(LazyObject{*this, sym->getName()});
- // If fetched, stop iterating because this->symbols has been transferred
+ // If extracted, stop iterating because this->symbols has been transferred
// to the instantiated ObjFile.
- if (fetched)
+ if (extracted)
return;
}
return;
}
}
-bool LazyObjFile::shouldFetchForCommon(const StringRef &name) {
+bool LazyObjFile::shouldExtractForCommon(const StringRef &name) {
if (isBitcode(mb))
return isBitcodeNonCommonDef(mb, name, archiveName);
static bool classof(const InputFile *f) { return f->kind() == LazyObjKind; }
template <class ELFT> void parse();
- void fetch();
+ void extract();
- // Check if a non-common symbol should be fetched to override a common
+ // Check if a non-common symbol should be extracted to override a common
// definition.
- bool shouldFetchForCommon(const StringRef &name);
+ bool shouldExtractForCommon(const StringRef &name);
- bool fetched = false;
+ bool extracted = false;
private:
uint64_t offsetInArchive;
// returns it. If the same file was instantiated before, this
// function does nothing (so we don't instantiate the same file
// more than once.)
- void fetch(const Archive::Symbol &sym);
+ void extract(const Archive::Symbol &sym);
- // Check if a non-common symbol should be fetched to override a common
+ // Check if a non-common symbol should be extracted to override a common
// definition.
- bool shouldFetchForCommon(const Archive::Symbol &sym);
+ bool shouldExtractForCommon(const Archive::Symbol &sym);
size_t getMemberCount() const;
- size_t getFetchedMemberCount() const { return seen.size(); }
+ size_t getExtractedMemberCount() const { return seen.size(); }
bool parsed = false;
// distributed build system that depends on that behavior.
static void thinLTOCreateEmptyIndexFiles() {
for (LazyObjFile *f : lazyObjFiles) {
- if (f->fetched || !isBitcode(f->mb))
+ if (f->extracted || !isBitcode(f->mb))
continue;
std::string path = replaceThinLTOSuffix(getThinLTOOutputFile(f->getName()));
std::unique_ptr<raw_fd_ostream> os = openFile(path + ".thinlto.bc");
return;
}
- os << "members\tfetched\tarchive\n";
+ os << "members\textracted\tarchive\n";
for (const ArchiveFile *f : archiveFiles)
- os << f->getMemberCount() << '\t' << f->getFetchedMemberCount() << '\t'
+ os << f->getMemberCount() << '\t' << f->getExtractedMemberCount() << '\t'
<< f->getName() << '\n';
}
def print_archive_stats: J<"print-archive-stats=">,
HelpText<"Write archive usage statistics to the specified file. "
- "Print the numbers of members and fetched members for each archive">;
+ "Print the numbers of members and extracted members for each archive">;
defm print_symbol_order: Eq<"print-symbol-order",
"Print a symbol order specified by --call-graph-ordering-file into the specified file">;
defm version_script: Eq<"version-script", "Read a version script">;
defm warn_backrefs: BB<"warn-backrefs",
- "Warn about backward symbol references to fetch archive members",
- "Do not warn about backward symbol references to fetch archive members (default)">;
+ "Warn about backward symbol references to extract archive members",
+ "Do not warn about backward symbol references to extract archive members (default)">;
defm warn_backrefs_exclude
: EEq<"warn-backrefs-exclude",
// A version script/dynamic list is only meaningful for a Defined symbol.
// A CommonSymbol will be converted to a Defined in replaceCommonSymbols().
-// A lazy symbol may be made Defined if an LTO libcall fetches it.
+// A lazy symbol may be made Defined if an LTO libcall extracts it.
static bool canBeVersioned(const Symbol &sym) {
return sym.isDefined() || sym.isCommon() || sym.isLazy();
}
verstr);
}
-void Symbol::fetch() const {
+void Symbol::extract() const {
if (auto *sym = dyn_cast<LazyArchive>(this)) {
- cast<ArchiveFile>(sym->file)->fetch(sym->sym);
+ cast<ArchiveFile>(sym->file)->extract(sym->sym);
return;
}
if (auto *sym = dyn_cast<LazyObject>(this)) {
- dyn_cast<LazyObjFile>(sym->file)->fetch();
+ dyn_cast<LazyObjFile>(sym->file)->extract();
return;
}
- llvm_unreachable("Symbol::fetch() is called on a non-lazy symbol");
+ llvm_unreachable("Symbol::extract() is called on a non-lazy symbol");
}
MemoryBufferRef LazyArchive::getMemberBuffer() {
printTraceSymbol(&other);
if (isLazy()) {
- // An undefined weak will not fetch archive members. See comment on Lazy in
- // Symbols.h for the details.
+ // An undefined weak will not extract archive members. See comment on Lazy
+ // in Symbols.h for the details.
if (other.binding == STB_WEAK) {
binding = STB_WEAK;
type = other.type;
// Do extra check for --warn-backrefs.
//
// --warn-backrefs is an option to prevent an undefined reference from
- // fetching an archive member written earlier in the command line. It can be
- // used to keep compatibility with GNU linkers to some degree.
- // I'll explain the feature and why you may find it useful in this comment.
+ // extracting an archive member written earlier in the command line. It can
+ // be used to keep compatibility with GNU linkers to some degree. I'll
+ // explain the feature and why you may find it useful in this comment.
//
// lld's symbol resolution semantics is more relaxed than traditional Unix
// linkers. For example,
// group assignment rule simulates the traditional linker's semantics.
bool backref = config->warnBackrefs && other.file &&
file->groupId < other.file->groupId;
- fetch();
+ extract();
if (!config->whyExtract.empty())
recordWhyExtract(other.file, *file, *this);
static void replaceCommon(Symbol &oldSym, const LazyT &newSym) {
backwardReferences.erase(&oldSym);
oldSym.replace(newSym);
- newSym.fetch();
+ newSym.extract();
}
template <class LazyT> void Symbol::resolveLazy(const LazyT &other) {
// For common objects, we want to look for global or weak definitions that
- // should be fetched as the canonical definition instead.
+ // should be extracted as the canonical definition instead.
if (isCommon() && elf::config->fortranCommon) {
if (auto *laSym = dyn_cast<LazyArchive>(&other)) {
ArchiveFile *archive = cast<ArchiveFile>(laSym->file);
const Archive::Symbol &archiveSym = laSym->sym;
- if (archive->shouldFetchForCommon(archiveSym)) {
+ if (archive->shouldExtractForCommon(archiveSym)) {
replaceCommon(*this, other);
return;
}
} else if (auto *loSym = dyn_cast<LazyObject>(&other)) {
LazyObjFile *obj = cast<LazyObjFile>(loSym->file);
- if (obj->shouldFetchForCommon(loSym->getName())) {
+ if (obj->shouldExtractForCommon(loSym->getName())) {
replaceCommon(*this, other);
return;
}
return;
}
- // An undefined weak will not fetch archive members. See comment on Lazy in
+ // An undefined weak will not extract archive members. See comment on Lazy in
// Symbols.h for the details.
if (isWeak()) {
uint8_t ty = type;
}
const InputFile *oldFile = file;
- other.fetch();
+ other.extract();
if (!config->whyExtract.empty())
recordWhyExtract(oldFile, *file, *this);
}
// Symbol binding. This is not overwritten by replace() to track
// changes during resolution. In particular:
// - An undefined weak is still weak when it resolves to a shared library.
- // - An undefined weak will not fetch archive members, but we have to
+ // - An undefined weak will not extract archive members, but we have to
// remember it is weak.
uint8_t binding;
void mergeProperties(const Symbol &other);
void resolve(const Symbol &other);
- // If this is a lazy symbol, fetch an input file and add the symbol
+ // If this is a lazy symbol, extract an input file and add the symbol
// in the file to the symbol table. Calling this function on
// non-lazy object causes a runtime error.
- void fetch() const;
+ void extract() const;
static bool isExportDynamic(Kind k, uint8_t visibility) {
if (k == SharedKind)
void VersionTableSection::writeTo(uint8_t *buf) {
buf += 2;
for (const SymbolTableEntry &s : getPartition().dynSymTab->getSymbols()) {
- // For an unfetched lazy symbol (undefined weak), it must have been
+ // For an unextracted lazy symbol (undefined weak), it must have been
// converted to Undefined and have VER_NDX_GLOBAL version here.
assert(!s.sym->isLazy());
write16(buf, s.sym->versionId);
# RUN: FileCheck --input-file=%t.txt -DT=%t %s --match-full-lines --strict-whitespace
## Fetches 0 member from %tweak.a and 2 members from %t1.a
-# CHECK:members fetched archive
+# CHECK:members extracted archive
# CHECK-NEXT:1 0 [[T]]weak.a
# CHECK-NEXT:3 2 [[T]]1.a
## The second %t1.a has 0 fetched member.
# RUN: ld.lld %t.o %tweak.a %t1.a %t1.a --print-archive-stats=- -o /dev/null | \
# RUN: FileCheck --check-prefix=CHECK2 %s
-# CHECK2: members fetched archive
+# CHECK2: members extracted archive
# CHECK2-NEXT: 1 0 {{.*}}weak.a
# CHECK2-NEXT: 3 2 {{.*}}1.a
# CHECK2-NEXT: 3 0 {{.*}}1.a