Skip to content

Commit

Permalink
cmake: new global property for generated files
Browse files Browse the repository at this point in the history
Introduce a new global property for source files that are generated from
the initial Zephyr link (app_smem_unaligned_prebuilt). This source list
is used for files which will introduce address shifts into the final
binary, which need to be present in `zephyr_prebuilt.elf` for
`CONFIG_USERSPACE` scripts to correctly generate `zephyr.elf`.

This resolves zephyrproject-rtos#38836.

Signed-off-by: Jordan Yates <[email protected]>
  • Loading branch information
Jordan Yates authored and tejlmand committed Nov 8, 2021
1 parent 60a2449 commit 1968f79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ if(CONFIG_USERSPACE)
endif()

# Read global variables into local variables
get_property(GASF GLOBAL PROPERTY GENERATED_APP_SOURCE_FILES)
get_property(GKOF GLOBAL PROPERTY GENERATED_KERNEL_OBJECT_FILES)
get_property(GKSF GLOBAL PROPERTY GENERATED_KERNEL_SOURCE_FILES)

Expand Down Expand Up @@ -1226,7 +1227,7 @@ set_property(TARGET
)

# FIXME: Is there any way to get rid of empty_file.c?
add_executable( ${ZEPHYR_PREBUILT_EXECUTABLE} misc/empty_file.c)
add_executable( ${ZEPHYR_PREBUILT_EXECUTABLE} misc/empty_file.c ${GASF})
toolchain_ld_link_elf(
TARGET_ELF ${ZEPHYR_PREBUILT_EXECUTABLE}
OUTPUT_MAP ${PROJECT_BINARY_DIR}/${ZEPHYR_PREBUILT_EXECUTABLE}.map
Expand Down Expand Up @@ -1275,7 +1276,7 @@ else()
${ZEPHYR_INCLUDE_DIRS}
)

add_executable( ${ZEPHYR_FINAL_EXECUTABLE} misc/empty_file.c ${GKSF})
add_executable( ${ZEPHYR_FINAL_EXECUTABLE} misc/empty_file.c ${GASF} ${GKSF})
toolchain_ld_link_elf(
TARGET_ELF ${ZEPHYR_FINAL_EXECUTABLE}
OUTPUT_MAP ${PROJECT_BINARY_DIR}/${ZEPHYR_FINAL_EXECUTABLE}.map
Expand Down
8 changes: 8 additions & 0 deletions cmake/app/boilerplate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ define_property(GLOBAL PROPERTY ZEPHYR_INTERFACE_LIBS
zephyr_interface_library_named() appends libs to this list.")
set_property(GLOBAL PROPERTY ZEPHYR_INTERFACE_LIBS "")

define_property(GLOBAL PROPERTY GENERATED_APP_SOURCE_FILES
BRIEF_DOCS "Source files that are generated after Zephyr has been linked once."
FULL_DOCS "\
Source files that are generated after Zephyr has been linked once.\
May include dev_handles.c etc."
)
set_property(GLOBAL PROPERTY GENERATED_APP_SOURCE_FILES "")

define_property(GLOBAL PROPERTY GENERATED_KERNEL_OBJECT_FILES
BRIEF_DOCS "Object files that are generated after symbol addresses are fixed."
FULL_DOCS "\
Expand Down

0 comments on commit 1968f79

Please sign in to comment.