This is the mail archive of the mailing list for the binutils 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]

Archive (library) which overrides syscalls from toolchain's archive?


I'm trying to archive the majority of my RTOS project ( ) as a static library. It works with 
every single source/object file except for the files where I override (or 
provide) newlib's syscalls ( 
). The toolchain I am using is targeting ARM microcontrollers (arm-none-
eabi-). Newlib's syscalls are functions like _sbrk_r(), _write_r(), _open_r() 
that are used internally by various other functions (malloc(), printf(), 
fopen(), ...). There are maybe a dozen syscalls that need to be overridden.

If I link with my syscalls files as objects (not archived) and the archive 
with rest of the code, then everything is fine - my own syscalls get 
precedence and replace the stubs from the toolchain's archives.

If I want to link with my 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 stub 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...

Basically I'm looking for a way to just force some functions to be taken from 
designated archive.

Thanks in advance for any help!

Freddie Chopin

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