1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-28 02:44:48 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-10-25 12:30:30 +09:00
parent 7a27eb0caa
commit f5df59480c
3 changed files with 14 additions and 5 deletions

View File

@ -275,6 +275,7 @@ int main(int argc, char **argv) {
out::ehdr = new OutputEhdr;
out::phdr = new OutputPhdr;
out::shdr = new OutputShdr;
out::interp = new InterpSection;
out::shstrtab = new StringTableSection(".shstrtab");
// Add ELF and program header to the output.
@ -283,7 +284,7 @@ int main(int argc, char **argv) {
output_chunks.push_back(out::phdr);
// Add .interp section.
output_chunks.push_back(new InterpSection);
output_chunks.push_back(out::interp);
// Add other output sections.
for (OutputSection *osec : get_output_sections())

3
mold.h
View File

@ -274,7 +274,7 @@ public:
private:
struct Phdr {
ELF64LE::Phdr phdr;
std::vector<InputSection *> members;
std::vector<OutputChunk *> members;
};
std::vector<Phdr> entries;
@ -360,6 +360,7 @@ namespace out {
extern OutputEhdr *ehdr;
extern OutputShdr *shdr;
extern OutputPhdr *phdr;
extern InterpSection *interp;
extern StringTableSection *shstrtab;
}

View File

@ -5,6 +5,7 @@ using namespace llvm::ELF;
OutputEhdr *out::ehdr;
OutputShdr *out::shdr;
OutputPhdr *out::phdr;
InterpSection *out::interp;
StringTableSection *out::shstrtab;
std::vector<OutputSection *> OutputSection::all_instances;
@ -43,10 +44,16 @@ static uint32_t to_phdr_flags(uint64_t sh_flags) {
}
void OutputPhdr::construct(std::vector<OutputChunk *> &chunks) {
entries.resize(1);
auto add = [&](uint32_t type, uint32_t flags, std::vector<OutputChunk *> members) {
ELF64LE::Phdr phdr = {};
phdr.p_type = type;
phdr.p_flags = flags;
entries.push_back({phdr, members});
};
Phdr &first = entries.back();
first.phdr.p_flags = PF_R;
add(PT_PHDR, PF_R, {out::phdr});
if (out::interp)
add(PT_INTERP, PF_R, {out::interp});
}
void OutputSection::set_offset(uint64_t off) {