If I follow you correctly you are trying to replace the startup files that
are normally used with your own versions.

You don't mention what the new library is that you are using to replace the
startup files.
The standard startup files provide _init and _fini.

You are also missing _exit which I thought would have been taken care of if
"-specs=nosys.specs" was being used.  It's not shown which specs option is
being used.

Any reason you aren't just using the standard startup files and follow the
retarget example to do any special initialization before main() is called?

On Fri, Feb 1, 2019 at 6:17 PM Kyle Edwards via CMake <cmake@cmake.org>
wrote:

> Hex,
>
> Can you see what else is in /opt/arm-none-eabi/lib/thumb/v7-ar/fpv3/hard
> (the same directory as libc.a)? There might be another system library that
> contains the _exit() implementation that isn't being linked due to your use
> of the -nostartfiles flag.
>
> Kyle
>
> On Fri, 2019-02-01 at 22:15 +0000, hex wrote:
>
> hello,
>
> I am trying to include a static library that contains the startup code for
> ARM processor to my  CMake project for cross compilation.
>
> I included the linker script and added it to the executable. Flags and
> include files are properly set in the CMake build output. The path to the
> library is also correctly seen.
>
> The linker fails on the startup code:
>
>
> Scanning dependencies of target testApp
> [ 50%] Building CXX object CMakeFiles/testApp.dir/src/main.c.obj
> [100%] Linking CXX executable testApp
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-exit.o):
>  In function `exit':
> exit.c:(.text.exit+0x1c): undefined reference to `_exit'
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-fini.o):
>  In function `__libc_fini_array':
> fini.c:(.text.__libc_fini_array+0x2c): undefined reference to `_fini'
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-init.o):
>  In function `__libc_init_array':
> init.c:(.text.__libc_init_array+0x38): undefined reference to `_init'
> collect2: error: ld returned 1 exit status
>
>
> Here is my CMakeLists file:
> *cmake_minimum_required(VERSION 3.5.1)**project 
> (hello-world)**set(SOURCE_FILES src/main.c)**set (LINKER_SCRIPT 
> linker_script.ld)**add_executable(${TARGET_NAME} 
> ${SOURCE_FILES})**set_target_properties( ${TARGET_NAME} PROPERTIES 
> LINK_DEPENDS ${LINKER_SCRIPT})**set(CMAKE_EXE_LINKER_FLAGS 
> "${CMAKE_EXE_LINKER_FLAGS} -Wl,-build-id=none -Wl,-T ${LINKER_SCRIPT} " CACHE 
> STRING "" FORCE )**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -march=armv7-a")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -mfpu=vfpv3")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -mfloat-abi=hard")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -Wall")**set(COMMON_FLAGS "${COMMON_FLAGS} -O0")**set(COMMON_FLAGS 
> "${COMMON_FLAGS} -nostartfiles")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -fmessage-length=0")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -fno-exceptions")**set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} 
> ${COMMON_FLAGS}")**set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} 
> ${COMMON_FLAGS}")**include_directories( inc )**find_library(LIB_C NAMES libc 
> PATHS "lib" )**target_link_libraries(${TARGET_NAME} ${LIB_C})*
>
> How can I solve this problem? The only dependency here is the library 
> itself...
>
> Thank you in advance for any response.
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to 
> subscribe/unsubscribe:https://cmake.org/mailman/listinfo/cmake
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to