1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-28 19:04:27 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-10-22 20:06:45 +09:00
parent 154cf15a26
commit 966dd5de4a
3 changed files with 14 additions and 14 deletions

View File

@ -171,6 +171,7 @@ static void fill_shdrs(ArrayRef<OutputChunk *> output_chunks) {
continue;
chunk->hdr.sh_name = out::shstrtab->add_string(chunk->name);
llvm::outs() << "sh_name=" << chunk->hdr.sh_name << "\n";
chunk->hdr.sh_offset = chunk->get_offset();
chunk->hdr.sh_size = chunk->get_size();
chunk->index = i++;

16
mold.h
View File

@ -319,16 +319,26 @@ class StringTableSection : public OutputChunk {
public:
StringTableSection(StringRef name) {
this->name = name;
contents = '\0';
hdr.sh_flags = 0;
hdr.sh_type = llvm::ELF::SHT_STRTAB;
}
uint64_t add_string(StringRef s);
void copy_to(uint8_t *buf) override;
uint64_t add_string(StringRef s) {
uint64_t ret = contents.size();
contents += s.str();
contents += '\0';
return ret;
}
void copy_to(uint8_t *buf) override {
memcpy(buf + offset, &contents[0], contents.size());
}
uint64_t get_size() const override { return contents.size(); }
private:
std::string contents = "\0";
std::string contents;
};
namespace out {

View File

@ -78,14 +78,3 @@ OutputSection *OutputSection::get_instance(InputSection *isec) {
return osec;
return new OutputSection(iname, iflags, isec->hdr->sh_type);
}
uint64_t StringTableSection::add_string(StringRef s) {
uint64_t ret = contents.size();
contents += s.str();
contents += "\0";
return ret;
}
void StringTableSection::copy_to(uint8_t *buf) {
memcpy(buf + offset, &contents[0], contents.size());
}