missing newlib stubs

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

missing newlib stubs

Post by JoVM »

I'm using arm-none-eabi 4.9.3. I add syscalls.c as my glibc stubs but the linker complaines it can't find 'abort' '_kill_r' '_getpid_r'. Is there another libc stub file?



Kr,Jo

@update: I find the missing stubs. They are zipped in this post viewtopic.php?f=3&t=422
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: missing newlib stubs

Post by Giovanni »

That file is not complete, this is a pending task.

Giovanni
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

Re: missing newlib stubs

Post by JoVM »

I use 'assert' function only from glibc.
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

Re: missing newlib stubs

Post by JoVM »

I started to use libgc alloc functions with result:

When I use linker opt -LOPT I get an error:
`_sbrk_r' referenced in section `.text._malloc_r' of c:/program files/gnu tools arm embedded/4.9 2014q4/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-mallocr.o): defined in discarded section `.text' of build/obj/syscalls.o (symbol from plugin)

Are the syscalls optimized away?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: missing newlib stubs

Post by Giovanni »

Not sure, does the compiler provide its own implementations in library? I will have to update that module...

Giovanni
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

Re: missing newlib stubs

Post by JoVM »

@Giovanni

Nope, linker need stubs from external source. For some reason gcc linker optimize away trivial piece of code.
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

Re: missing newlib stubs

Post by JoVM »

It is the link time optimization -flto. If I remove this option I can compile libgc alloc functions.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: missing newlib stubs

Post by Giovanni »

I agree, if you don't use any function that use those functions then LTO removes everything.

Giovanni
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

Re: missing newlib stubs

Post by JoVM »

@note I use arm none eabi gcc version 4.9.3 20141119
hyOzd
Posts: 20
Joined: Tue Jul 21, 2015 12:17 pm
Has thanked: 1 time
Been thanked: 2 times

Re: missing newlib stubs

Post by hyOzd »

JoVM wrote:I started to use libgc alloc functions with result:

When I use linker opt -LOPT I get an error:
`_sbrk_r' referenced in section `.text._malloc_r' of c:/program files/gnu tools arm embedded/4.9 2014q4/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-mallocr.o): defined in discarded section `.text' of build/obj/syscalls.o (symbol from plugin)

Are the syscalls optimized away?


I have a very similar error (trying to use sscanf function).

Code: Select all

`_sbrk_r' referenced in section `.text._malloc_trim_r' of /usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/libg.a(lib_a-freer.o): defined in discarded section `.text' of build/obj/syscalls.o (symbol from plugin)
`_sbrk_r' referenced in section `.text._malloc_trim_r' of /usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/libg.a(lib_a-freer.o): defined in discarded section `.text' of build/obj/syscalls.o (symbol from plugin)
`_sbrk_r' referenced in section `.text._malloc_trim_r' of /usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/libg.a(lib_a-freer.o): defined in discarded section `.text' of build/obj/syscalls.o (symbol from plugin)
`_sbrk_r' referenced in section `.text._malloc_r' of /usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/libg.a(lib_a-mallocr.o): defined in discarded section `.text' of build/obj/syscalls.o (symbol from plugin)
`_sbrk_r' referenced in section `.text._malloc_r' of /usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/libg.a(lib_a-mallocr.o): defined in discarded section `.text' of build/obj/syscalls.o (symbol from plugin)


Disabling linker optimization (USE_LTO = no) works. But is there another alternative? I'm just wondering how can I use these stubs with optimization enabled.
Post Reply