1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-13 09:39:13 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-10-27 19:03:57 +09:00
parent 5944f39411
commit bc7a6d32d7
3 changed files with 30 additions and 5 deletions

View File

@ -333,13 +333,33 @@ void ObjectFile::fix_sym_addrs() {
}
}
void ObjectFile::copy_symbols() {
for (int i = 0; i < elf_syms.size(); i++) {
void ObjectFile::read_local_symbols() {
local_symbols.reserve(first_global);
for (int i = 0; i < first_global; i++) {
const ELF64LE::Sym &esym = elf_syms[i];
StringRef name = CHECK(esym.getName(symbol_strtab), this);
uint64_t off = out::strtab->add_string(name);
local_symbols.push_back(CHECK(esym.getName(symbol_strtab), this));
}
}
void ObjectFile::copy_symbols() {
for (int i = 0; i < first_global; i++) {
const ELF64LE::Sym &esym = elf_syms[i];
uint64_t off = out::strtab->add_string(local_symbols[i]);
out::symtab->add_symbol(esym, off, get_symbol_value(i));
}
for (int i = first_global; i < elf_syms.size(); i++) {
const ELF64LE::Sym &esym = elf_syms[i];
Symbol &sym = *symbols[i - first_global];
if (sym.file != this)
continue;
uint64_t off = out::strtab->add_string(sym.name);
out::symtab->add_symbol(esym, off, sym.value);
}
}
StringRef ObjectFile::get_filename() {

View File

@ -482,6 +482,9 @@ int main(int argc, char **argv) {
tbb::task_group tg_symtab;
tg_symtab.run([&]() {
MyTimer t("symtab");
for_each(files, [](ObjectFile *file) { file->read_local_symbols(); });
for (ObjectFile *file : files)
file->copy_symbols();
});

4
mold.h
View File

@ -469,6 +469,8 @@ public:
void convert_common_symbols();
void scan_relocations();
void fix_sym_addrs();
void read_local_symbols();
void copy_symbols();
StringRef get_filename();
@ -518,7 +520,7 @@ private:
ArrayRef<ELF64LE::Shdr> elf_sections;
ArrayRef<ELF64LE::Sym> elf_syms;
std::vector<StringRef> local_symnames;
std::vector<StringRef> local_symbols;
StringRef symbol_strtab;
const ELF64LE::Shdr *symtab_sec;
};