I experienced an odd intermittent problem where calling certain functions would suddenly cause the following errors to appear:
Code: Select all
/usr/lib/gcc/arm-none-eabi/4.8/../../../arm-none-eabi/lib/armv6-m/libg.a(lib_a-abort.o): In function `abort':
/build/buildd/newlib-2.1.0+git20140818.1a8323b/build/arm-none-eabi/armv6-m/newlib/libc/stdlib/../../../../../../newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
/usr/lib/gcc/arm-none-eabi/4.8/../../../arm-none-eabi/lib/armv6-m/libg.a(lib_a-signalr.o): In function `_kill_r':
/build/buildd/newlib-2.1.0+git20140818.1a8323b/build/arm-none-eabi/armv6-m/newlib/libc/reent/../../../../../../newlib/libc/reent/signalr.c:61: undefined reference to `_kill'
/usr/lib/gcc/arm-none-eabi/4.8/../../../arm-none-eabi/lib/armv6-m/libg.a(lib_a-signalr.o): In function `_getpid_r':
/build/buildd/newlib-2.1.0+git20140818.1a8323b/build/arm-none-eabi/armv6-m/newlib/libc/reent/../../../../../../newlib/libc/reent/signalr.c:96: undefined reference to `_getpid'
Defining stubs for those functions in my main file or adding syscalls_cpp.cpp to the project just changed the errors to the following:
Code: Select all
`_exit' referenced in section `.text.abort' of /usr/lib/gcc/arm-none-eabi/4.8/../../../arm-none-eabi/lib/armv6-m/libg.a(lib_a-abort.o): defined in discarded section `.text' of build/obj/syscalls_cpp.o (symbol from plugin)
`_kill' referenced in section `.text._kill_r' of /usr/lib/gcc/arm-none-eabi/4.8/../../../arm-none-eabi/lib/armv6-m/libg.a(lib_a-signalr.o): defined in discarded section `.text' of build/obj/syscalls_cpp.o (symbol from plugin)
`_getpid' referenced in section `.text._getpid_r' of /usr/lib/gcc/arm-none-eabi/4.8/../../../arm-none-eabi/lib/armv6-m/libg.a(lib_a-signalr.o): defined in discarded section `.text' of build/obj/syscalls_cpp.o (symbol from plugin)
It appears that the -02 optimization level (default in the makefile, right?) is cutting out the stubs from the wrapper before they can be linked to. This can be avoided (for GCC at least) by adding the __attribute__((used)) tag to each of the 3 function definitions in syscalls_cpp.cpp.
If I may ask, would it be possible to incorporate that change into the ChibiOS code? If so, what is the best way to post any future bug fixes (Github is read-only)?
Thanks!
Charlie West