diff --git a/mold.h b/mold.h index ca421128..9e761ce1 100644 --- a/mold.h +++ b/mold.h @@ -303,6 +303,7 @@ public: : name(name) { hdr.sh_flags = flags; hdr.sh_type = type; + all_instances.push_back(this); } void copy_to(uint8_t *buf) override { diff --git a/output_chunks.cc b/output_chunks.cc index 54b445f2..9b4b4f52 100644 --- a/output_chunks.cc +++ b/output_chunks.cc @@ -74,8 +74,5 @@ OutputSection *OutputSection::get_instance(InputSection *isec) { std::unique_lock unique_lock(mu); if (OutputSection *osec = find()) return osec; - - OutputSection *osec = new OutputSection(iname, iflags, isec->hdr->sh_type); - OutputSection::all_instances.push_back(osec); - return osec; + return new OutputSection(iname, iflags, isec->hdr->sh_type); }