Skip to content

Commit

Permalink
sim/cmake: add .scattered_array section inside .text section
Browse files Browse the repository at this point in the history
the ".scattered_array" section is required by optee_os,
optee_os will uniformly place all the functions that need to
be called during the system startup phase into the
`.scattered_array` section.
In order to enable optee_os to start up normally, we need to
addd this section to the linker script explicitly, otherwise the
function that put into `.scattered_array` section will be optimized
out during link procedure.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
  • Loading branch information
extinguish committed Dec 30, 2024
1 parent 2ca5156 commit b9d0cf7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmake/nuttx_generate_sim_ld.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ file(
DESTINATION ${CMAKE_BINARY_DIR}
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)

if(CONFIG_OPTEE_OS)
set(SIM_LD_ADD_SCATTERED_ARRAY_SECTION
" 's/\*\(.text.hot .text.hot.*\)/KEEP\(*\(SORT\(.scattered_array*\)\)\)\\n *\(.text.hot .text.hot.*\)/g' "
)
endif()

add_custom_command(
OUTPUT nuttx.ld
COMMAND
Expand All @@ -61,5 +67,6 @@ add_custom_command(
|| true
COMMAND sh process_sim_ld_script.sh nuttx-orig.ld nuttx.ld
COMMAND sed -i '/\\.data *:/i " ${CONFIG_SIM_CUSTOM_DATA_SECTION} " ' nuttx.ld
COMMAND sed -i " ${SIM_LD_ADD_SCATTERED_ARRAY_SECTION} " nuttx.ld
COMMENT "Generating sim linker script nuttx.ld"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

0 comments on commit b9d0cf7

Please sign in to comment.