Page 1 of 2
missing newlib stubs
Posted: Sun Mar 15, 2015 11:12 am
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
Re: missing newlib stubs
Posted: Sun Mar 15, 2015 12:46 pm
by Giovanni
That file is not complete, this is a pending task.
Giovanni
Re: missing newlib stubs
Posted: Sun Mar 15, 2015 1:08 pm
by JoVM
I use 'assert' function only from glibc.
Re: missing newlib stubs
Posted: Wed Apr 01, 2015 1:36 pm
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?
Re: missing newlib stubs
Posted: Wed Apr 01, 2015 3:16 pm
by Giovanni
Not sure, does the compiler provide its own implementations in library? I will have to update that module...
Giovanni
Re: missing newlib stubs
Posted: Wed Apr 01, 2015 5:11 pm
by JoVM
@Giovanni
Nope, linker need stubs from external source. For some reason gcc linker optimize away trivial piece of code.
Re: missing newlib stubs
Posted: Wed Apr 01, 2015 5:21 pm
by JoVM
It is the link time optimization -flto. If I remove this option I can compile libgc alloc functions.
Re: missing newlib stubs
Posted: Wed Apr 01, 2015 6:00 pm
by Giovanni
I agree, if you don't use any function that use those functions then LTO removes everything.
Giovanni
Re: missing newlib stubs
Posted: Thu Apr 02, 2015 7:43 am
by JoVM
@note I use arm none eabi gcc version 4.9.3 20141119
Re: missing newlib stubs
Posted: Wed Aug 12, 2015 2:33 pm
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.