@@ -330,16 +330,7 @@ template <class ELFT> void Writer<ELFT>::run() {
330330 for (OutputSection *sec : ctx.outputSections )
331331 sec->maybeCompress <ELFT>(ctx);
332332
333- if (ctx.script ->hasSectionsCommand )
334- ctx.script ->allocateHeaders (ctx.mainPart ->phdrs );
335333
336- // Remove empty PT_LOAD to avoid causing the dynamic linker to try to mmap a
337- // 0 sized region. This has to be done late since only after assignAddresses
338- // we know the size of the sections.
339- for (Partition &part : ctx.partitions )
340- removeEmptyPTLoad (ctx, part.phdrs );
341- ctx.out .programHeaders ->size =
342- sizeof (Elf_Phdr) * ctx.mainPart ->phdrs .size ();
343334
344335 if (!ctx.arg .oFormatBinary )
345336 assignFileOffsets ();
@@ -2151,6 +2142,18 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
21512142 addArmInputSectionMappingSymbols (ctx);
21522143 sortArmMappingSymbols (ctx);
21532144 }
2145+
2146+ if (ctx.script ->hasSectionsCommand )
2147+ ctx.script ->allocateHeaders (ctx.mainPart ->phdrs );
2148+
2149+ // Remove empty PT_LOAD to avoid causing the dynamic linker to try to mmap a
2150+ // 0 sized region. This has to be done late since only after assignAddresses
2151+ // we know the size of the sections.
2152+ for (Partition &part : ctx.partitions )
2153+ removeEmptyPTLoad (ctx, part.phdrs );
2154+ ctx.out .programHeaders ->size =
2155+ sizeof (Elf_Phdr) * ctx.mainPart ->phdrs .size ();
2156+ finalizeAddressDependentContent ();
21542157}
21552158
21562159// Ensure data sections are not mixed with executable sections when
0 commit comments