On Fri, Jun 01, 2012 at 05:00:58PM +0200, Florian Weimer wrote: > On 06/01/2012 03:34 PM, Jakub Jelinek wrote: > >The standard -D_FORTIFY_SOURCE failure is __chk_fail (), so IMNSHO > >if this is presented as _FORTIFY_SOURCE check, it should call that > >and not some other function. You'd need to use > >#if __USE_FORTIFY_LEVEL> 0 > >test instead (as __chk_fail is only provided by glibcs that on > >_FORTIFY_SOURCE definition sets __USE_FORTIFY_LEVEL), but it would be > >consistent with all other fortification failures (and, even > >-fstack-protector failures are similar). > > __chk_fail it is, then. This means that the test case will be > specific to GNU libc platforms. How can I mark it as such?
{ target *-*-linux* } or so? > >Or of course if you want it to do something else on failures, better > >enable it using a different macro. > > I'm aiming for a consistent developer experience. For other platforms there is always libssp included with gcc, which can be used instead (users then have to link -lssp if they compile with -D_FORTIFY_SOURCE). Note, __chk_fail () isn't prototyped in glibc headers, so you want probably in the checking method declare it in some __gnu* namespace as extern "C" __chk_fail () __attribute__((unused)); and then use. Jakub