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: undefined reference error while using 'gets'


On 11/03/2011 08:59 AM, Rohit Arul Raj wrote:
Hi All,

I am using newlib v1.18 built with 'powerpc-elf' v4.5.2. While using
the 'gets' function call, i get the following error:

powerpc-elf/4.5.2/../../../../powerpc-elf/lib\libc.a(lib_a-gets.o): In
function `_gets_r':
gets.c:(.text+0x30): undefined reference to `__sfp_lock_acquire'
gets.c:(.text+0xa8): undefined reference to `__sfp_lock_release'

Based on the documentation, it has been mentioned that 'gets' is
obsolete and we need to use 'fgets'. But still i should not be getting
any undefined reference errors.

I took a look at the 'newlib\libc\stdio\gets.c' and i think we need to
include "local.h" to get these definitions. Is that right?

Let me know your suggestions.


Actually, Rohit, there was a lock issue that was fixed in January by Corinna so gets doesn't call __sfp_lock_xxxxx functions any more.


2011-01-28 Corinna Vinschen <vinschen@redhat.com>

* libc/stdio/fclose.c: Only use sfp lock to guard non-atomic
changes of flags and fp lock.
* libc/stdio/freopen.c: Ditto.
* libc/stdio64/freopen64.c: Ditto.
* libc/stdio/fgetc.c: Revert change from 2009-04-24, remove sfp locks
which guard entire function to avoid potential deadlocks when using
stdio functions in multiple thraeds.
* libc/stdio/fgets.c: Ditto.
* libc/stdio/fgetwc.c: Ditto.
* libc/stdio/fgetws.c: Ditto.
* libc/stdio/fread.c: Ditto.
* libc/stdio/fseek.c: Ditto.
* libc/stdio/getc.c: Ditto.
* libc/stdio/getdelim.c: Ditto.
* libc/stdio/gets.c: Ditto.
* libc/stdio/vfscanf.c: Ditto.
* libc/stdio/vfwscanf.c: Ditto.


I suggest you check out current newlib as it will have the most up-to-date fixes. Otherwise, you can attempt to patch your own code locally.

Thanks,
Rohit


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