[lld] e652f3f - [ELF] Simplify some ctx->outSec with sec. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 28 19:08:33 PST 2021


Author: Fangrui Song
Date: 2021-11-28T19:08:27-08:00
New Revision: e652f3f04a253d1c6bc3e16f15115ff3e8401dc0

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

LOG: [ELF] Simplify some ctx->outSec with sec. NFC

Added: 
    

Modified: 
    lld/ELF/LinkerScript.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 3ba8c35e82bd..cf4da7ab54c9 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -991,13 +991,13 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
   ctx->outSec = sec;
   if (sec->addrExpr && script->hasSectionsCommand) {
     // The alignment is ignored.
-    ctx->outSec->addr = dot;
+    sec->addr = dot;
   } else {
-    // ctx->outSec->alignment is the max of ALIGN and the maximum of input
+    // sec->alignment is the max of ALIGN and the maximum of input
     // section alignments.
     const uint64_t pos = dot;
-    dot = alignTo(dot, ctx->outSec->alignment);
-    ctx->outSec->addr = dot;
+    dot = alignTo(dot, sec->alignment);
+    sec->addr = dot;
     expandMemoryRegions(dot - pos);
   }
 
@@ -1019,7 +1019,7 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
   }
 
   // Propagate ctx->lmaOffset to the first "non-header" section.
-  if (PhdrEntry *l = ctx->outSec->ptLoad)
+  if (PhdrEntry *l = sec->ptLoad)
     if (sec == findFirstSection(l))
       l->lmaOffset = ctx->lmaOffset;
 
@@ -1041,7 +1041,7 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
 
     // Handle BYTE(), SHORT(), LONG(), or QUAD().
     if (auto *data = dyn_cast<ByteCommand>(cmd)) {
-      data->offset = dot - ctx->outSec->addr;
+      data->offset = dot - sec->addr;
       dot += data->size;
       expandOutputSection(data->size);
       continue;
@@ -1051,10 +1051,10 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
     // It calculates and assigns the offsets for each section and also
     // updates the output section size.
     for (InputSection *isec : cast<InputSectionDescription>(cmd)->sections) {
-      assert(ctx->outSec == isec->getParent());
+      assert(isec->getParent() == sec);
       const uint64_t pos = dot;
       dot = alignTo(dot, isec->alignment);
-      isec->outSecOff = dot - ctx->outSec->addr;
+      isec->outSecOff = dot - sec->addr;
       dot += isec->getSize();
 
       // Update output section size after adding each section. This is so that


        


More information about the llvm-commits mailing list