summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Writer.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 2e31bfd7e81..444384dc8b4 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -268,22 +268,24 @@ template <class ELFT> void Writer<ELFT>::run() {
OutputSectionCommands.begin(), OutputSectionCommands.end(),
[](OutputSectionCommand *Cmd) { Cmd->maybeCompress<ELFT>(); });
- if (Config->Relocatable) {
- assignFileOffsets();
- } else {
- Script->assignAddresses(Phdrs, OutputSectionCommands);
+ Script->assignAddresses(Phdrs, OutputSectionCommands);
- // Remove empty PT_LOAD to avoid causing the dynamic linker to try to mmap a
- // 0 sized region. This has to be done late since only after assignAddresses
- // we know the size of the sections.
- removeEmptyPTLoad();
+ // Remove empty PT_LOAD to avoid causing the dynamic linker to try to mmap a
+ // 0 sized region. This has to be done late since only after assignAddresses
+ // we know the size of the sections.
+ removeEmptyPTLoad();
- if (!Config->OFormatBinary)
- assignFileOffsets();
- else
- assignFileOffsetsBinary();
+ if (!Config->OFormatBinary)
+ assignFileOffsets();
+ else
+ assignFileOffsetsBinary();
+
+ setPhdrs();
- setPhdrs();
+ if (Config->Relocatable) {
+ for (OutputSectionCommand *Cmd : OutputSectionCommands)
+ Cmd->Sec->Addr = 0;
+ } else {
fixPredefinedSymbols();
}
OpenPOWER on IntegriCloud