undefined reference to `__stack_chk_fail'
Corinna Vinschen
vinschen@redhat.com
Wed Apr 21 22:10:00 GMT 2010
On Apr 9 17:11, Qihang Huang wrote:
> Dear list,
>
> I am "porting" new lib to replace glibc on Linux (x86_64), so that I
> know new lib better before I actually port it somewhere. So right now,
> all I did was implementing the system calls stubs using Linux system
> calls directly, and compile new lib, and link a helloWorld.c with new
> lib. Everything is fine if I am using puts() in the helloWorld
> program, but if I use iprintf() instead, when I link it with "ld
> -static -nostdlib -L/path/to/newlib -o hello helloWorld.o crt1.o
> my_syscalls.o -lc", ld complains "./libc.a(lib_a-vfiprintf.o): In
> function `_vfiprintf_r':
> vfprintf.c:(.text+0x1392): undefined reference to `__stack_chk_fail'".
>
> Any idea why is it so? And how to fix it?
The symbol has been added by your compiler. AFAIK it's defined
in glibc. See the GCC flag -fstack-protector. In theory you
should be able to define a function __stack_chk_fail(void) yourself
and call abort in it, or something.
Corinna
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
More information about the Newlib
mailing list