Re: -fstack-protector
Re: -fstack-protector
- Subject: Re: -fstack-protector
- From: "John Engelhart" <email@hidden>
- Date: Sat, 13 Sep 2008 16:31:50 -0400
On Thu, Sep 11, 2008 at 3:03 PM, Rich Collyer <email@hidden> wrote:
> I am using 10.4 (SDK & Deployment) because my product requirement is that I
> run on 10.4 machines.
>
> If this is true, I guess I will not be able to use this feature yet.
You can use it on 10.4, but it takes some effort. Lucky for you I've
already jumped this hurdle. :) I ran in to this issue when working
on RegexKit (http://regexkit.sourceforge.net).
The gist of the problem is there's a handful of functions that
-fstack-protector calls that aren't present in libSystem prior to
10.5, I think it's stack_chk_guard() and stack_chk_fail(), but don't
hold me to it.
You can find the source for my solution to the problem at
http://regexkit.svn.sourceforge.net/viewvc/regexkit/trunk/Source/RK_stack_chk.c?revision=20&view=markup
Now, this is all from memory, so I might get a few things wrong, but
the idea was to take the OpenBSD source for those functions and
compile them in to my executable. It's tweaked slightly so that it
checks to see if a real stack_chk_guard() function is present (ie,
running on 10.5), and if so just uses that. If it can't find the
function, then it just executes the code that the real
stack_chk_guard() would have done anyways (preps the stack canary, I
think. It's the exact same code that ships with 10.5, modulo start up
tweaks).
So, it is possible to use -fstack-protector on pre-10.5 systems, you
just have to do a bit of hand waving and linking trickery. Can't say
it'll get a nod as 'officially supported' though, so you take your
chances. :) It was a pretty rude shock to compile with
-fstack-protector -mmacosx-version-min=10.4, get no warnings, and have
it utterly fail on a 10.4 machine due to linking problems. :(
>
>
> On Sep 11, 2008, at 11:58 AM, Sean McBride wrote:
>
>> On 9/11/08 11:41 AM, Rich Collyer said:
>>
>>> I have heard a couple of times this summer a recommendation to use the
>>> -fstack-protector gcc flag. However, when I use it, I get non-
>>> descript linker errors about a few of my methods.
>>>
>>> Does anyone know what the linker might be complaining about?
>>
>> Are you using the 10.5 sdk and 10.5 deployment target? I believe that
>> feature is 10.5 only.
>>
>> --
>> ____________________________________________________________
>> Sean McBride, B. Eng email@hidden
>> Rogue Research www.rogue-research.com
>> Mac Software Developer Montréal, Québec, Canada
>>
>>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden