diff --git a/mold.h b/mold.h index eb81bdd6..5f32ebee 100644 --- a/mold.h +++ b/mold.h @@ -259,7 +259,11 @@ public: // Program header class OutputPhdr : public OutputChunk { public: - void copy_to(uint8_t *buf) override; + void copy_to(uint8_t *buf) override { + auto *p = (ELF64LE::Phdr *)(buf + offset); + for (Phdr &ent : entries) + *p++ = ent.phdr; + } uint64_t get_size() const override { return entries.size() * sizeof(ELF64LE::Phdr); diff --git a/output_chunks.cc b/output_chunks.cc index cf75ebf3..6df5b98a 100644 --- a/output_chunks.cc +++ b/output_chunks.cc @@ -33,12 +33,6 @@ void OutputEhdr::relocate(uint8_t *buf) { hdr->e_shstrndx = out::shstrtab->index; } -void OutputPhdr::copy_to(uint8_t *buf) { - auto *p = (ELF64LE::Phdr *)buf; - for (Phdr &ent : entries) - *p++ = ent.phdr; -} - static uint32_t to_phdr_flags(uint64_t sh_flags) { uint32_t ret = PF_R; if (sh_flags & SHF_WRITE)