diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 986cca27fdf8..4b33563e8a79 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -557,9 +557,6 @@ template void Writer::run() { for (Partition &part : partitions) setPhdrs(part); - if (config->relocatable) - for (OutputSection *sec : outputSections) - sec->addr = 0; // Handle --print-map(-M)/--Map, --why-extract=, --cref and // --print-archive-stats=. Dump them before checkSections() because the files @@ -1699,6 +1696,10 @@ template void Writer::finalizeAddressDependentContent() { } } + if (config->relocatable) + for (OutputSection *sec : outputSections) + sec->addr = 0; + // If addrExpr is set, the address may not be a multiple of the alignment. // Warn because this is error-prone. for (SectionCommand *cmd : script->sectionCommands)