mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
cmake:init protected-mode for CMake build
adjust link options for userspace elf specify system libs and apps lib to only link with nuttx target in flat build mode Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
+20
-8
@@ -416,6 +416,10 @@ include(platform)
|
|||||||
# Setup main nuttx target ####################################################
|
# Setup main nuttx target ####################################################
|
||||||
|
|
||||||
add_executable(nuttx)
|
add_executable(nuttx)
|
||||||
|
if(CONFIG_BUILD_PROTECTED)
|
||||||
|
add_executable(nuttx_user)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_dependencies(nuttx nuttx_context)
|
add_dependencies(nuttx nuttx_context)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@@ -604,9 +608,6 @@ get_property(nuttx_extra_libs GLOBAL PROPERTY NUTTX_EXTRA_LIBRARIES)
|
|||||||
|
|
||||||
if(CONFIG_BUILD_FLAT)
|
if(CONFIG_BUILD_FLAT)
|
||||||
get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
|
get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT CONFIG_BUILD_KERNEL)
|
|
||||||
get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES)
|
get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -742,25 +743,36 @@ endif()
|
|||||||
# Userspace portion ##########################################################
|
# Userspace portion ##########################################################
|
||||||
|
|
||||||
if(CONFIG_BUILD_PROTECTED)
|
if(CONFIG_BUILD_PROTECTED)
|
||||||
add_executable(nuttx_user)
|
|
||||||
|
|
||||||
get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
|
get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
|
||||||
|
|
||||||
|
get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES)
|
||||||
|
|
||||||
get_property(user_ldscript GLOBAL PROPERTY LD_SCRIPT_USER)
|
get_property(user_ldscript GLOBAL PROPERTY LD_SCRIPT_USER)
|
||||||
list(TRANSFORM user_ldscript PREPEND "-Wl,--script=")
|
list(TRANSFORM user_ldscript PREPEND "-Wl,--script=")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
|
||||||
|
--print-libgcc-file-name
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
OUTPUT_VARIABLE nuttx_user_libgcc)
|
||||||
|
|
||||||
|
# reset link options for userspace to prevent sections from being accidentally
|
||||||
|
# deleted
|
||||||
|
set_target_properties(nuttx_user PROPERTIES LINK_OPTIONS "")
|
||||||
|
|
||||||
target_link_options(
|
target_link_options(
|
||||||
nuttx_user PRIVATE -nostartfiles -nodefaultlibs
|
nuttx_user PRIVATE -nostartfiles -nodefaultlibs
|
||||||
-Wl,--entry=${CONFIG_USER_ENTRYPOINT}
|
-Wl,--entry=${CONFIG_INIT_ENTRYPOINT}
|
||||||
-Wl,--undefined=${CONFIG_USER_ENTRYPOINT})
|
-Wl,--undefined=${CONFIG_INIT_ENTRYPOINT})
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
nuttx_user
|
nuttx_user
|
||||||
PRIVATE ${user_ldscript}
|
PRIVATE ${user_ldscript}
|
||||||
userspace
|
|
||||||
$<$<NOT:$<BOOL:${APPLE}>>:-Wl,--start-group>
|
$<$<NOT:$<BOOL:${APPLE}>>:-Wl,--start-group>
|
||||||
${nuttx_system_libs}
|
${nuttx_system_libs}
|
||||||
gcc
|
${nuttx_apps_libs}
|
||||||
|
${nuttx_user_libgcc}
|
||||||
$<$<BOOL:${CONFIG_HAVE_CXX}>:supc++>
|
$<$<BOOL:${CONFIG_HAVE_CXX}>:supc++>
|
||||||
$<$<NOT:$<BOOL:${APPLE}>>:-Wl,--end-group>)
|
$<$<NOT:$<BOOL:${APPLE}>>:-Wl,--end-group>)
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ if(CONFIG_BUILD_PROTECTED OR CONFIG_BUILD_KERNEL)
|
|||||||
list(APPEND SRCS arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c)
|
list(APPEND SRCS arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c)
|
||||||
|
|
||||||
if(CONFIG_BUILD_PROTECTED)
|
if(CONFIG_BUILD_PROTECTED)
|
||||||
list(APPEND SRCS ${ARCH_TOOLCHAIN_PATH}/arm_signal_handler.S)
|
target_sources(arch_interface
|
||||||
|
PRIVATE ${ARCH_TOOLCHAIN_PATH}/arm_signal_handler.S)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ endif()
|
|||||||
if(NOT CONFIG_BUILD_FLAT)
|
if(NOT CONFIG_BUILD_FLAT)
|
||||||
list(APPEND SRCS riscv_task_start.c riscv_pthread_start.c
|
list(APPEND SRCS riscv_task_start.c riscv_pthread_start.c
|
||||||
riscv_signal_dispatch.c)
|
riscv_signal_dispatch.c)
|
||||||
list(APPEND SRCS riscv_signal_handler.S)
|
target_sources(arch_interface PRIVATE riscv_signal_handler.S)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_BACKTRACE)
|
if(CONFIG_SCHED_BACKTRACE)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
if(NOT CONFIG_BUILD_FLAT)
|
if(CONFIG_BUILD_PROTECTED)
|
||||||
add_subdirectory(kernel)
|
add_subdirectory(kernel)
|
||||||
set_property(
|
set_property(
|
||||||
GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld
|
GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# ##############################################################################
|
||||||
|
# boards/arm/tiva/lm3s6965-ek/kernel/CMakeLists.txt
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# ##############################################################################
|
||||||
|
|
||||||
|
target_sources(nuttx_user PRIVATE lm_userspace.c)
|
||||||
Reference in New Issue
Block a user