linker: Re-implement {APP,KERNEL}_INPUT_SECTION
This rewrites the implementation of the APP_INPUT_SECTION and KERNEL_INPUT_SECTION macros such that an unbounded amount of kernelspace libraries can be used. This resolves #7703 The new implementation has a caveat/limitation; the linker script developer must invoke APP_INPUT_SECTION before KERNEL_INPUT_SECTION. All in-tree linker scripts happened to already be doing this so no in-tree porting was necessary. Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
parent
964f6dc626
commit
cbe7b4fb74
2 changed files with 22 additions and 30 deletions
|
@ -618,15 +618,14 @@ if(CONFIG_APPLICATION_MEMORY)
|
|||
list(APPEND ks ${fixed_path})
|
||||
endforeach()
|
||||
|
||||
# We are done constructing kernel_object_file_list, now we inject this
|
||||
# information into the linker script through -D's
|
||||
list(LENGTH kernel_object_file_list NUM_KERNEL_OBJECT_FILES)
|
||||
list(APPEND LINKER_SCRIPT_DEFINES -DNUM_KERNEL_OBJECT_FILES=${NUM_KERNEL_OBJECT_FILES})
|
||||
set(i 0)
|
||||
# We are done constructing kernel_object_file_list, now we inject
|
||||
# this list into the linker script through the define
|
||||
# KERNELSPACE_OBJECT_FILES
|
||||
set(def -DKERNELSPACE_OBJECT_FILES=)
|
||||
foreach(f ${ks})
|
||||
list(APPEND LINKER_SCRIPT_DEFINES -DKERNEL_OBJECT_FILE_${i}=${f})
|
||||
math(EXPR i "${i}+1")
|
||||
set(def "${def} ${f}")
|
||||
endforeach()
|
||||
list(APPEND LINKER_SCRIPT_DEFINES ${def})
|
||||
endif() # CONFIG_APPLICATION_MEMORY
|
||||
|
||||
# Declare MPU userspace dependencies before the linker scripts to make
|
||||
|
|
|
@ -112,34 +112,27 @@
|
|||
* their shell commands are automatically initialized by the kernel.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_APPLICATION_MEMORY
|
||||
/*
|
||||
* KERNELSPACE_OBJECT_FILES is a space-separated list of object files
|
||||
* and libraries that belong in kernelspace.
|
||||
*/
|
||||
#define MAYBE_EXCLUDE_SOME_FILES EXCLUDE_FILE (KERNELSPACE_OBJECT_FILES)
|
||||
#else
|
||||
#define MAYBE_EXCLUDE_SOME_FILES
|
||||
#endif /* CONFIG_APPLICATION_MEMORY */
|
||||
|
||||
/*
|
||||
* APP_INPUT_SECTION should be invoked on sections that should be in
|
||||
* 'app' space. KERNEL_INPUT_SECTION should be invoked on sections
|
||||
* that should be in 'kernel' space.
|
||||
*
|
||||
* NB: APP_INPUT_SECTION must be invoked before
|
||||
* KERNEL_INPUT_SECTION. If it is not all sections will end up in
|
||||
* kernelspace.
|
||||
*/
|
||||
#ifdef CONFIG_APPLICATION_MEMORY
|
||||
|
||||
#ifndef NUM_KERNEL_OBJECT_FILES
|
||||
#error "Expected NUM_KERNEL_OBJECT_FILES to be defined"
|
||||
#elif NUM_KERNEL_OBJECT_FILES > 32
|
||||
#error "Max supported kernel objects is 32."
|
||||
/* TODO: Using the preprocessor to do this was a mistake. Rewrite to
|
||||
scale better. e.g. by aggregating the kernel objects into two
|
||||
archives like KBuild did.*/
|
||||
#endif
|
||||
|
||||
#define X(i, j) KERNEL_OBJECT_FILE_##i (j)
|
||||
#define Y(i, j) KERNEL_OBJECT_FILE_##i
|
||||
|
||||
#define KERNEL_INPUT_SECTION(sect) \
|
||||
UTIL_LISTIFY(NUM_KERNEL_OBJECT_FILES, X, sect)
|
||||
#define APP_INPUT_SECTION(sect) \
|
||||
*(EXCLUDE_FILE (UTIL_LISTIFY(NUM_KERNEL_OBJECT_FILES, Y, ~)) sect)
|
||||
|
||||
#else
|
||||
#define KERNEL_INPUT_SECTION(sect) *(sect)
|
||||
#define APP_INPUT_SECTION(sect) *(sect)
|
||||
#endif /* CONFIG_APPLICATION_MEMORY */
|
||||
#define APP_INPUT_SECTION(sect) *(MAYBE_EXCLUDE_SOME_FILES sect)
|
||||
#define KERNEL_INPUT_SECTION(sect) *(sect)
|
||||
|
||||
#define APP_SMEM_SECTION() KEEP(*(SORT(data_smem_[_a-zA-Z0-9]*)))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue