[lld] r329281 - [ELF] Don't add NOLOAD sections to segment
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 5 06:23:59 PDT 2018
Author: evgeny777
Date: Thu Apr 5 06:23:59 2018
New Revision: 329281
URL: http://llvm.org/viewvc/llvm-project?rev=329281&view=rev
Log:
[ELF] Don't add NOLOAD sections to segment
Differential revision: https://reviews.llvm.org/D45264
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/linkerscript/noload.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=329281&r1=329280&r2=329281&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Apr 5 06:23:59 2018
@@ -1706,7 +1706,7 @@ void Writer<ELFT>::addStartStopSymbols(O
}
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
Modified: lld/trunk/test/ELF/linkerscript/noload.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/noload.s?rev=329281&r1=329280&r2=329281&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/noload.s (original)
+++ lld/trunk/test/ELF/linkerscript/noload.s Thu Apr 5 06:23:59 2018
@@ -2,12 +2,13 @@
# 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 [
@@ -15,7 +16,7 @@
# 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
@@ -23,7 +24,7 @@
# 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 [
@@ -31,13 +32,29 @@
# 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
More information about the llvm-commits
mailing list