This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: newlib-2.18: Problem with 'free' in __call_atexit.c


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]