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: Archive (library) with syscalls?


On 25 Sep 2015 00:09, Freddie Chopin wrote:
> I'm trying to archive the majority of my RTOS project ( 
> https://github.com/DISTORTEC/distortos ) as a static library. It works with 
> every single source/object file except for the files where I override (or 
> provide) syscalls.
> 
> If I link with the syscalls files as objects (not archived) and the archive 
> with rest of the code, then everything is fine.
> 
> If I want to link with the syscalls archived I get the following error:
> 
> > /home/freddie/gcc-arm-none-eabi-4_9-150626/bin/../lib/gcc/arm-none-eabi/4.9.
> > 3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg.a(lib_a-signalr.o): In
> > function `_kill_r':
> > /home/freddie/bleeding-edge-toolchain/src/newlib/newlib/libc/reent/signalr.
> > c:61: undefined reference to `_kill'
> > /home/freddie/gcc-arm-none-eabi-4_9-150626/bin/../lib/gcc/arm-none-eabi/4.9
> > .3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg.a(lib_a-signalr.o): In
> > function `_getpid_r':
> > /home/freddie/bleeding-edge-toolchain/src/newlib/newlib/libc/reent/signalr.
> > c:96: undefined reference to `_getpid'
> > /home/freddie/gcc-arm-none-eabi-4_9-150626/bin/../lib/gcc/arm-none-eabi/4.9
> > .3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libg.a(lib_a-sbrkr.o): In
> > function `_sbrk_r':
> > /home/freddie/bleeding-edge-toolchain/src/newlib/newlib/libc/reent/sbrkr.c:
> > 58: undefined reference to `_sbrk'
> > collect2: error: ld returned 1 exit status
> 
> The problem is that my own _sbrk_r() from the archive is discarded and the 
> function from libg.a is used (a wrapper for _sbrk())... Is there any (possibly 
> simple and generic) way to solve it? Maybe I'm missing some command line 
> switch or a command in linker script? I've tried grouping (via command line 
> and in linker script) or forcing _sbrk_r() to be initially undefined with 
> EXTERN(_sbrk_r) in the linker script, but this didn't change much. However - I 
> might have done something wrong...
> 
> It works if I explicitly call any of the functions from the code that is 
> linked as objects (so not from any source that goes into the archive), but 
> that can hardly be considered a solution...

what you describe is expected linker behavior -- when you have an archive
of objects, then things get pulled out only when explicitly requested.
you should post to the binutils mailing list to ask for suggestions as
this is not specific to newlib.
-mike

Attachment: signature.asc
Description: Digital signature


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