mirror of
https://github.com/rui314/mold.git
synced 2024-12-28 19:04:27 +03:00
temporary
This commit is contained in:
parent
5e97a2c22f
commit
95810dd8ba
@ -345,7 +345,7 @@ void ObjectFile::compute_symtab() {
|
||||
for (Symbol *sym : symbols) {
|
||||
if (sym->file == this) {
|
||||
strtab_size += sym->name.size() + 1;
|
||||
symtab_size++;
|
||||
symtab_size += sizeof(ELF64LE::Sym);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
30
main.cc
30
main.cc
@ -422,27 +422,25 @@ int main(int argc, char **argv) {
|
||||
for_each(files, [](ObjectFile *file) { file->scan_relocations(); });
|
||||
}
|
||||
|
||||
{
|
||||
MyTimer t("symtab_size", before_copy);
|
||||
|
||||
for_each(files, [](ObjectFile *file) { file->compute_symtab(); });
|
||||
|
||||
uint64_t symtab_size = 0;
|
||||
uint64_t strtab_size = 1;
|
||||
for (ObjectFile *file : files) {
|
||||
symtab_size += file->symtab_size;
|
||||
strtab_size += file->strtab_size;
|
||||
}
|
||||
llvm::outs() << "symtab_size=" << symtab_size * sizeof(ELF64LE::Sym) << "\n"
|
||||
<< "strtab_size=" << strtab_size << "\n";
|
||||
}
|
||||
|
||||
// Create linker-synthesized sections.
|
||||
out::ehdr = new OutputEhdr;
|
||||
out::phdr = new OutputPhdr;
|
||||
out::shdr = new OutputShdr;
|
||||
// out::interp = new InterpSection;
|
||||
out::shstrtab = new ShstrtabSection;
|
||||
out::symtab = new SymtabSection;
|
||||
out::strtab = new StrtabSection;
|
||||
|
||||
// Compute .symtab and .strtab sizes
|
||||
{
|
||||
MyTimer t("symtab_size", before_copy);
|
||||
for_each(files, [](ObjectFile *file) { file->compute_symtab(); });
|
||||
|
||||
for (ObjectFile *file : files) {
|
||||
out::symtab->size += file->symtab_size;
|
||||
out::strtab->size += file->strtab_size;
|
||||
}
|
||||
}
|
||||
|
||||
// Add ELF and program header to the output.
|
||||
std::vector<OutputChunk *> output_chunks;
|
||||
@ -464,8 +462,6 @@ int main(int argc, char **argv) {
|
||||
output_chunks.push_back(out::shdr);
|
||||
|
||||
// Add .symtab and .strtab.
|
||||
out::symtab = new SymtabSection;
|
||||
out::strtab = new StrtabSection;
|
||||
output_chunks.push_back(out::symtab);
|
||||
output_chunks.push_back(out::strtab);
|
||||
|
||||
|
34
mold.h
34
mold.h
@ -374,15 +374,10 @@ public:
|
||||
shdr.sh_addralign = 8;
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
void copy_to_lazy(uint8_t *buf) {
|
||||
memcpy(buf + shdr.sh_offset, &contents[0], contents.size());
|
||||
}
|
||||
|
||||
uint64_t get_size_lazy() const { return contents.size(); }
|
||||
uint64_t size = 0;
|
||||
|
||||
private:
|
||||
std::vector<ELF64LE::Sym> contents;
|
||||
@ -394,35 +389,12 @@ public:
|
||||
this->name = ".strtab";
|
||||
shdr.sh_flags = 0;
|
||||
shdr.sh_type = llvm::ELF::SHT_STRTAB;
|
||||
|
||||
strings.push_back("");
|
||||
offsets.push_back(0);
|
||||
}
|
||||
|
||||
uint64_t add_string(StringRef s) {
|
||||
strings.push_back(s);
|
||||
offsets.push_back(size);
|
||||
size = size + s.size() + 1;
|
||||
return offsets.back();
|
||||
}
|
||||
|
||||
void copy_to(uint8_t *buf) override {}
|
||||
uint64_t get_size() const override { return 0; }
|
||||
uint64_t get_size() const override { return size; }
|
||||
|
||||
void copy_to_lazy(uint8_t *buf) {
|
||||
buf += shdr.sh_offset;
|
||||
|
||||
tbb::parallel_for((size_t)0, strings.size(), [&](size_t i) {
|
||||
memcpy(buf + offsets[i], strings[i].data(), strings[i].size());
|
||||
});
|
||||
}
|
||||
|
||||
uint64_t get_size_lazy() const { return size; }
|
||||
|
||||
private:
|
||||
std::vector<StringRef> strings;
|
||||
std::vector<uint64_t> offsets;
|
||||
uint64_t size = 0;
|
||||
uint64_t size = 1;
|
||||
};
|
||||
|
||||
namespace out {
|
||||
|
@ -163,10 +163,3 @@ OutputSection::get_instance(StringRef name, uint64_t flags, uint32_t type) {
|
||||
return osec;
|
||||
return new OutputSection(name, flags, type);
|
||||
}
|
||||
|
||||
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;
|
||||
contents.back().st_value = value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user