[PATCH] D25676: [ELF] - Add support for -nopie

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 07:51:40 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL284388: [ELF] - Add support for -nopie (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D25676?vs=74841&id=74848#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25676

Files:
  lld/trunk/ELF/Driver.cpp
  lld/trunk/ELF/Options.td
  lld/trunk/test/ELF/pie.s


Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -456,7 +456,7 @@
   Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
   Config->NoUndefinedVersion = Args.hasArg(OPT_no_undefined_version);
   Config->Nostdlib = Args.hasArg(OPT_nostdlib);
-  Config->Pie = Args.hasArg(OPT_pie);
+  Config->Pie = getArg(Args, OPT_pie, OPT_nopie, false);
   Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections);
   Config->Relocatable = Args.hasArg(OPT_relocatable);
   Config->SaveTemps = Args.hasArg(OPT_save_temps);
Index: lld/trunk/ELF/Options.td
===================================================================
--- lld/trunk/ELF/Options.td
+++ lld/trunk/ELF/Options.td
@@ -127,6 +127,8 @@
 def noinhibit_exec: F<"noinhibit-exec">,
   HelpText<"Retain the executable output file whenever it is still usable">;
 
+def nopie: F<"nopie">, HelpText<"Do not create a position independent executable">;
+
 def no_undefined: F<"no-undefined">,
   HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
 
Index: lld/trunk/test/ELF/pie.s
===================================================================
--- lld/trunk/test/ELF/pie.s
+++ lld/trunk/test/ELF/pie.s
@@ -1,5 +1,12 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+
+## Default is no PIE.
+# RUN: ld.lld %t1.o -o %t
+# RUN: llvm-readobj -file-headers -sections -program-headers -symbols -r %t \
+# RUN:   | FileCheck %s --check-prefix=NOPIE
+
+## Check -pie.
 # RUN: ld.lld -pie %t1.o -o %t
 # RUN: llvm-readobj -file-headers -sections -program-headers -symbols -r %t | FileCheck %s
 
@@ -98,5 +105,10 @@
 # CHECK-NEXT:    Alignment: 8
 # CHECK-NEXT:  }
 
+## Check -nopie
+# RUN: ld.lld -nopie %t1.o -o %t2
+# RUN: llvm-readobj -file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE
+# NOPIE-NOT: Type: SharedObject
+
 .globl _start
 _start:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25676.74848.patch
Type: text/x-patch
Size: 1985 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/0af02b9e/attachment.bin>


More information about the llvm-commits mailing list