[ELF] -r: move zero OutputSection::addr code into finalizeAddressDependentContent

Ensure addresses are unchanged after finalizeAddressDependentContent.
This commit is contained in:
Fangrui Song 2021-12-27 12:10:23 -08:00
parent f261e258ec
commit e590c9bc73
1 changed files with 4 additions and 3 deletions

View File

@ -557,9 +557,6 @@ template <class ELFT> void Writer<ELFT>::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 <class ELFT> void Writer<ELFT>::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)