This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: undefined reference to `__stack_chk_fail'
Thank you Corinna! Yes, you are right, it is added by gcc. And using
the GCC flag -fno-stack-protector can remove the complain from GCC.
Thanks again.
Cheers,
Qihang
On Fri, Apr 9, 2010 at 9:49 PM, Corinna Vinschen <vinschen@redhat.com> wrote:
> 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
>