1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-14 07:18:42 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-10-27 17:32:53 +09:00
parent 071c3b2453
commit 9370d89f16
2 changed files with 25 additions and 0 deletions

16
mold.h
View File

@ -337,6 +337,20 @@ private:
};
class SymtabSection : public OutputChunk {
public:
void add(const ELF64LE::Sym &sym, uint64_t name, uint64_t value);
void copy_to(uint8_t *buf) override {
memcpy(buf + shdr.sh_offset, &contents[0], contents.size());
}
uint64_t get_size() const override { return contents.size(); }
private:
std::vector<ELF64LE::Sym> contents;
};
class StringTableSection : public OutputChunk {
public:
StringTableSection(StringRef name) {
@ -368,6 +382,8 @@ extern OutputEhdr *ehdr;
extern OutputShdr *shdr;
extern OutputPhdr *phdr;
extern InterpSection *interp;
extern SymtabSection *symtab;
extern StringTableSection *strtab;
extern StringTableSection *shstrtab;
}

View File

@ -6,6 +6,8 @@ OutputEhdr *out::ehdr;
OutputShdr *out::shdr;
OutputPhdr *out::phdr;
InterpSection *out::interp;
SymtabSection *out::symtab;
StringTableSection *out::strtab;
StringTableSection *out::shstrtab;
std::vector<OutputSection *> OutputSection::all_instances;
@ -168,3 +170,10 @@ OutputSection::get_instance(StringRef name, uint64_t flags, uint32_t type) {
return osec;
return new OutputSection(name, flags, type);
}
void SymtabSection::add(const ELF64LE::Sym &sym, uint64_t name, uint64_t value) {
contents.push_back(sym);
contents.back().st_shndx = get_section_idx(out::shstrtab);
contents.back().st_name = name;
contents.back().st_value = value;
}