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
missing newlib stubs
Moderators: RoccoMarco, lbednarz, tfAteba
- 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
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?
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?
- 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
Not sure, does the compiler provide its own implementations in library? I will have to update that module...
Giovanni
Giovanni
Re: missing newlib stubs
@Giovanni
Nope, linker need stubs from external source. For some reason gcc linker optimize away trivial piece of code.
Nope, linker need stubs from external source. For some reason gcc linker optimize away trivial piece of code.
Re: missing newlib stubs
It is the link time optimization -flto. If I remove this option I can compile libgc alloc functions.
- 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
I agree, if you don't use any function that use those functions then LTO removes everything.
Giovanni
Giovanni
Re: missing newlib stubs
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.