diff --git a/main.cc b/main.cc index 1e8fb07e..99e166c4 100644 --- a/main.cc +++ b/main.cc @@ -811,8 +811,7 @@ int main(int argc, char **argv) { out::phdr = new OutputPhdr; out::got = new SpecialSection(".got", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE, 8); out::gotplt = new GotPltSection; - out::relplt = new SpecialSection(".rela.plt", SHT_RELA, SHF_ALLOC, - 8, sizeof(ELF64LE::Rela)); + out::relplt = new RelPltSection; out::strtab = new StrtabSection(".strtab", 0); out::shstrtab = new ShstrtabSection; out::plt = new PltSection; @@ -955,8 +954,6 @@ int main(int argc, char **argv) { out::files = files; out::chunks = chunks; - out::relplt->shdr.sh_link = out::dynsym->shndx; - for (OutputChunk *chunk : chunks) chunk->update_shdr(); diff --git a/mold.h b/mold.h index 1240fcac..ee2ba422 100644 --- a/mold.h +++ b/mold.h @@ -437,6 +437,8 @@ public: shdr.sh_entsize = sizeof(ELF64LE::Rela); shdr.sh_addralign = 8; } + + void update_shdr() override; }; class RelDynSection : public OutputChunk { @@ -600,7 +602,7 @@ inline OutputPhdr *phdr; inline InterpSection *interp; inline SpecialSection *got; inline GotPltSection *gotplt; -inline SpecialSection *relplt; +inline RelPltSection *relplt; inline RelDynSection *reldyn; inline DynamicSection *dynamic; inline StrtabSection *strtab; diff --git a/output_chunks.cc b/output_chunks.cc index ca40e9a9..baaef469 100644 --- a/output_chunks.cc +++ b/output_chunks.cc @@ -179,6 +179,10 @@ static std::vector create_dynamic_section() { return vec; } +void RelPltSection::update_shdr() { + shdr.sh_link = out::dynsym->shndx; +} + void RelDynSection::update_shdr() { shdr.sh_link = out::dynsym->shndx; }