From 2b76f0fee2f20d3c969e514c0e71b7c80e3dd9d5 Mon Sep 17 00:00:00 2001 From: Evgeniy Paltsev Date: Fri, 23 Apr 2021 15:55:53 +0300 Subject: [PATCH] init: tweak Zephyr .init* section name conflicting with toolchain In case of ARC MWDT toolchain and C++ support enabled the Zephyr .init* section conflicts with .init* sections derived from toolchain libs. Let's add 'z_' prefix to Zephyr .init* section (and therefore .device section as they share the same macros) to make Zephyr section name unique. Signed-off-by: Evgeniy Paltsev --- include/device.h | 2 +- include/init.h | 2 +- include/linker/common-rom.ld | 4 ++-- include/linker/linker-defs.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/device.h b/include/device.h index 03ff44f75d3..5a3e9d8c99d 100644 --- a/include/device.h +++ b/include/device.h @@ -1040,7 +1040,7 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts"); COND_CODE_1(DT_NODE_EXISTS(node_id), (), (static)) \ const Z_DECL_ALIGN(struct device) \ DEVICE_NAME_GET(dev_name) __used \ - __attribute__((__section__(".device_" #level STRINGIFY(prio)"_"))) = { \ + __attribute__((__section__(".z_device_" #level STRINGIFY(prio)"_"))) = { \ .name = drv_name, \ .config = (cfg_ptr), \ .api = (api_ptr), \ diff --git a/include/init.h b/include/init.h index 4bff15f07e3..96352ffaaa1 100644 --- a/include/init.h +++ b/include/init.h @@ -85,7 +85,7 @@ void z_sys_init_run_level(int32_t level); #define Z_INIT_ENTRY_DEFINE(_entry_name, _init_fn, _device, _level, _prio) \ static const Z_DECL_ALIGN(struct init_entry) \ _CONCAT(__init_, _entry_name) __used \ - __attribute__((__section__(".init_" #_level STRINGIFY(_prio)"_"))) = { \ + __attribute__((__section__(".z_init_" #_level STRINGIFY(_prio)"_"))) = { \ .init = (_init_fn), \ .dev = (_device), \ } diff --git a/include/linker/common-rom.ld b/include/linker/common-rom.ld index 5642e7be662..9efd49c0fbf 100644 --- a/include/linker/common-rom.ld +++ b/include/linker/common-rom.ld @@ -30,10 +30,10 @@ } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) #endif - /* verify we don't have rogue .init_ initlevel sections */ + /* verify we don't have rogue .z_init_ initlevel sections */ SECTION_PROLOGUE(initlevel_error,,) { - KEEP(*(SORT(.init_[_A-Z0-9]*))) + KEEP(*(SORT(.z_init_[_A-Z0-9]*))) } ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.") diff --git a/include/linker/linker-defs.h b/include/linker/linker-defs.h index 9a64d71a3c9..8a79a7f3983 100644 --- a/include/linker/linker-defs.h +++ b/include/linker/linker-defs.h @@ -116,8 +116,8 @@ */ #define CREATE_OBJ_LEVEL(object, level) \ __##object##_##level##_start = .; \ - KEEP(*(SORT(.object##_##level[0-9]_*))); \ - KEEP(*(SORT(.object##_##level[1-9][0-9]_*))); + KEEP(*(SORT(.z_##object##_##level[0-9]_*))); \ + KEEP(*(SORT(.z_##object##_##level[1-9][0-9]_*))); /* * link in shell initialization objects for all modules that use shell and