зеркало из https://github.com/microsoft/clang-1.git
[driver] Add support for the --param ssp-buffer-size= driver option.
PR9673 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162285 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
05c5ebc9ba
Коммит
a7afeb0404
|
@ -415,6 +415,8 @@ def static_define : Flag<"-static-define">,
|
|||
HelpText<"Should __STATIC__ be defined">;
|
||||
def stack_protector : Separate<"-stack-protector">,
|
||||
HelpText<"Enable stack protectors">;
|
||||
def stack_protector_buffer_size : Separate<"-stack-protector-buffer-size">,
|
||||
HelpText<"Lower bound for a buffer to be considered for stack protection">;
|
||||
def fvisibility : Separate<"-fvisibility">,
|
||||
HelpText<"Default symbol visibility">;
|
||||
def ftemplate_depth : Separate<"-ftemplate-depth">,
|
||||
|
|
|
@ -185,6 +185,9 @@ public:
|
|||
/// The run-time penalty for bounds checking, or 0 to disable.
|
||||
unsigned char BoundsChecking;
|
||||
|
||||
/// The lower bound for a buffer to be considered for stack protection.
|
||||
unsigned SSPBufferSize;
|
||||
|
||||
/// The default TLS model to use.
|
||||
TLSModel DefaultTLSModel;
|
||||
|
||||
|
@ -241,6 +244,7 @@ public:
|
|||
StackRealignment = 0;
|
||||
StackAlignment = 0;
|
||||
BoundsChecking = 0;
|
||||
SSPBufferSize = 8;
|
||||
UseInitArray = 0;
|
||||
|
||||
DebugInfo = NoDebugInfo;
|
||||
|
|
|
@ -375,6 +375,7 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,
|
|||
Options.DisableTailCalls = CodeGenOpts.DisableTailCalls;
|
||||
Options.TrapFuncName = CodeGenOpts.TrapFuncName;
|
||||
Options.PositionIndependentExecutable = LangOpts.PIELevel != 0;
|
||||
Options.SSPBufferSize = CodeGenOpts.SSPBufferSize;
|
||||
|
||||
TargetMachine *TM = TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
|
||||
FeaturesStr, Options,
|
||||
|
|
|
@ -2353,6 +2353,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
if (StackProtectorLevel) {
|
||||
CmdArgs.push_back("-stack-protector");
|
||||
CmdArgs.push_back(Args.MakeArgString(Twine(StackProtectorLevel)));
|
||||
|
||||
// --param ssp-buffer-size=
|
||||
for (arg_iterator it = Args.filtered_begin(options::OPT__param),
|
||||
ie = Args.filtered_end(); it != ie; ++it) {
|
||||
StringRef Str((*it)->getValue(Args));
|
||||
if (Str.startswith("ssp-buffer-size=")) {
|
||||
CmdArgs.push_back("-stack-protector-buffer-size");
|
||||
// FIXME: Verify the argument is a valid integer.
|
||||
CmdArgs.push_back(Args.MakeArgString(Str.drop_front(16)));
|
||||
(*it)->claim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Translate -mstackrealign
|
||||
|
|
|
@ -1267,6 +1267,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Opts.CoverageFile = Args.getLastArgValue(OPT_coverage_file);
|
||||
Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
|
||||
Opts.LinkBitcodeFile = Args.getLastArgValue(OPT_mlink_bitcode_file);
|
||||
Opts.SSPBufferSize =
|
||||
Args.getLastArgIntValue(OPT_stack_protector_buffer_size, 8, Diags);
|
||||
Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
|
||||
if (Arg *A = Args.getLastArg(OPT_mstack_alignment)) {
|
||||
StringRef Val = A->getValue(Args);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// RUN: %clang -fno-stack-protector -### %s 2>&1 | FileCheck %s -check-prefix=NOSSP
|
||||
// NOSSP-NOT: "-stack-protector" "1"
|
||||
// NOSSP-NOT: "-stack-protector-buffer-size"
|
||||
|
||||
// RUN: %clang -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP
|
||||
// SSP: "-stack-protector" "1"
|
||||
// SSP-NOT: "-stack-protector-buffer-size"
|
||||
|
||||
// RUN: %clang -fstack-protector --param ssp-buffer-size=16 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-BUF
|
||||
// SSP-BUF: "-stack-protector" "1"
|
||||
// SSP-BUF: "-stack-protector-buffer-size" "16"
|
Загрузка…
Ссылка в новой задаче