1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-11 16:58:12 +03:00
This commit is contained in:
Rui Ueyama 2021-03-08 17:58:25 +09:00
parent c5b23ea8f5
commit b31480fec8
2 changed files with 21 additions and 12 deletions

15
main.cc
View File

@ -380,13 +380,16 @@ static void scan_rels() {
// Exit if there was a relocation that refers an undefined symbol.
Error::checkpoint();
// Export symbols referenced by DSOs.
tbb::parallel_for_each(out::dsos, [&](SharedFile *file) {
for (Symbol *sym : file->undefs)
if (sym->file && !sym->file->is_dso)
sym->is_exported = true;
});
if (!config.shared) {
// Export symbols referenced by DSOs.
tbb::parallel_for_each(out::dsos, [&](SharedFile *file) {
for (Symbol *sym : file->undefs)
if (sym->file && !sym->file->is_dso)
sym->is_exported = true;
});
}
// Add imported or exported symbols to .dynsym.
tbb::parallel_for_each(out::objs, [&](ObjectFile *file) {
for (Symbol *sym : std::span(file->symbols).subspan(file->first_global))
if (sym->file == file)

View File

@ -607,13 +607,19 @@ void ObjectFile::mark_live_objects(std::function<void(ObjectFile *)> feeder) {
if (sym.traced)
SyncOut() << "trace: " << *this << ": reference to " << sym;
if (esym.st_bind != STB_WEAK && sym.file && !sym.file->is_alive.exchange(true)) {
if (!sym.file->is_dso)
feeder((ObjectFile *)sym.file);
if (sym.file) {
if (sym.file->is_dso) {
sym.file->is_alive = true;
continue;
}
if (sym.traced)
SyncOut() << "trace: " << *this << " keeps " << *sym.file
<< " for " << sym;
ObjectFile *obj = (ObjectFile *)sym.file;
if (esym.st_bind != STB_WEAK && !obj->is_alive.exchange(true)) {
feeder(obj);
if (sym.traced)
SyncOut() << "trace: " << *this << " keeps " << *obj
<< " for " << sym;
}
}
}
}