Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,14 @@ if(CONFIG_BUILD_PROTECTED)
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 "")
# deleted Toolchain link options
get_target_property(nuttx_user_LINK_OPTIONS nuttx_user LINK_OPTIONS)
list(REMOVE_ITEM nuttx_user_LINK_OPTIONS "-Wl,--gc-sections")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not skip adding these option instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not skip adding these option instead

These link options is set in the Toolchain file and has global scope.
they are also required by the nuttx target.but the timing of setting the Toolchain file is before all targets.
so it cannot be distinguished by USER_LINK_OPTION and NUTTX_LINK_OPTION like Makefile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why these options can't be used with uerspace.bin

Copy link
Contributor

@yf13 yf13 Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how @xuxin930 identified them. My test shows that the gc-sections will cause user space ELF lacking things required by kernel side, thus can't boot the target. The -Map=nuttx.map name conflicts with that of kernel. As these global settings are for kernel, adjusting them for userspace looks reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xuxin930 let's split the hack to a new pr

list(REMOVE_ITEM nuttx_user_LINK_OPTIONS "-Wl,--cref")
list(REMOVE_ITEM nuttx_user_LINK_OPTIONS "-Wl,-Map=nuttx.map")
list(REMOVE_ITEM nuttx_user_LINK_OPTIONS "-Wl,--entry=__start")
set_target_properties(nuttx_user PROPERTIES LINK_OPTIONS
"${nuttx_user_LINK_OPTIONS}")

target_link_options(
nuttx_user PRIVATE -nostartfiles -nodefaultlibs
Expand Down
7 changes: 7 additions & 0 deletions boards/risc-v/k230/canmv230/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@
# ##############################################################################

add_subdirectory(src)

if(CONFIG_BUILD_PROTECTED)
add_subdirectory(kernel)
set_property(
GLOBAL PROPERTY LD_SCRIPT_USER
${CMAKE_CURRENT_LIST_DIR}/scripts/ld-userland.script)
endif()
23 changes: 23 additions & 0 deletions boards/risc-v/k230/canmv230/kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ##############################################################################
# boards/risc-v/k230/canmv230/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_link_options(nuttx_user PRIVATE "-Wl,-melf64lriscv")

target_sources(nuttx_user PRIVATE k230_userspace.c)
14 changes: 6 additions & 8 deletions libs/libc/spawn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,21 @@ set(SRCS
lib_psa_getschedparam.c
lib_psa_getschedpolicy.c
lib_psa_init.c
lib_psa_destroy.c
lib_psa_setflags.c
lib_psa_setschedparam.c
lib_psa_setschedpolicy.c
lib_psa_getsigmask.c
lib_psa_setsigmask.c)

if(CONFIG_DEBUG_FEATURES)
list(APPEND SRCS lib_psfa_dump.c)
endif()
lib_psa_setsigmask.c
lib_psa_getstacksize.c
lib_psa_setstacksize.c
lib_psa_destroy.c)

if(NOT CONFIG_BUILD_KERNEL)
list(APPEND SRCS lib_psa_getstacksize.c lib_psa_setstacksize.c)
list(APPEND SRCS lib_psa_getstackaddr.c lib_psa_setstackaddr.c)
endif()

if(CONFIG_DEBUG_FEATURES)
list(APPEND SRCS lib_psa_dump.c)
list(APPEND SRCS lib_psfa_dump.c lib_psa_dump.c)
endif()

target_sources(c PRIVATE ${SRCS})