diff --git a/elf/passes.cc b/elf/passes.cc index a43c663f..c241dc3d 100644 --- a/elf/passes.cc +++ b/elf/passes.cc @@ -32,49 +32,50 @@ void apply_exclude_libs(Context &ctx) { template void create_synthetic_sections(Context &ctx) { - auto add = [&](auto &chunk) { - ctx.chunks.push_back(chunk.get()); + auto push = [&](T *x) { + ctx.chunks.push_back(x); + return std::unique_ptr(x); }; - add(ctx.ehdr = std::make_unique>()); - add(ctx.phdr = std::make_unique>()); - add(ctx.shdr = std::make_unique>()); - add(ctx.got = std::make_unique>()); - add(ctx.gotplt = std::make_unique>()); - add(ctx.reldyn = std::make_unique>()); - add(ctx.relplt = std::make_unique>()); + ctx.ehdr = push(new OutputEhdr); + ctx.phdr = push(new OutputPhdr); + ctx.shdr = push(new OutputShdr); + ctx.got = push(new GotSection); + ctx.gotplt = push(new GotPltSection); + ctx.reldyn = push(new RelDynSection); + ctx.relplt = push(new RelPltSection); if (ctx.arg.pack_dyn_relocs_relr) - add(ctx.relrdyn = std::make_unique>()); + ctx.relrdyn = push(new RelrDynSection); - add(ctx.strtab = std::make_unique>()); - add(ctx.shstrtab = std::make_unique>()); - add(ctx.plt = std::make_unique>()); - add(ctx.pltgot = std::make_unique>()); - add(ctx.symtab = std::make_unique>()); - add(ctx.dynsym = std::make_unique>()); - add(ctx.dynstr = std::make_unique>()); - add(ctx.eh_frame = std::make_unique>()); - add(ctx.copyrel = std::make_unique>(false)); - add(ctx.copyrel_relro = std::make_unique>(true)); + ctx.strtab = push(new StrtabSection); + ctx.shstrtab = push(new ShstrtabSection); + ctx.plt = push(new PltSection); + ctx.pltgot = push(new PltGotSection); + ctx.symtab = push(new SymtabSection); + ctx.dynsym = push(new DynsymSection); + ctx.dynstr = push(new DynstrSection); + ctx.eh_frame = push(new EhFrameSection); + ctx.copyrel = push(new CopyrelSection(false)); + ctx.copyrel_relro = push(new CopyrelSection(true)); if (!ctx.arg.dynamic_linker.empty()) - add(ctx.interp = std::make_unique>()); + ctx.interp = push(new InterpSection); if (ctx.arg.build_id.kind != BuildId::NONE) - add(ctx.buildid = std::make_unique>()); + ctx.buildid = push(new BuildIdSection); if (ctx.arg.eh_frame_hdr) - add(ctx.eh_frame_hdr = std::make_unique>()); + ctx.eh_frame_hdr = push(new EhFrameHdrSection); if (ctx.arg.hash_style_sysv) - add(ctx.hash = std::make_unique>()); + ctx.hash = push(new HashSection); if (ctx.arg.hash_style_gnu) - add(ctx.gnu_hash = std::make_unique>()); + ctx.gnu_hash = push(new GnuHashSection); if (!ctx.arg.version_definitions.empty()) - add(ctx.verdef = std::make_unique>()); + ctx.verdef = push(new VerdefSection); - add(ctx.dynamic = std::make_unique>()); - add(ctx.versym = std::make_unique>()); - add(ctx.verneed = std::make_unique>()); - add(ctx.note_property = std::make_unique>()); + ctx.dynamic = push(new DynamicSection); + ctx.versym = push(new VersymSection); + ctx.verneed = push(new VerneedSection); + ctx.note_property = push(new NotePropertySection); } template