forked from OSchip/llvm-project
Driver/Darwin: Pass -pie/-no_pie to the linker when -fpie/-fno-pie and friends
are explicitly given. llvm-svn: 108297
This commit is contained in:
parent
c95a41b510
commit
af68a88e68
|
@ -179,6 +179,8 @@ namespace driver {
|
|||
Arg *getLastArg(OptSpecifier Id) const;
|
||||
Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1) const;
|
||||
Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const;
|
||||
Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2,
|
||||
OptSpecifier Id3) const;
|
||||
|
||||
/// getArgString - Return the input argument string at \arg Index.
|
||||
virtual const char *getArgString(unsigned Index) const = 0;
|
||||
|
|
|
@ -230,6 +230,7 @@ def exported__symbols__list : Separate<"-exported_symbols_list">;
|
|||
def e : JoinedOrSeparate<"-e">;
|
||||
def fPIC : Flag<"-fPIC">, Group<f_Group>;
|
||||
def fPIE : Flag<"-fPIE">, Group<f_Group>;
|
||||
def fno_PIE : Flag<"-fno-PIE">, Group<f_Group>;
|
||||
def faccess_control : Flag<"-faccess-control">, Group<f_Group>;
|
||||
def fapple_kext : Flag<"-fapple-kext">, Group<f_Group>;
|
||||
def fasm : Flag<"-fasm">, Group<f_Group>;
|
||||
|
@ -356,6 +357,7 @@ def fpascal_strings : Flag<"-fpascal-strings">, Group<f_Group>;
|
|||
def fpch_preprocess : Flag<"-fpch-preprocess">, Group<f_Group>;
|
||||
def fpic : Flag<"-fpic">, Group<f_Group>;
|
||||
def fpie : Flag<"-fpie">, Group<f_Group>;
|
||||
def fno_pie : Flag<"-fno-pie">, Group<f_Group>;
|
||||
def fprofile_arcs : Flag<"-fprofile-arcs">, Group<f_Group>;
|
||||
def fprofile_generate : Flag<"-fprofile-generate">, Group<f_Group>;
|
||||
def framework : Separate<"-framework">, Flags<[LinkerInput]>;
|
||||
|
|
|
@ -95,6 +95,25 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
|||
return Res;
|
||||
}
|
||||
|
||||
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
OptSpecifier Id2, OptSpecifier Id3) const {
|
||||
Arg *Res = 0;
|
||||
for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(Id0) ||
|
||||
(*it)->getOption().matches(Id1) ||
|
||||
(*it)->getOption().matches(Id2) ||
|
||||
(*it)->getOption().matches(Id3)) {
|
||||
Res = *it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Res)
|
||||
Res->claim();
|
||||
|
||||
return Res;
|
||||
}
|
||||
|
||||
bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const {
|
||||
if (Arg *A = getLastArg(Pos, Neg))
|
||||
return A->getOption().matches(Pos);
|
||||
|
|
|
@ -2356,8 +2356,15 @@ void darwin::Link::AddLinkArgs(const ArgList &Args,
|
|||
Args.AddAllArgs(CmdArgs, options::OPT_multiply__defined);
|
||||
Args.AddAllArgs(CmdArgs, options::OPT_multiply__defined__unused);
|
||||
|
||||
if (Args.hasArg(options::OPT_fpie))
|
||||
CmdArgs.push_back("-pie");
|
||||
if (const Arg *A = Args.getLastArg(options::OPT_fpie, options::OPT_fPIE,
|
||||
options::OPT_fno_pie,
|
||||
options::OPT_fno_PIE)) {
|
||||
if (A->getOption().matches(options::OPT_fpie) ||
|
||||
A->getOption().matches(options::OPT_fPIE))
|
||||
CmdArgs.push_back("-pie");
|
||||
else
|
||||
CmdArgs.push_back("-no_pie");
|
||||
}
|
||||
|
||||
Args.AddLastArg(CmdArgs, options::OPT_prebind);
|
||||
Args.AddLastArg(CmdArgs, options::OPT_noprebind);
|
||||
|
|
|
@ -70,3 +70,15 @@
|
|||
// LINK_IPHONE_3_1: ld"
|
||||
// LINK_IPHONE_3_1-NOT: -lbundle1.o
|
||||
// LINK_IPHONE_3_1: -lSystem
|
||||
|
||||
// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -fpie %t.o 2> %t.log
|
||||
// RUN: FileCheck -check-prefix=LINK_EXPLICIT_PIE %s < %t.log
|
||||
//
|
||||
// LINK_EXPLICIT_PIE: ld"
|
||||
// LINK_EXPLICIT_PIE: "-pie"
|
||||
|
||||
// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -fno-pie %t.o 2> %t.log
|
||||
// RUN: FileCheck -check-prefix=LINK_EXPLICIT_NO_PIE %s < %t.log
|
||||
//
|
||||
// LINK_EXPLICIT_NO_PIE: ld"
|
||||
// LINK_EXPLICIT_NO_PIE: "-no_pie"
|
||||
|
|
Loading…
Reference in New Issue