diff options
author | George Rimar <grimar@accesssoftek.com> | 2016-10-17 14:42:11 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2016-10-17 14:42:11 +0000 |
commit | c3c4f46d07e397f76044a3c9c4888816ae3cc703 (patch) | |
tree | 312570ffbd70c828b72d50a065631bb5cb9d381f | |
parent | 272c410c2480ae3534d5eff196e4332e83ac0b98 (diff) | |
download | bcm5719-llvm-c3c4f46d07e397f76044a3c9c4888816ae3cc703.tar.gz bcm5719-llvm-c3c4f46d07e397f76044a3c9c4888816ae3cc703.zip |
[ELF] - Add support for -nopie
This is https://llvm.org/bugs/show_bug.cgi?id=30696,
Differential revision: https://reviews.llvm.org/D25676
llvm-svn: 284388
-rw-r--r-- | lld/ELF/Driver.cpp | 2 | ||||
-rw-r--r-- | lld/ELF/Options.td | 2 | ||||
-rw-r--r-- | lld/test/ELF/pie.s | 12 |
3 files changed, 15 insertions, 1 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index a46416e802a..54183d0c407 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -456,7 +456,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { 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); diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td index e01ba28efa4..5e7297681d4 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -127,6 +127,8 @@ def no_whole_archive: F<"no-whole-archive">, 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">; diff --git a/lld/test/ELF/pie.s b/lld/test/ELF/pie.s index 4cf1743ee73..b07a5d376e8 100644 --- a/lld/test/ELF/pie.s +++ b/lld/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: |