[llvm-commits] [llvm-gcc-4.2] r59021 - in /llvm-gcc-4.2/trunk/gcc: common.opt config/darwin.c

Bill Wendling isanbard at gmail.com
Tue Nov 11 11:20:08 PST 2008


On Tue, Nov 11, 2008 at 9:00 AM, Evan Cheng <evan.cheng at apple.com> wrote:
>> - Enable stack protectors by default for Darwin 10.6 and later.
>> - Don't enable stack protectors by default for Darwin 10.5.
>>
>> This isn't exact. If we're building a 10.5 binary on a 10.6 system,
>> then stack
>> protectors should be enabled.
>>
>> --- llvm-gcc-4.2/trunk/gcc/common.opt (original)
>> +++ llvm-gcc-4.2/trunk/gcc/common.opt Mon Nov 10 22:28:21 2008
>> @@ -1018,9 +1018,8 @@
>> -fstack-limit-symbol=<name>   Trap if the stack goes past symbol <name>
>>
>> ; APPLE LOCAL begin stack-protector default 5095227
>> -; LLVM LOCAL FIXME Don't add Init just yet
>> fstack-protector
>> -Common Report Var(flag_stack_protect, 1)
>> +Common Report Var(flag_stack_protect, 1) Init(-1)
>> Use propolice as a stack protection method
>> ; APPLE LOCAL end stack-protector default 5095227
>>
>>

>> --- llvm-gcc-4.2/trunk/gcc/config/darwin.c (original)
>> +++ llvm-gcc-4.2/trunk/gcc/config/darwin.c Mon Nov 10 22:28:21 2008
>> @@ -2686,12 +2686,22 @@
>>   /* APPLE LOCAL begin stack-protector default 5095227 */
>>   /* Default flag_stack_protect to 1 if on 10.5 or later for user
>> code,
>>      or 10.6 or later for code identified as part of the kernel.  */
>> +  /* LLVM LOCAL begin - Don't enable stack protectors by default
>> for Leopard. */
>> +#ifndef ENABLE_LLVM
>
> The logic here should be the same for gcc and llvm-gcc. It seems like
> gcc turns it on for 10.5 but when I tried gcc-4.2 it doesn't seem to
> generate stack protector code. Is darwin_macosx_version_min set by
> default? If not, then flag_stack_protect is set somewhere else, right?
>
The flag_stack_protect is set by the code that's generated from the
common.opt stuff. (See above for the initial value.) If you specify
-fstack-protector, then it gets set to 1, etc. The
darwin_macosx_version_min is set by the -mmacosx-version-min= command
line variable. If you specify "-v" on the command line, you'll see
that this command line variable is added in there for us:

/usr/libexec/gcc/i686-apple-darwin9/4.2.1/cc1 ...
-mmacosx-version-min=10.5.5 ...

The reason why the logic is not the same is because the logic on the
GCC that's shipping with Leopard is different than the logic that's in
the current TOT -- it's a different branch. LLVM-GCC doesn't have this
luxury.

>>   if (flag_stack_protect == -1
>>       && darwin_macosx_version_min
>>       && ((! flag_mkernel && ! flag_apple_kext
>>          && strverscmp (darwin_macosx_version_min, "10.5") >= 0)
>>         || strverscmp (darwin_macosx_version_min, "10.6") >= 0))
>>     flag_stack_protect = 1;
>> +#else
>> +  if (flag_stack_protect == -1 && darwin_macosx_version_min)
>
> Need { } around the if else otherwise it generates a gcc compile
> warning which breaks Apple style build.
>
Fixed.

-bw



More information about the llvm-commits mailing list