1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-27 10:23:41 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-10-25 15:42:13 +09:00
parent b083d1d955
commit f6c24ad62a
2 changed files with 20 additions and 4 deletions

3
mold.h
View File

@ -201,7 +201,7 @@ public:
const ELF64LE::Shdr &shdr;
StringRef name;
uint64_t addr;
uint64_t vaddr;
uint64_t fileoff;
};
@ -318,6 +318,7 @@ public:
}
void set_fileoff(uint64_t off) override;
void set_vaddr(uint64_t va) override;
void set_alignment(uint32_t align) { shdr.sh_addralign = align; }

View File

@ -108,10 +108,25 @@ void OutputPhdr::copy_to(uint8_t *buf) {
}
void OutputSection::set_fileoff(uint64_t off) {
if (shdr.sh_type & SHT_NOBITS) {
shdr.sh_offset = off;
for (InputSection *isec : chunks)
isec->fileoff = off;
return;
}
shdr.sh_offset = off;
for (int i = 0; i < chunks.size(); i++) {
chunks[i]->fileoff = off;
off += chunks[i]->shdr.sh_size;
for (InputSection *isec : chunks) {
isec->fileoff = off;
off += isec->shdr.sh_size;
}
}
void OutputSection::set_vaddr(uint64_t va) {
shdr.sh_addr = va;
for (InputSection *isec : chunks) {
isec->vaddr = va;
va += isec->shdr.sh_size;
}
}