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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 27 12:10:28 PST 2021


Author: Fangrui Song
Date: 2021-12-27T12:10:23-08:00
New Revision: e590c9bc7331f7351528369e512b3659f7f16e70

URL: https://github.com/llvm/llvm-project/commit/e590c9bc7331f7351528369e512b3659f7f16e70
DIFF: https://github.com/llvm/llvm-project/commit/e590c9bc7331f7351528369e512b3659f7f16e70.diff

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

Ensure addresses are unchanged after finalizeAddressDependentContent.

Added: 
    

Modified: 
    lld/ELF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 986cca27fdf89..4b33563e8a79a 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -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)


        


More information about the llvm-commits mailing list