[PATCH] D59986: [ELF] Respect NonAlloc when copying flags from the previous sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 18 02:23:14 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL358650: [ELF] Respect NonAlloc when copying flags from the previous sections (authored by MaskRay, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59986/new/

https://reviews.llvm.org/D59986

Files:
  lld/trunk/ELF/LinkerScript.cpp
  lld/trunk/ELF/ScriptParser.cpp
  lld/trunk/test/ELF/linkerscript/info-section-type.s


Index: lld/trunk/test/ELF/linkerscript/info-section-type.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/info-section-type.s
+++ lld/trunk/test/ELF/linkerscript/info-section-type.s
@@ -29,6 +29,10 @@
 # RUN: ld.lld -o %t --script %t.script %t.o
 # RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=NONALLOC
 
+# RUN: echo "SECTIONS { .bar (INFO) : { . += 1; } };" > %t.script
+# RUN: ld.lld -o %t --script %t.script %t.o
+# RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=NONALLOC
+
 # RUN: echo "SECTIONS { .bar 0x20000 (INFO) : { *(.foo) } };" > %t.script
 # RUN: ld.lld -o %t --script %t.script %t.o
 # RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=NONALLOC
Index: lld/trunk/ELF/ScriptParser.cpp
===================================================================
--- lld/trunk/ELF/ScriptParser.cpp
+++ lld/trunk/ELF/ScriptParser.cpp
@@ -752,6 +752,7 @@
   } else {
     skip(); // This is "COPY", "INFO" or "OVERLAY".
     Cmd->NonAlloc = true;
+    Cmd->Type = SHT_PROGBITS;
   }
   expect(")");
   return true;
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -887,7 +887,8 @@
     // in case it is empty.
     bool IsEmpty = getInputSections(Sec).empty();
     if (IsEmpty)
-      Sec->Flags = Flags & (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR);
+      Sec->Flags =
+          Flags & ((Sec->NonAlloc ? 0 : SHF_ALLOC) | SHF_WRITE | SHF_EXECINSTR);
 
     if (IsEmpty && isDiscardable(*Sec)) {
       Sec->Live = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59986.195697.patch
Type: text/x-patch
Size: 1650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190418/2df4af3b/attachment.bin>


More information about the llvm-commits mailing list