Skip to content

Commit 1f4d121

Browse files
committed
linker: update section names to be unambiguous
Recently 0ae0c3d allowed for three digit priorities, this resulted in objects potentially matching multiple sections, for example: .z_init_PRE_KERNEL_2_0_0_ .z_init_PRE_KERNEL_2_?_* .z_init_PRE_KERNEL_2_???_* This does not seem to be detected by ld, but the IAR linker emits a warning. Add some extra qualifiers in the object section name to make it unambiguous, this has the extra value of making it easier to interpret, for example going from: .z_init_POST_KERNEL_90_00012_ to .z_init_POST_KERNEL_P_90_SUB_00012_ Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
1 parent 1bdffce commit 1f4d121

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

cmake/modules/extensions.cmake

+5-5
Original file line numberDiff line numberDiff line change
@@ -5240,8 +5240,8 @@ endfunction()
52405240
# This is useful content such as struct devices.
52415241
#
52425242
# For example: zephyr_linker_section_obj_level(SECTION init LEVEL PRE_KERNEL_1)
5243-
# will create an input section matching `.z_init_PRE_KERNEL_1_?_`,
5244-
# `.z_init_PRE_KERNEL_1_??_`, and `.z_init_PRE_KERNEL_1_???_`.
5243+
# will create an input section matching `.z_init_PRE_KERNEL_P_1_SUB_?_`,
5244+
# `.z_init_PRE_KERNEL_P_1_SUB_??_`, and `.z_init_PRE_KERNEL_P_1_SUB_???_`.
52455245
#
52465246
# SECTION <section>: Section in which the objects shall be placed
52475247
# LEVEL <level> : Priority level, all input sections matching the level
@@ -5265,18 +5265,18 @@ function(zephyr_linker_section_obj_level)
52655265

52665266
zephyr_linker_section_configure(
52675267
SECTION ${OBJ_SECTION}
5268-
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_?_*"
5268+
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_P_?_*"
52695269
SYMBOLS __${OBJ_SECTION}_${OBJ_LEVEL}_start
52705270
KEEP SORT NAME
52715271
)
52725272
zephyr_linker_section_configure(
52735273
SECTION ${OBJ_SECTION}
5274-
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_??_*"
5274+
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_P_??_*"
52755275
KEEP SORT NAME
52765276
)
52775277
zephyr_linker_section_configure(
52785278
SECTION ${OBJ_SECTION}
5279-
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_???_*"
5279+
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_P_???_*"
52805280
KEEP SORT NAME
52815281
)
52825282
endfunction()

include/zephyr/init.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct init_entry {
110110
*/
111111
#define Z_INIT_ENTRY_SECTION(level, prio, sub_prio) \
112112
__attribute__(( \
113-
__section__(".z_init_" #level "_" STRINGIFY(prio)"_" STRINGIFY(sub_prio)"_")))
113+
__section__(".z_init_" #level "_P_" STRINGIFY(prio) "_SUB_" STRINGIFY(sub_prio)"_")))
114114

115115
/** @endcond */
116116

include/zephyr/linker/linker-defs.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
/* clang-format off */
4848
#define CREATE_OBJ_LEVEL(object, level) \
4949
__##object##_##level##_start = .; \
50-
KEEP(*(SORT(.z_##object##_##level##_?_*))); \
51-
KEEP(*(SORT(.z_##object##_##level##_??_*))); \
52-
KEEP(*(SORT(.z_##object##_##level##_???_*)));
50+
KEEP(*(SORT(.z_##object##_##level##_P_?_*))); \
51+
KEEP(*(SORT(.z_##object##_##level##_P_??_*))); \
52+
KEEP(*(SORT(.z_##object##_##level##_P_???_*)));
5353
/* clang-format on */
5454

5555
/*

0 commit comments

Comments
 (0)