diff --git a/arch/arm/src/cmake/elf.cmake b/arch/arm/src/cmake/elf.cmake index 67223df2511..c199c9a6fc2 100644 --- a/arch/arm/src/cmake/elf.cmake +++ b/arch/arm/src/cmake/elf.cmake @@ -35,3 +35,5 @@ nuttx_elf_link_options_ifdef(CONFIG_BINFMT_ELF_RELOCATABLE -r) nuttx_elf_link_options_ifdef(CONFIG_BUILD_KERNEL -Bstatic) nuttx_elf_link_options_ifdef(CONFIG_DEBUG_OPT_UNUSED_SECTIONS --gc-sections) + +nuttx_elf_link_options(-e __start) diff --git a/arch/arm64/src/cmake/elf.cmake b/arch/arm64/src/cmake/elf.cmake index 1e8dfb4218a..d0ce0a6db85 100644 --- a/arch/arm64/src/cmake/elf.cmake +++ b/arch/arm64/src/cmake/elf.cmake @@ -27,3 +27,5 @@ nuttx_elf_link_options_ifdef(CONFIG_BINFMT_ELF_RELOCATABLE -r) nuttx_elf_link_options_ifdef(CONFIG_BUILD_KERNEL -Bstatic) nuttx_elf_link_options_ifdef(CONFIG_DEBUG_OPT_UNUSED_SECTIONS --gc-sections) + +nuttx_elf_link_options(-e __start) diff --git a/arch/sim/src/cmake/Toolchain.cmake b/arch/sim/src/cmake/Toolchain.cmake index b5d87923a8c..cf91d6f4cd2 100644 --- a/arch/sim/src/cmake/Toolchain.cmake +++ b/arch/sim/src/cmake/Toolchain.cmake @@ -29,6 +29,12 @@ if(WIN32) return() endif() +if(CONFIG_HOST_LINUX) + set(CMAKE_LD ld) + set(CMAKE_PREPROCESSOR cc -E -P -x c) + set(CMAKE_STRIP strip --strip-unneeded) +endif() + # LLVM style architecture flags if(CONFIG_HOST_X86_64) if(CONFIG_SIM_M32) diff --git a/arch/sim/src/cmake/elf.cmake b/arch/sim/src/cmake/elf.cmake new file mode 100644 index 00000000000..dc2cca50a14 --- /dev/null +++ b/arch/sim/src/cmake/elf.cmake @@ -0,0 +1,29 @@ +# ############################################################################## +# arch/sim/src/cmake/elf.cmake +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +# Loadable and ELF module settings + +nuttx_elf_compile_options(-fvisibility=hidden -fno-pic) + +nuttx_elf_compile_options_ifdef(CONFIG_LIBC_ARCH_ELF_64BIT -mcmodel=large) + +nuttx_elf_link_options(-r -e main) + +nuttx_elf_link_options_ifdef(CONFIG_SIM_M32 -melf_i386) diff --git a/arch/x86_64/src/cmake/elf.cmake b/arch/x86_64/src/cmake/elf.cmake index 1bcbc42a88b..a5bcaa5e9f5 100644 --- a/arch/x86_64/src/cmake/elf.cmake +++ b/arch/x86_64/src/cmake/elf.cmake @@ -25,3 +25,5 @@ nuttx_elf_compile_options(-fvisibility=hidden -fno-pic -mcmodel=large) nuttx_elf_link_options(-r) nuttx_elf_link_options_ifdef(CONFIG_DEBUG_OPT_UNUSED_SECTIONS --gc-sections) + +nuttx_elf_link_options(-e __start) diff --git a/cmake/nuttx_add_application.cmake b/cmake/nuttx_add_application.cmake index 5a125590e51..1fd342bbfa0 100644 --- a/cmake/nuttx_add_application.cmake +++ b/cmake/nuttx_add_application.cmake @@ -131,8 +131,9 @@ function(nuttx_add_application) COMMAND ${CMAKE_LD} $> - -e __start -T ${CMAKE_BINARY_DIR}/gnu-elf.ld - $ --start-group + -T ${CMAKE_BINARY_DIR}/gnu-elf.ld + $<$:$> + --start-group $<$:$>> $> $ --end-group -o