mirror of
https://github.com/rui314/mold.git
synced 2024-11-11 16:58:12 +03:00
Export symbols from executables
This commit is contained in:
parent
9814405864
commit
d8381f7e74
7
main.cc
7
main.cc
@ -360,6 +360,13 @@ 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->flags |= NEEDS_DYNSYM;
|
||||
});
|
||||
|
||||
// Aggregate dynamic symbols to a single vector.
|
||||
std::vector<InputFile *> files;
|
||||
append(files, out::objs);
|
||||
|
1
mold.h
1
mold.h
@ -977,6 +977,7 @@ public:
|
||||
|
||||
std::string_view soname;
|
||||
std::vector<std::string_view> version_strings;
|
||||
std::vector<Symbol *> undefs;
|
||||
|
||||
private:
|
||||
std::string_view get_soname();
|
||||
|
@ -874,15 +874,18 @@ void SharedFile::parse() {
|
||||
vers = get_data<u16>(*sec);
|
||||
|
||||
for (i64 i = first_global; i < esyms.size(); i++) {
|
||||
if (!esyms[i].is_defined())
|
||||
continue;
|
||||
if (!vers.empty() && (vers[i] >> 15) == 1)
|
||||
continue;
|
||||
|
||||
std::string_view name = symbol_strtab.data() + esyms[i].st_name;
|
||||
elf_syms.push_back(&esyms[i]);
|
||||
versyms.push_back(vers.empty() ? 1 : vers[i]);
|
||||
symbols.push_back(Symbol::intern(name));
|
||||
|
||||
if (esyms[i].is_defined()) {
|
||||
elf_syms.push_back(&esyms[i]);
|
||||
versyms.push_back(vers.empty() ? 1 : vers[i]);
|
||||
symbols.push_back(Symbol::intern(name));
|
||||
} else {
|
||||
undefs.push_back(Symbol::intern(name));
|
||||
}
|
||||
}
|
||||
|
||||
static Counter counter("dso_syms");
|
||||
|
@ -18,5 +18,6 @@ x:
|
||||
EOF
|
||||
|
||||
../mold -o $t/exe $t/a.o $t/b.so
|
||||
readelf --dyn-syms $t/exe | grep -q expfn
|
||||
|
||||
echo OK
|
||||
|
Loading…
Reference in New Issue
Block a user