[lld] r253145 - [ELF2] - Implemented PT_GNU_STACK support, -z execstack option.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 14 12:56:09 PST 2015
Author: grimar
Date: Sat Nov 14 14:56:08 2015
New Revision: 253145
URL: http://llvm.org/viewvc/llvm-project?rev=253145&view=rev
Log:
[ELF2] - Implemented PT_GNU_STACK support, -z execstack option.
PT_GNU_STACK is a entry in the elf file format which contains the access rights (read, write, execute) of the stack,
it is always generated now. By default stack is not executable in this implementation.
-z execstack can be used to make executable.
Differential revision: http://reviews.llvm.org/D14571
Added:
lld/trunk/test/elf2/gnustack.s
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/Writer.cpp
lld/trunk/test/elf2/basic-aarch64.s
lld/trunk/test/elf2/basic-mips.s
lld/trunk/test/elf2/basic.s
lld/trunk/test/elf2/basic32.s
lld/trunk/test/elf2/basic64be.s
lld/trunk/test/elf2/eh-frame-merge.s
lld/trunk/test/elf2/gnu-hash-table.s
lld/trunk/test/elf2/merge-shared.s
lld/trunk/test/elf2/merge-string.s
lld/trunk/test/elf2/merge-sym.s
lld/trunk/test/elf2/merge.s
lld/trunk/test/elf2/program-header-layout.s
lld/trunk/test/elf2/relative-dynamic-reloc-ppc64.s
lld/trunk/test/elf2/relative-dynamic-reloc.s
lld/trunk/test/elf2/relocation-local.s
lld/trunk/test/elf2/relocation.s
lld/trunk/test/elf2/shared.s
lld/trunk/test/elf2/string-table.s
lld/trunk/test/elf2/symbols.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Sat Nov 14 14:56:08 2015
@@ -63,6 +63,7 @@ struct Configuration {
bool StripAll;
bool SysvHash = true;
bool Verbose;
+ bool ZExecStack;
bool ZNodelete = false;
bool ZNow = false;
bool ZOrigin = false;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sat Nov 14 14:56:08 2015
@@ -171,6 +171,7 @@ void LinkerDriver::createFiles(opt::Inpu
Config->SoName = getString(Args, OPT_soname);
Config->Sysroot = getString(Args, OPT_sysroot);
+ Config->ZExecStack = hasZOption(Args, "execstack");
Config->ZNodelete = hasZOption(Args, "nodelete");
Config->ZNow = hasZOption(Args, "now");
Config->ZOrigin = hasZOption(Args, "origin");
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Sat Nov 14 14:56:08 2015
@@ -219,7 +219,9 @@ void elf2::ObjectFile<ELFT>::initializeS
default: {
ErrorOr<StringRef> NameOrErr = this->ELFObj.getSectionName(&Sec);
error(NameOrErr);
- if (*NameOrErr == ".eh_frame")
+ if (*NameOrErr == ".note.GNU-stack")
+ Sections[I] = &InputSection<ELFT>::Discarded;
+ else if (*NameOrErr == ".eh_frame")
Sections[I] = new (this->Alloc) EHInputSection<ELFT>(this, &Sec);
else if (shouldMerge<ELFT>(Sec))
Sections[I] = new (this->Alloc) MergeInputSection<ELFT>(this, &Sec);
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Nov 14 14:56:08 2015
@@ -864,6 +864,11 @@ template <class ELFT> void Writer<ELFT>:
copyPhdr(PH, Out<ELFT>::Dynamic);
}
+ Elf_Phdr *PH = &Phdrs[++PhdrIdx];
+ PH->p_type = PT_GNU_STACK;
+ PH->p_flags = Config->ZExecStack ? toPhdrFlags(SHF_WRITE | SHF_EXECINSTR)
+ : toPhdrFlags(SHF_WRITE);
+
// Fix up PT_INTERP as we now know the address of .interp section.
if (Interp) {
Interp->p_type = PT_INTERP;
@@ -882,7 +887,7 @@ template <class ELFT> void Writer<ELFT>:
// Returns the number of PHDR entries.
template <class ELFT> int Writer<ELFT>::getPhdrsNum() const {
bool Tls = false;
- int I = 2; // 2 for PT_PHDR and the first PT_LOAD
+ int I = 3; // 3 for PT_PHDR, first PT_LOAD and PT_GNU_STACK
if (needsInterpSection())
++I;
if (isOutputDynamic())
Modified: lld/trunk/test/elf2/basic-aarch64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic-aarch64.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic-aarch64.s (original)
+++ lld/trunk/test/elf2/basic-aarch64.s Sat Nov 14 14:56:08 2015
@@ -31,7 +31,7 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 64
# CHECK-NEXT: ProgramHeaderEntrySize: 56
-# CHECK-NEXT: ProgramHeaderCount: 3
+# CHECK-NEXT: ProgramHeaderCount: 4
# CHECK-NEXT: SectionHeaderEntrySize: 64
# CHECK-NEXT: SectionHeaderCount: 5
# CHECK-NEXT: StringTableSectionIndex: 3
@@ -145,8 +145,8 @@ _start:
# CHECK-NEXT: Offset: 0x40
# CHECK-NEXT: VirtualAddress: 0x10040
# CHECK-NEXT: PhysicalAddress: 0x10040
-# CHECK-NEXT: FileSize: 168
-# CHECK-NEXT: MemSize: 168
+# CHECK-NEXT: FileSize: 224
+# CHECK-NEXT: MemSize: 224
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -157,8 +157,8 @@ _start:
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x10000
# CHECK-NEXT: PhysicalAddress: 0x10000
-# CHECK-NEXT: FileSize: 232
-# CHECK-NEXT: MemSize: 232
+# CHECK-NEXT: FileSize: 288
+# CHECK-NEXT: MemSize: 288
# CHECK-NEXT: Flags [
# CHECK-NEXT: PF_R
# CHECK-NEXT: ]
@@ -177,4 +177,17 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 4096
# CHECK-NEXT: }
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_GNU_STACK
+# CHECK-NEXT: Offset: 0x0
+# CHECK-NEXT: VirtualAddress: 0x0
+# CHECK-NEXT: PhysicalAddress: 0x0
+# CHECK-NEXT: FileSize: 0
+# CHECK-NEXT: MemSize: 0
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_W
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: }
# CHECK-NEXT: ]
Modified: lld/trunk/test/elf2/basic-mips.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic-mips.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic-mips.s (original)
+++ lld/trunk/test/elf2/basic-mips.s Sat Nov 14 14:56:08 2015
@@ -32,7 +32,7 @@ __start:
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 52
# CHECK-NEXT: ProgramHeaderEntrySize: 32
-# CHECK-NEXT: ProgramHeaderCount: 4
+# CHECK-NEXT: ProgramHeaderCount: 5
# CHECK-NEXT: SectionHeaderEntrySize: 40
# CHECK-NEXT: SectionHeaderCount: 9
# CHECK-NEXT: StringTableSectionIndex: 7
@@ -59,8 +59,8 @@ __start:
# CHECK-NEXT: Flags [ (0x2)
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x100B4
-# CHECK-NEXT: Offset: 0xB4
+# CHECK-NEXT: Address: 0x100D4
+# CHECK-NEXT: Offset: 0xD4
# CHECK-NEXT: Size: 24
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@@ -74,8 +74,8 @@ __start:
# CHECK-NEXT: Flags [ (0x2)
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x100D0
-# CHECK-NEXT: Offset: 0xD0
+# CHECK-NEXT: Address: 0x100F0
+# CHECK-NEXT: Offset: 0xF0
# CHECK-NEXT: Size: 24
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@@ -208,8 +208,8 @@ __start:
# CHECK-NEXT: Offset: 0x34
# CHECK-NEXT: VirtualAddress: 0x10034
# CHECK-NEXT: PhysicalAddress: 0x10034
-# CHECK-NEXT: FileSize: 128
-# CHECK-NEXT: MemSize: 128
+# CHECK-NEXT: FileSize: 160
+# CHECK-NEXT: MemSize: 160
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -220,8 +220,8 @@ __start:
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x10000
# CHECK-NEXT: PhysicalAddress: 0x10000
-# CHECK-NEXT: FileSize: 232
-# CHECK-NEXT: MemSize: 232
+# CHECK-NEXT: FileSize: 264
+# CHECK-NEXT: MemSize: 264
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -253,4 +253,17 @@ __start:
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 65536
# CHECK-NEXT: }
-# CHECK-NEXT: ]
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_GNU_STACK
+# CHECK-NEXT: Offset: 0x0
+# CHECK-NEXT: VirtualAddress: 0x0
+# CHECK-NEXT: PhysicalAddress: 0x0
+# CHECK-NEXT: FileSize: 0
+# CHECK-NEXT: MemSize: 0
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_W
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: }
+# CHECK-NEXT:]
Modified: lld/trunk/test/elf2/basic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic.s (original)
+++ lld/trunk/test/elf2/basic.s Sat Nov 14 14:56:08 2015
@@ -32,7 +32,7 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 64
# CHECK-NEXT: ProgramHeaderEntrySize: 56
-# CHECK-NEXT: ProgramHeaderCount: 3
+# CHECK-NEXT: ProgramHeaderCount: 4
# CHECK-NEXT: SectionHeaderEntrySize: 64
# CHECK-NEXT: SectionHeaderCount: 5
# CHECK-NEXT: StringTableSectionIndex: 3
@@ -137,8 +137,8 @@ _start:
# CHECK-NEXT: Offset: 0x40
# CHECK-NEXT: VirtualAddress: 0x10040
# CHECK-NEXT: PhysicalAddress: 0x10040
-# CHECK-NEXT: FileSize: 168
-# CHECK-NEXT: MemSize: 168
+# CHECK-NEXT: FileSize: 224
+# CHECK-NEXT: MemSize: 224
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -149,8 +149,8 @@ _start:
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x10000
# CHECK-NEXT: PhysicalAddress: 0x10000
-# CHECK-NEXT: FileSize: 232
-# CHECK-NEXT: MemSize: 232
+# CHECK-NEXT: FileSize: 288
+# CHECK-NEXT: MemSize: 288
# CHECK-NEXT: Flags [
# CHECK-NEXT: PF_R
# CHECK-NEXT: ]
@@ -169,6 +169,19 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 4096
# CHECK-NEXT: }
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_GNU_STACK
+# CHECK-NEXT: Offset: 0x0
+# CHECK-NEXT: VirtualAddress: 0x0
+# CHECK-NEXT: PhysicalAddress: 0x0
+# CHECK-NEXT: FileSize: 0
+# CHECK-NEXT: MemSize: 0
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_W
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: }
# CHECK-NEXT: ]
# Test for the response file
Modified: lld/trunk/test/elf2/basic32.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic32.s (original)
+++ lld/trunk/test/elf2/basic32.s Sat Nov 14 14:56:08 2015
@@ -30,7 +30,7 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 52
# CHECK-NEXT: ProgramHeaderEntrySize: 32
-# CHECK-NEXT: ProgramHeaderCount: 3
+# CHECK-NEXT: ProgramHeaderCount: 4
# CHECK-NEXT: SectionHeaderEntrySize: 40
# CHECK-NEXT: SectionHeaderCount: 5
# CHECK-NEXT: StringTableSectionIndex: 3
@@ -115,8 +115,8 @@ _start:
# CHECK-NEXT: Offset: 0x34
# CHECK-NEXT: VirtualAddress: 0x10034
# CHECK-NEXT: PhysicalAddress: 0x10034
-# CHECK-NEXT: FileSize: 96
-# CHECK-NEXT: MemSize: 96
+# CHECK-NEXT: FileSize: 128
+# CHECK-NEXT: MemSize: 128
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -127,8 +127,8 @@ _start:
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x10000
# CHECK-NEXT: PhysicalAddress: 0x10000
-# CHECK-NEXT: FileSize: 148
-# CHECK-NEXT: MemSize: 148
+# CHECK-NEXT: FileSize: 180
+# CHECK-NEXT: MemSize: 180
# CHECK-NEXT: Flags [
# CHECK-NEXT: PF_R
# CHECK-NEXT: ]
@@ -147,4 +147,17 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 4096
# CHECK-NEXT: }
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_GNU_STACK
+# CHECK-NEXT: Offset: 0x0
+# CHECK-NEXT: VirtualAddress: 0x0
+# CHECK-NEXT: PhysicalAddress: 0x0
+# CHECK-NEXT: FileSize: 0
+# CHECK-NEXT: MemSize: 0
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_W
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: }
# CHECK-NEXT: ]
Modified: lld/trunk/test/elf2/basic64be.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic64be.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic64be.s (original)
+++ lld/trunk/test/elf2/basic64be.s Sat Nov 14 14:56:08 2015
@@ -43,7 +43,7 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 64
# CHECK-NEXT: ProgramHeaderEntrySize: 56
-# CHECK-NEXT: ProgramHeaderCount: 4
+# CHECK-NEXT: ProgramHeaderCount: 5
# CHECK-NEXT: SectionHeaderEntrySize: 64
# CHECK-NEXT: SectionHeaderCount: 8
# CHECK-NEXT: StringTableSectionIndex: 6
@@ -199,8 +199,8 @@ _start:
# CHECK-NEXT: Offset: 0x40
# CHECK-NEXT: VirtualAddress: 0x10000040
# CHECK-NEXT: PhysicalAddress: 0x10000040
-# CHECK-NEXT: FileSize: 224
-# CHECK-NEXT: MemSize: 224
+# CHECK-NEXT: FileSize: 280
+# CHECK-NEXT: MemSize: 280
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -211,8 +211,8 @@ _start:
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x10000000
# CHECK-NEXT: PhysicalAddress: 0x10000000
-# CHECK-NEXT: FileSize: 288
-# CHECK-NEXT: MemSize: 288
+# CHECK-NEXT: FileSize: 344
+# CHECK-NEXT: MemSize: 344
# CHECK-NEXT: Flags [
# CHECK-NEXT: PF_R
# CHECK-NEXT: ]
@@ -220,7 +220,7 @@ _start:
# CHECK-NEXT: }
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
-# CHECK-NEXT: Offset: 0x1000
+# CHECK-NEXT: Offset: 0x10000
# CHECK-NEXT: VirtualAddress: 0x10010000
# CHECK-NEXT: PhysicalAddress: 0x10010000
# CHECK-NEXT: FileSize: 12
@@ -233,7 +233,7 @@ _start:
# CHECK-NEXT: }
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
-# CHECK-NEXT: Offset: 0x2000
+# CHECK-NEXT: Offset: 0x20000
# CHECK-NEXT: VirtualAddress: 0x10020000
# CHECK-NEXT: PhysicalAddress: 0x10020000
# CHECK-NEXT: FileSize: 88
@@ -244,4 +244,17 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 65536
# CHECK-NEXT: }
-# CHECK-NEXT:]
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_GNU_STACK (0x6474E551)
+# CHECK-NEXT: Offset: 0x0
+# CHECK-NEXT: VirtualAddress: 0x0
+# CHECK-NEXT: PhysicalAddress: 0x0
+# CHECK-NEXT: FileSize: 0
+# CHECK-NEXT: MemSize: 0
+# CHECK-NEXT: Flags [ (0x6)
+# CHECK-NEXT: PF_R (0x4)
+# CHECK-NEXT: PF_W (0x2)
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
\ No newline at end of file
Modified: lld/trunk/test/elf2/eh-frame-merge.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/eh-frame-merge.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/eh-frame-merge.s (original)
+++ lld/trunk/test/elf2/eh-frame-merge.s Sat Nov 14 14:56:08 2015
@@ -35,9 +35,9 @@
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 14000000 00000000 017A5200 01781001 |
// CHECK-NEXT: 0010: 1B0C0708 90010000 10000000 1C000000 |
-// CHECK-NEXT: 0020: 880E0000 01000000 00000000 10000000 |
-// CHECK-NEXT: 0030: 30000000 760E0000 02000000 00000000 |
-// CHECK-NEXT: 0040: 10000000 44000000 610E0000 01000000 |
+// CHECK-NEXT: 0020: 500E0000 01000000 00000000 10000000 |
+// CHECK-NEXT: 0030: 30000000 3E0E0000 02000000 00000000 |
+// CHECK-NEXT: 0040: 10000000 44000000 290E0000 01000000 |
// CHECK-NEXT: 0050: 00000000 |
// CHECK-NEXT: )
Modified: lld/trunk/test/elf2/gnu-hash-table.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/gnu-hash-table.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/gnu-hash-table.s (original)
+++ lld/trunk/test/elf2/gnu-hash-table.s Sat Nov 14 14:56:08 2015
@@ -149,8 +149,8 @@
# PPC64-NEXT: Flags [
# PPC64-NEXT: SHF_ALLOC
# PPC64-NEXT: ]
-# PPC64-NEXT: Address: 0x1B8
-# PPC64-NEXT: Offset: 0x1B8
+# PPC64-NEXT: Address: 0x1F0
+# PPC64-NEXT: Offset: 0x1F0
# PPC64-NEXT: Size: 36
# PPC64-NEXT: Link: 1
# PPC64-NEXT: Info: 0
Added: lld/trunk/test/elf2/gnustack.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/gnustack.s?rev=253145&view=auto
==============================================================================
--- lld/trunk/test/elf2/gnustack.s (added)
+++ lld/trunk/test/elf2/gnustack.s Sat Nov 14 14:56:08 2015
@@ -0,0 +1,46 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
+# RUN: ld.lld2 %t1 -z execstack -o %t
+# RUN: llvm-readobj --program-headers -s %t | FileCheck --check-prefix=CHECK_RWX %s
+# RUN: ld.lld2 %t1 -o %t
+# RUN: llvm-readobj --program-headers -s %t | FileCheck --check-prefix=CHECK_RW %s
+
+# CHECK_RW: Sections [
+# CHECK_RW-NOT: Name: .note.GNU-stack
+# CHECK_RW: ProgramHeaders [
+# CHECK_RW: ProgramHeader {
+# CHECK_RW: Type: PT_GNU_STACK
+# CHECK_RW-NEXT: Offset: 0x0
+# CHECK_RW-NEXT: VirtualAddress: 0x0
+# CHECK_RW-NEXT: PhysicalAddress: 0x0
+# CHECK_RW-NEXT: FileSize: 0
+# CHECK_RW-NEXT: MemSize: 0
+# CHECK_RW-NEXT: Flags [
+# CHECK_RW-NEXT: PF_R
+# CHECK_RW-NEXT: PF_W
+# CHECK_RW-NEXT: ]
+# CHECK_RW-NEXT: Alignment: 0
+# CHECK_RW-NEXT: }
+# CHECK_RW-NEXT: ]
+
+# CHECK_RWX: Sections [
+# CHECK_RWX-NOT: Name: .note.GNU-stack
+# CHECK_RWX: ProgramHeaders [
+# CHECK_RWX: ProgramHeader {
+# CHECK_RWX: Type: PT_GNU_STACK
+# CHECK_RWX-NEXT: Offset: 0x0
+# CHECK_RWX-NEXT: VirtualAddress: 0x0
+# CHECK_RWX-NEXT: PhysicalAddress: 0x0
+# CHECK_RWX-NEXT: FileSize: 0
+# CHECK_RWX-NEXT: MemSize: 0
+# CHECK_RWX-NEXT: Flags [
+# CHECK_RWX-NEXT: PF_R
+# CHECK_RWX-NEXT: PF_W
+# CHECK_RWX-NEXT: PF_X
+# CHECK_RWX-NEXT: ]
+# CHECK_RWX-NEXT: Alignment: 0
+# CHECK_RWX-NEXT: }
+# CHECK_RWX-NEXT: ]
+
+.globl _start
+_start:
Modified: lld/trunk/test/elf2/merge-shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/merge-shared.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/merge-shared.s (original)
+++ lld/trunk/test/elf2/merge-shared.s Sat Nov 14 14:56:08 2015
@@ -17,10 +17,10 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_MERGE
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x158
+// CHECK-NEXT: Address: 0x190
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.dyn {
-// CHECK-NEXT: 0x{{.*}} R_X86_64_RELATIVE - 0x15A
+// CHECK-NEXT: 0x{{.*}} R_X86_64_RELATIVE - 0x192
// CHECK-NEXT: }
// CHECK-NEXT: ]
Modified: lld/trunk/test/elf2/merge-string.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/merge-string.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/merge-string.s (original)
+++ lld/trunk/test/elf2/merge-string.s Sat Nov 14 14:56:08 2015
@@ -26,8 +26,8 @@ zed:
// CHECK-NEXT: SHF_MERGE
// CHECK-NEXT: SHF_STRINGS
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x158
-// CHECK-NEXT: Offset: 0x158
+// CHECK-NEXT: Address: 0x190
+// CHECK-NEXT: Offset: 0x190
// CHECK-NEXT: Size: 4
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
@@ -44,8 +44,8 @@ zed:
// NOTAIL-NEXT: SHF_MERGE
// NOTAIL-NEXT: SHF_STRINGS
// NOTAIL-NEXT: ]
-// NOTAIL-NEXT: Address: 0x158
-// NOTAIL-NEXT: Offset: 0x158
+// NOTAIL-NEXT: Address: 0x190
+// NOTAIL-NEXT: Offset: 0x190
// NOTAIL-NEXT: Size: 7
// NOTAIL-NEXT: Link: 0
// NOTAIL-NEXT: Info: 0
@@ -62,8 +62,8 @@ zed:
// CHECK-NEXT: SHF_MERGE
// CHECK-NEXT: SHF_STRINGS
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x15C
-// CHECK-NEXT: Offset: 0x15C
+// CHECK-NEXT: Address: 0x194
+// CHECK-NEXT: Offset: 0x194
// CHECK-NEXT: Size: 4
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
@@ -75,11 +75,11 @@ zed:
// CHECK: Name: bar
-// CHECK-NEXT: Value: 0x159
+// CHECK-NEXT: Value: 0x191
// CHECK: Name: foo
-// CHECK-NEXT: Value: 0x158
+// CHECK-NEXT: Value: 0x190
// CHECK: Name: zed
-// CHECK-NEXT: Value: 0x15C
+// CHECK-NEXT: Value: 0x194
// CHECK-NEXT: Size: 0
Modified: lld/trunk/test/elf2/merge-sym.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/merge-sym.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/merge-sym.s (original)
+++ lld/trunk/test/elf2/merge-sym.s Sat Nov 14 14:56:08 2015
@@ -15,7 +15,7 @@ foo:
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_MERGE
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x158
+// CHECK-NEXT: Address: 0x190
// CHECK: Name: foo
-// CHECK-NEXT: Value: 0x15A
+// CHECK-NEXT: Value: 0x192
Modified: lld/trunk/test/elf2/merge.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/merge.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/merge.s (original)
+++ lld/trunk/test/elf2/merge.s Sat Nov 14 14:56:08 2015
@@ -23,8 +23,8 @@ zed:
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_MERGE
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x100E8
-// CHECK-NEXT: Offset: 0xE8
+// CHECK-NEXT: Address: 0x10120
+// CHECK-NEXT: Offset: 0x120
// CHECK-NEXT: Size: 8
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
@@ -35,13 +35,13 @@ zed:
// CHECK-NEXT: )
-// Address of the constant 0x10 = 0x100E8 = 65768
-// Address of the constant 0x42 = 0x100EC = 65772
+// Address of the constant 0x10 = 0x10120 = 65824
+// Address of the constant 0x42 = 0x10124 = 65828
// CHECK: Symbols [
// CHECK: Name: bar
-// CHECK-NEXT: Value: 0x100EC
+// CHECK-NEXT: Value: 0x10124
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Loca
// CHECK-NEXT: Type: None
@@ -49,7 +49,7 @@ zed:
// CHECK-NEXT: Section: .mysec
// CHECK: Name: zed
-// CHECK-NEXT: Value: 0x100EC
+// CHECK-NEXT: Value: 0x10124
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -57,7 +57,7 @@ zed:
// CHECK-NEXT: Section: .mysec
// CHECK: Name: foo
-// CHECK-NEXT: Value: 0x100EC
+// CHECK-NEXT: Value: 0x10124
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -73,37 +73,37 @@ _start:
// DISASM-NEXT: _start:
movl .mysec, %eax
-// addr(0x10) = 65768
-// DISASM-NEXT: movl 65768, %eax
+// addr(0x10) = 65824
+// DISASM-NEXT: movl 65824, %eax
movl .mysec+7, %eax
-// addr(0x42) + 3 = 65772 + 3 = 65775
-// DISASM-NEXT: movl 65775, %eax
+// addr(0x42) + 3 = 65828 + 3 = 65831
+// DISASM-NEXT: movl 65831, %eax
movl .mysec+8, %eax
-// addr(0x42) = 65772
-// DISASM-NEXT: movl 65772, %eax
+// addr(0x42) = 65828
+// DISASM-NEXT: movl 65828, %eax
movl bar+7, %eax
-// addr(0x42) + 7 = 65772 + 7 = 65779
-// DISASM-NEXT: movl 65779, %eax
+// addr(0x42) + 7 = 65828 + 7 = 65835
+// DISASM-NEXT: movl 65835, %eax
movl bar+8, %eax
-// addr(0x42) + 8 = 65772 + 8 = 65780
-// DISASM-NEXT: movl 65780, %eax
+// addr(0x42) + 8 = 65828 + 8 = 65836
+// DISASM-NEXT: movl 65836, %eax
movl foo, %eax
-// addr(0x42) = 65772
-// DISASM-NEXT: movl 65772, %eax
+// addr(0x42) = 65828
+// DISASM-NEXT: movl 65828, %eax
movl foo+7, %eax
-// addr(0x42) + 7 = = 65772 + 7 = 65779
-// DISASM-NEXT: movl 65779, %eax
+// addr(0x42) + 7 = = 65828 + 7 = 65835
+// DISASM-NEXT: movl 65835, %eax
movl foo+8, %eax
-// addr(0x42) + 8 = = 65772 + 8 = 65780
-// DISASM-NEXT: movl 65780, %eax
+// addr(0x42) + 8 = = 65828 + 8 = 65836
+// DISASM-NEXT: movl 65836, %eax
// From the other file: movl .mysec, %eax
-// addr(0x42) = 65772
-// DISASM-NEXT: movl 65772, %eax
+// addr(0x42) = 65828
+// DISASM-NEXT: movl 65828, %eax
Modified: lld/trunk/test/elf2/program-header-layout.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/program-header-layout.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/program-header-layout.s (original)
+++ lld/trunk/test/elf2/program-header-layout.s Sat Nov 14 14:56:08 2015
@@ -23,7 +23,7 @@ _start:
# CHECK-NEXT: SHF_ALLOC
# CHECK-NEXT: ]
# CHECK-NEXT: Address:
-# CHECK-NEXT: Offset: 0x120
+# CHECK-NEXT: Offset: 0x158
# CHECK-NEXT: Size:
# CHECK-NEXT: Link:
# CHECK-NEXT: Info:
@@ -37,8 +37,8 @@ _start:
# CHECK-NEXT: Offset: 0x40
# CHECK-NEXT: VirtualAddress: 0x10040
# CHECK-NEXT: PhysicalAddress: 0x10040
-# CHECK-NEXT: FileSize: 224
-# CHECK-NEXT: MemSize: 224
+# CHECK-NEXT: FileSize: 280
+# CHECK-NEXT: MemSize: 280
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -49,8 +49,8 @@ _start:
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress:
# CHECK-NEXT: PhysicalAddress:
-# CHECK-NEXT: FileSize: 296
-# CHECK-NEXT: MemSize: 296
+# CHECK-NEXT: FileSize: 352
+# CHECK-NEXT: MemSize: 352
# CHECK-NEXT: Flags [
# CHECK-NEXT: PF_R
# CHECK-NEXT: ]
@@ -82,4 +82,17 @@ _start:
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment:
# CHECK-NEXT: }
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_GNU_STACK
+# CHECK-NEXT: Offset: 0x0
+# CHECK-NEXT: VirtualAddress: 0x0
+# CHECK-NEXT: PhysicalAddress: 0x0
+# CHECK-NEXT: FileSize: 0
+# CHECK-NEXT: MemSize: 0
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_W
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: }
# CHECK-NEXT: ]
Modified: lld/trunk/test/elf2/relative-dynamic-reloc-ppc64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relative-dynamic-reloc-ppc64.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/relative-dynamic-reloc-ppc64.s (original)
+++ lld/trunk/test/elf2/relative-dynamic-reloc-ppc64.s Sat Nov 14 14:56:08 2015
@@ -13,7 +13,7 @@
// CHECK-NEXT: 0x10010 R_PPC64_RELATIVE - 0x10009
// CHECK-NEXT: 0x{{.*}} R_PPC64_RELATIVE - 0x[[ZED_ADDR:.*]]
// CHECK-NEXT: 0x{{.*}} R_PPC64_RELATIVE - 0x[[FOO_ADDR]]
-// CHECK-NEXT: 0x160 R_PPC64_ADDR64 external 0x0
+// CHECK-NEXT: 0x198 R_PPC64_ADDR64 external 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]
Modified: lld/trunk/test/elf2/relative-dynamic-reloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relative-dynamic-reloc.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/relative-dynamic-reloc.s (original)
+++ lld/trunk/test/elf2/relative-dynamic-reloc.s Sat Nov 14 14:56:08 2015
@@ -12,7 +12,7 @@
// CHECK-NEXT: 0x1010 R_X86_64_RELATIVE - 0x1009
// CHECK-NEXT: 0x{{.*}} R_X86_64_RELATIVE - 0x[[ZED_ADDR:.*]]
// CHECK-NEXT: 0x{{.*}} R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
-// CHECK-NEXT: 0x160 R_X86_64_64 external 0x0
+// CHECK-NEXT: 0x198 R_X86_64_64 external 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]
Modified: lld/trunk/test/elf2/relocation-local.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation-local.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/relocation-local.s (original)
+++ lld/trunk/test/elf2/relocation-local.s Sat Nov 14 14:56:08 2015
@@ -35,4 +35,4 @@ R_X86_64_64:
.quad R_X86_64_64
// CHECK: Contents of section .R_X86_64_64:
-// CHECK-NEXT: 100e8 e8000100 00000000
+// CHECK-NEXT: 10120 20010100 00000000
Modified: lld/trunk/test/elf2/relocation.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/relocation.s (original)
+++ lld/trunk/test/elf2/relocation.s Sat Nov 14 14:56:08 2015
@@ -31,7 +31,7 @@
// SEC-NEXT: EntrySize: 0
// SEC-NEXT: }
-// SEC: Name: .got.plt
+// SEC: Name: .got.plt
// SEC-NEXT: Type: SHT_PROGBITS
// SEC-NEXT: Flags [
// SEC-NEXT: SHF_ALLOC
@@ -104,7 +104,7 @@ R_X86_64_64:
.quad R_X86_64_64
// CHECK: Contents of section .R_X86_64_64:
-// CHECK-NEXT: 10158 58010100 00000000
+// CHECK-NEXT: 10190 90010100 00000000
.section .R_X86_64_GOTPCREL,"a", at progbits
.global R_X86_64_GOTPCREL
@@ -114,4 +114,4 @@ R_X86_64_GOTPCREL:
// 0x120A8 - 0x10160 = 8008
// 8008 = 0x481f0000 in little endian
// CHECK: Contents of section .R_X86_64_GOTPCREL
-// CHECK-NEXT: 10160 801f0000
+// CHECK-NEXT: 10198 481f0000
Modified: lld/trunk/test/elf2/shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/shared.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/shared.s (original)
+++ lld/trunk/test/elf2/shared.s Sat Nov 14 14:56:08 2015
@@ -46,7 +46,7 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: ]
// CHECK-NEXT: Address: [[DYNSYMADDR:.*]]
-// CHECK-NEXT: Offset: 0x110
+// CHECK-NEXT: Offset: 0x130
// CHECK-NEXT: Size:
// CHECK-NEXT: Link: [[DYNSTR:.*]]
// CHECK-NEXT: Info: 1
Modified: lld/trunk/test/elf2/string-table.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/string-table.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/string-table.s (original)
+++ lld/trunk/test/elf2/string-table.s Sat Nov 14 14:56:08 2015
@@ -19,7 +19,7 @@ _start:
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x100E8
+// CHECK-NEXT: Address: 0x10120
// CHECK: Name: foobar
// CHECK-NEXT: Type: SHT_PROGBITS
Modified: lld/trunk/test/elf2/symbols.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/symbols.s?rev=253145&r1=253144&r2=253145&view=diff
==============================================================================
--- lld/trunk/test/elf2/symbols.s (original)
+++ lld/trunk/test/elf2/symbols.s Sat Nov 14 14:56:08 2015
@@ -50,7 +50,7 @@ internal:
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x10120
+// CHECK-NEXT: Address: 0x10158
// CHECK: Name: .text
// CHECK-NEXT: Type: SHT_PROGBITS
@@ -82,7 +82,7 @@ internal:
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: hidden
-// CHECK-NEXT: Value: 0x10128
+// CHECK-NEXT: Value: 0x10160
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -91,7 +91,7 @@ internal:
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: internal
-// CHECK-NEXT: Value: 0x10128
+// CHECK-NEXT: Value: 0x10160
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -145,7 +145,7 @@ internal:
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: protected
-// CHECK-NEXT: Value: 0x10128
+// CHECK-NEXT: Value: 0x10160
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
@@ -154,7 +154,7 @@ internal:
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: zed
-// CHECK-NEXT: Value: 0x10120
+// CHECK-NEXT: Value: 0x10158
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global (0x1)
// CHECK-NEXT: Type: None
@@ -163,7 +163,7 @@ internal:
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: zed2
-// CHECK-NEXT: Value: 0x10124
+// CHECK-NEXT: Value: 0x1015C
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
@@ -172,7 +172,7 @@ internal:
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: zed3
-// CHECK-NEXT: Value: 0x10128
+// CHECK-NEXT: Value: 0x10160
// CHECK-NEXT: Size: 4
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
More information about the llvm-commits
mailing list