device: add post-process of elf file to manage device handles

Following the idiom used for system calls, add script support to read
the initial application binary to identify which devices are defined,
and to use their offset in the device array as their unique handle
rather than the externally-defined ordinal from devicetree.  The
device dependency arrays are updated to use these handles.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-06-30 10:05:35 -05:00 committed by Anas Nashif
commit d554d34137
7 changed files with 390 additions and 5 deletions

View file

@ -180,3 +180,14 @@
} GROUP_LINK_IN(ROMABLE_REGION)
Z_ITERABLE_SECTION_ROM(tracing_backend, 4)
SECTION_DATA_PROLOGUE(device_handles,,)
{
__device_handles_start = .;
#ifdef LINKER_PASS2
KEEP(*(SORT(.__device_handles_pass2*)));
#else /* LINKER_PASS2 */
KEEP(*(SORT(.__device_handles_pass1*)));
#endif /* LINKER_PASS2 */
__device_handles_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)