mirror of
https://github.com/rui314/mold.git
synced 2024-11-11 16:58:12 +03:00
temporary
This commit is contained in:
parent
154cf15a26
commit
966dd5de4a
1
main.cc
1
main.cc
@ -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
16
mold.h
@ -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 {
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user