Stack protection breaks -fprofile-generate

Peter Jeremy peterjeremy at
Fri Sep 18 01:15:19 UTC 2009

On 2009-Sep-17 22:16:42 +1000, Peter Jeremy <peterjeremy at> wrote:
>On 2009-Sep-17 16:10:54 +1000, Peter Jeremy <peterjeremy at> wrote:
>>Somewhere between early June and lastest 8.x, -fprofile-generate broke
>>on i386.  This looks to be related to stack protection.
>>$ echo 'int main() { return 0; }' > x.c
>>$ cc x.c
>>$ cc -fprofile-generate x.c         
>>/usr/lib/libgcov.a(_gcov.o)(.text+0x13df): In function `gcov_exit':
>>/usr/src/gnu/lib/libgcov/../../../contrib/gcc/libgcov.c:532: undefined reference to `__stack_chk_fail_local'
>Checking on 8.0-BETA4 from yesterday (about SVN rev 197239), it fails
>on i386 and succeeds on amd4.  It looks suspiciously like this is
>more fallout from r195697 but I'm not sure what the fix is.

I had hoped r197277 might fix the problem but it doesn't:   r197277
provides a weak __stack_chk_fail_local in libc.a but in my case, it's
linking against

That said, _does_ have a definition of __stack_chk_fail_local
so why isn't the linker finding it?

builder% cc -Wl,-t -fprofile-generate x.c
/usr/bin/ld: mode elf_i386_fbsd
-lgcc_s (/usr/lib/
-lc (/usr/lib/
-lgcc_s (/usr/lib/
/usr/lib/libgcov.a(_gcov.o)(.text+0x13df): In function `gcov_exit':
/usr/src/gnu/lib/libgcov/../../../contrib/gcc/libgcov.c:532: undefined reference to `__stack_chk_fail_local'
/usr/bin/ld: link errors found, deleting executable `a.out'
builder% nm -o -D /usr/lib/|grep __stack_chk_fail
/usr/lib/ T __stack_chk_fail
/usr/lib/ T __stack_chk_fail_local
builder% nm -o /usr/lib/libgcov.a|grep __stack_chk_fail_local
/usr/lib/libgcov.a:_gcov_execle.o:         U __stack_chk_fail_local
/usr/lib/libgcov.a:_gcov_execlp.o:         U __stack_chk_fail_local
/usr/lib/libgcov.a:_gcov_execl.o:         U __stack_chk_fail_local
/usr/lib/libgcov.a:_gcov.o:         U __stack_chk_fail_local

Peter Jeremy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url :

More information about the freebsd-current mailing list