[PATCH] D45264: [ELF] Don't put NOLOAD section into PT_LOAD

Eugene Leviant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 5 06:27:11 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL329281: [ELF] Don't add NOLOAD sections to segment (authored by evgeny777, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45264?vs=140976&id=141147#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45264

Files:
  lld/trunk/ELF/Writer.cpp
  lld/trunk/test/ELF/linkerscript/noload.s


Index: lld/trunk/test/ELF/linkerscript/noload.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/noload.s
+++ lld/trunk/test/ELF/linkerscript/noload.s
@@ -2,42 +2,59 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
 # RUN: echo "SECTIONS { \
 # RUN:        .data_noload_a (NOLOAD) : { *(.data_noload_a) } \
-# RUN:        .data_noload_b (0x10000) (NOLOAD) : { *(.data_noload_b) } };" > %t.script
+# RUN:        .data_noload_b (0x10000) (NOLOAD) : { *(.data_noload_b) } \
+# RUN:        .text (0x20000) : { *(.text) } };" > %t.script
 # RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-readobj --symbols -sections %t | FileCheck %s
+# RUN: llvm-readobj -sections -program-headers  %t | FileCheck %s
 
 # CHECK:      Section {
-# CHECK:        Index: 2
+# CHECK:        Index: 1
 # CHECK-NEXT:   Name: .data_noload_a
 # CHECK-NEXT:   Type: SHT_NOBITS
 # CHECK-NEXT:   Flags [
 # CHECK-NEXT:     SHF_ALLOC
 # CHECK-NEXT:     SHF_WRITE
 # CHECK-NEXT:   ]
 # CHECK-NEXT:   Address: 0x0
-# CHECK-NEXT:   Offset: 0x1000
+# CHECK-NEXT:   Offset: 0xE8
 # CHECK-NEXT:   Size: 4096
 # CHECK-NEXT:   Link: 0
 # CHECK-NEXT:   Info: 0
 # CHECK-NEXT:   AddressAlignment: 1
 # CHECK-NEXT:   EntrySize: 0
 # CHECK-NEXT: }
 # CHECK-NEXT: Section {
-# CHECK-NEXT:   Index: 3
+# CHECK-NEXT:   Index: 2
 # CHECK-NEXT:   Name: .data_noload_b
 # CHECK-NEXT:   Type: SHT_NOBITS
 # CHECK-NEXT:   Flags [
 # CHECK-NEXT:     SHF_ALLOC
 # CHECK-NEXT:     SHF_WRITE
 # CHECK-NEXT:   ]
 # CHECK-NEXT:   Address: 0x10000
-# CHECK-NEXT:   Offset: 0x1000
+# CHECK-NEXT:   Offset: 0xE8
 # CHECK-NEXT:   Size: 4096
 # CHECK-NEXT:   Link: 0
 # CHECK-NEXT:   Info: 0
 # CHECK-NEXT:   AddressAlignment: 1
 # CHECK-NEXT:   EntrySize: 0
 # CHECK-NEXT: }
+# CHECK:      ProgramHeader {
+# CHECK-NEXT:   Type: PT_LOAD (0x1)
+# CHECK-NEXT:   Offset: 0x1000
+# CHECK-NEXT:   VirtualAddress: 0x20000
+# CHECK-NEXT:   PhysicalAddress: 0x20000
+# CHECK-NEXT:   FileSize: 1
+# CHECK-NEXT:   MemSize: 1
+# CHECK-NEXT:   Flags [ (0x5)
+# CHECK-NEXT:     PF_R (0x4)
+# CHECK-NEXT:     PF_X (0x1)
+# CHECK-NEXT:   ]
+# CHECK-NEXT:   Alignment: 4096
+# CHECK-NEXT: }
+
+.section .text,"ax", at progbits
+  nop
 
 .section .data_noload_a,"aw", at progbits
 .zero 4096
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1706,7 +1706,7 @@
 }
 
 static bool needsPtLoad(OutputSection *Sec) {
-  if (!(Sec->Flags & SHF_ALLOC))
+  if (!(Sec->Flags & SHF_ALLOC) || Sec->Noload)
     return false;
 
   // Don't allocate VA space for TLS NOBITS sections. The PT_TLS PHDR is


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45264.141147.patch
Type: text/x-patch
Size: 2703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180405/bc85b4ee/attachment.bin>


More information about the llvm-commits mailing list