linker: use UTIL_LISTIFY macro for dealing with .a files

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2017-10-31 09:30:38 -04:00 committed by Anas Nashif
commit 0a4808b75c
2 changed files with 148 additions and 2 deletions

View file

@ -21,6 +21,7 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <misc/util.h>
/* include platform dependent linker-defs */
#ifdef CONFIG_X86
@ -102,9 +103,24 @@
__shell_cmd_end = .;
#ifdef CONFIG_APPLICATION_MEMORY
#define KERNEL_INPUT_SECTION(sect) libzephyr.a (sect) kernel/lib.a (sect)
#ifndef NUM_KERNEL_OBJECT_FILES
#error "Expected NUM_KERNEL_OBJECT_FILES to be defined"
#elif NUM_KERNEL_OBJECT_FILES > 19
#error "Max supported kernel objects is 19."
/* 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 (*libzephyr.a *kernel/lib.a) sect)
*(EXCLUDE_FILE (UTIL_LISTIFY(NUM_KERNEL_OBJECT_FILES, Y, ~)) sect)
#else
#define KERNEL_INPUT_SECTION(sect) *(sect)
#define APP_INPUT_SECTION(sect) *(sect)