newlib-2.18: Problem with 'free' in __call_atexit.c
Jeff Johnston
jjohnstn@redhat.com
Tue Oct 26 04:10:00 GMT 2010
On 10/25/2010 02:49 PM, Jeff Kuskin wrote:
> Hi,
>
> I'm trying to upgrade from version of newlib-1.16 to 1.18. The problem described below does not occur with newlib-1.16.
>
> I'm using binutils-2.20.1 and GCC 4.5.1.
>
> When I try to compile this program:
>
> #include<stdio.h>
> #include<stdlib.h>
> int main() {
> FILE *f = fopen("qqq", "r");
> return (f == 0);
> }
>
>
> I get this error at link time:
> [...]/lib/libc.a(lib_a-__call_atexit.o):
> In function `__call_exitprocs':
> [...]/newlib/libc/stdlib/__call_atexit.c:97: undefined reference to `free'
> collect2: ld returned 1 exit status
>
>
> However, if I add a 'free(f);' statement into the main() code (which is of course a bug, but ignore that), the link error goes away. It's as if the weak reference to 'free' in __call_atexit.c is not being bound to free() by the linker unless there is also a non-weak reference to free() present.
>
> Any suggestions?
>
>
What configuration are you building for?
Something may have changed in the latest compiler/linker behaviour as
the newlib 1.18 code has built fine in the past. Try regressing your
level of gcc and binutils to confirm. As well, you should post to the
gcc and binutils mailing lists.
-- Jeff J.
>
More information about the Newlib
mailing list