mirror of
https://github.com/rui314/mold.git
synced 2024-12-28 02:44:48 +03:00
temporary
This commit is contained in:
parent
21955e47df
commit
1a6ecaa01d
@ -119,9 +119,8 @@ void ObjectFile::initialize_symbols() {
|
||||
for (int i = 0; i < first_global; i++) {
|
||||
const ELF64LE::Sym &esym = elf_syms[i];
|
||||
StringRef name = CHECK(esym.getName(symbol_strtab), this);
|
||||
|
||||
static ConcurrentMap<LocalSymbolName> map;
|
||||
local_symbols.push_back(map.insert(name, LocalSymbolName(name)));
|
||||
local_symbols.push_back(name);
|
||||
strtab_size += name.size() + 1;
|
||||
}
|
||||
|
||||
symbols.reserve(elf_syms.size() - first_global);
|
||||
@ -343,6 +342,11 @@ void ObjectFile::fix_sym_addrs() {
|
||||
}
|
||||
|
||||
uint64_t ObjectFile::get_strtab_size() {
|
||||
uint64_t sz = strtab_size;
|
||||
for (Symbol *sym : symbols)
|
||||
if (sym->file == this)
|
||||
sz += sym->name.size() + 1;
|
||||
return sz;
|
||||
}
|
||||
|
||||
StringRef ObjectFile::get_filename() {
|
||||
|
5
main.cc
5
main.cc
@ -422,6 +422,11 @@ int main(int argc, char **argv) {
|
||||
for_each(files, [](ObjectFile *file) { file->scan_relocations(); });
|
||||
}
|
||||
|
||||
{
|
||||
MyTimer t("strtab_size", before_copy);
|
||||
for_each(files, [](ObjectFile *file) { file->get_strtab_size(); });
|
||||
}
|
||||
|
||||
// Create linker-synthesized sections.
|
||||
out::ehdr = new OutputEhdr;
|
||||
out::phdr = new OutputPhdr;
|
||||
|
13
mold.h
13
mold.h
@ -458,14 +458,6 @@ struct StringPiece {
|
||||
std::atomic_flag flag = ATOMIC_FLAG_INIT;
|
||||
};
|
||||
|
||||
struct LocalSymbolName {
|
||||
LocalSymbolName(StringRef name) : name(name) {}
|
||||
LocalSymbolName(const LocalSymbolName &other) : name(other.name) {}
|
||||
|
||||
StringRef name;
|
||||
std::atomic_flag claimed = ATOMIC_FLAG_INIT;
|
||||
};
|
||||
|
||||
class ObjectFile {
|
||||
public:
|
||||
ObjectFile(MemoryBufferRef mb, StringRef archive_name);
|
||||
@ -527,9 +519,12 @@ private:
|
||||
|
||||
ArrayRef<ELF64LE::Shdr> elf_sections;
|
||||
ArrayRef<ELF64LE::Sym> elf_syms;
|
||||
std::vector<LocalSymbolName *> local_symbols;
|
||||
StringRef symbol_strtab;
|
||||
const ELF64LE::Shdr *symtab_sec;
|
||||
|
||||
// For .strtab construction
|
||||
std::vector<StringRef> local_symbols;
|
||||
uint64_t strtab_size;
|
||||
};
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user