[PATCH] D25472: [ELF] - Implemented -z wxneeded.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 04:12:15 PDT 2016
grimar updated this revision to Diff 74358.
grimar added a comment.
- Addressed review comments.
https://reviews.llvm.org/D25472
Files:
ELF/Config.h
ELF/Driver.cpp
ELF/LinkerScript.cpp
ELF/Writer.cpp
test/ELF/linkerscript/openbsd-wxneeded.s
test/ELF/openbsd-wxneeded.s
Index: test/ELF/openbsd-wxneeded.s
===================================================================
--- test/ELF/openbsd-wxneeded.s
+++ test/ELF/openbsd-wxneeded.s
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+# RUN: ld.lld -z wxneeded %t -o %t.out
+# RUN: llvm-readobj --program-headers %t.out | FileCheck %s
+
+# CHECK: ProgramHeader {
+# CHECK: Type: (0x65A3DBE7)
+# 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_X
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: }
Index: test/ELF/linkerscript/openbsd-wxneeded.s
===================================================================
--- test/ELF/linkerscript/openbsd-wxneeded.s
+++ test/ELF/linkerscript/openbsd-wxneeded.s
@@ -0,0 +1,17 @@
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
+# RUN: echo "PHDRS { text PT_LOAD FILEHDR PHDRS; wxneeded PT_OPENBSD_WXNEEDED; }" > %t.script
+# RUN: ld.lld -z wxneeded --script %t.script %t.o -o %t
+# RUN: llvm-readobj --program-headers %t | FileCheck %s
+
+# CHECK: ProgramHeader {
+# CHECK: Type: (0x65A3DBE7)
+# 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: ]
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: }
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1109,6 +1109,9 @@
Hdr.H.p_memsz = Config->ZStackSize;
}
+ if (Config->ZWxneeded)
+ AddHdr(PT_OPENBSD_WXNEEDED, PF_X);
+
if (Note.First)
Ret.push_back(std::move(Note));
return Ret;
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1714,6 +1714,7 @@
.Case("PT_GNU_EH_FRAME", PT_GNU_EH_FRAME)
.Case("PT_GNU_STACK", PT_GNU_STACK)
.Case("PT_GNU_RELRO", PT_GNU_RELRO)
+ .Case("PT_OPENBSD_WXNEEDED", PT_OPENBSD_WXNEEDED)
.Default(-1);
if (Ret == (unsigned)-1) {
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -494,6 +494,7 @@
Config->ZNow = hasZOption(Args, "now");
Config->ZOrigin = hasZOption(Args, "origin");
Config->ZRelro = !hasZOption(Args, "norelro");
+ Config->ZWxneeded = hasZOption(Args, "wxneeded");
if (!Config->Relocatable)
Config->Strip = getStripOption(Args);
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -126,6 +126,7 @@
bool ZNow;
bool ZOrigin;
bool ZRelro;
+ bool ZWxneeded;
DiscardPolicy Discard;
SortSectionPolicy SortSection;
StripPolicy Strip = StripPolicy::None;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25472.74358.patch
Type: text/x-patch
Size: 3111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161012/f266bf26/attachment.bin>
More information about the llvm-commits
mailing list