1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-28 02:44:48 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-10-27 18:07:15 +09:00
parent a4882c64c4
commit 730eff5530
4 changed files with 18 additions and 4 deletions

View File

@ -333,6 +333,15 @@ void ObjectFile::fix_sym_addrs() {
}
}
void ObjectFile::copy_symbols() {
for (int i = 0; i < elf_syms.size(); i++) {
const ELF64LE::Sym &esym = elf_syms[i];
StringRef name = CHECK(esym.getName(symbol_strtab), this);
uint64_t off = out::strtab->add_string(name);
out::symtab->add_symbol(esym, off, get_symbol_value(i));
}
}
StringRef ObjectFile::get_filename() {
return mb.getBufferIdentifier();
}

View File

@ -470,8 +470,8 @@ int main(int argc, char **argv) {
tbb::task_group tg_symtab;
tg_symtab.run([&]() {
MyTimer t("symtab", before_copy);
for (OutputSection *osec : output_sections) {
}
for (ObjectFile *file : files)
file->copy_symbols();
});
// Assign offsets to input sections

7
mold.h
View File

@ -348,7 +348,7 @@ public:
shdr.sh_addralign = 8;
}
void add(const ELF64LE::Sym &sym, uint64_t name, uint64_t value);
void add_symbol(const ELF64LE::Sym &sym, uint64_t name, uint64_t value);
void copy_to(uint8_t *buf) override {}
uint64_t get_size() const override { return 0; }
@ -461,6 +461,7 @@ public:
void convert_common_symbols();
void scan_relocations();
void fix_sym_addrs();
void copy_symbols();
StringRef get_filename();
bool is_in_archive();
@ -474,6 +475,10 @@ public:
uint64_t get_symbol_value(uint32_t idx) const {
if (idx < first_global) {
const ELF64LE::Sym &sym = elf_syms[idx];
if (sym.st_shndx == llvm::ELF::SHN_ABS)
return sym.st_value;
InputSection *isec = sections[sym.st_shndx];
if (isec)
return isec->output_section->shdr.sh_addr + isec->offset + sym.st_value;

View File

@ -164,7 +164,7 @@ OutputSection::get_instance(StringRef name, uint64_t flags, uint32_t type) {
return new OutputSection(name, flags, type);
}
void SymtabSection::add(const ELF64LE::Sym &sym, uint64_t name, uint64_t value) {
void SymtabSection::add_symbol(const ELF64LE::Sym &sym, uint64_t name, uint64_t value) {
contents.push_back(sym);
contents.back().st_shndx = out::shstrtab->idx;
contents.back().st_name = name;