Build: Expose symbols SECTION_start and SECTION_size for embedded resources.

Resources embedded by the embed_resource() function will now also expose
a SECTION_start and SECTION_size symbol so the embedded resource can be found
by an application without having to parse its own ELF image which is not
something applications can currently do from userspace.
This commit is contained in:
William Marlow 2020-12-29 12:38:14 +00:00 committed by Andreas Kling
commit 91b65ec328
Notes: sideshowbarker 2024-07-19 17:30:49 +09:00
2 changed files with 19 additions and 5 deletions

View file

@ -118,9 +118,10 @@ function(embed_resource target section file)
get_filename_component(asm_file "${file}" NAME)
set(asm_file "${CMAKE_CURRENT_BINARY_DIR}/${target}-${section}.s")
get_filename_component(input_file "${file}" ABSOLUTE)
file(SIZE "${input_file}" file_size)
add_custom_command(
OUTPUT "${asm_file}"
COMMAND "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}"
COMMAND "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}" "${file_size}"
DEPENDS "${input_file}" "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh"
COMMENT "Generating ${asm_file}"
)