mirror of
https://github.com/rui314/mold.git
synced 2024-12-28 02:44:48 +03:00
temporary
This commit is contained in:
parent
a4882c64c4
commit
730eff5530
@ -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();
|
||||
}
|
||||
|
4
main.cc
4
main.cc
@ -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
7
mold.h
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user