net: Append device name to linker generated symbols for struct net_if

Before this change all struct net_if objects accessed by for example
net_if_get_by_index() are placed in one linker area (i.e. net_if_area)
with the same "name" - '_net_if.static.net_if'. This may cause problems
when the order of struct net_if elements is important.

With the same names for all elements there is no guarantee of placement
order. After this change the unique device name is appended, so
SORT_BY_NAME() linker command places objects in reproductible manner.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
This commit is contained in:
Lukasz Majewski 2021-03-30 12:23:00 +02:00 committed by Anas Nashif
commit 46ea8bf00c

View file

@ -2178,7 +2178,8 @@ struct net_if_api {
}; \
static Z_DECL_ALIGN(struct net_if) \
NET_IF_GET_NAME(dev_name, sfx)[_num_configs] \
__used __in_section(_net_if, static, net_if) = { \
__used __in_section(_net_if, static, \
dev_name) = { \
[0 ... (_num_configs - 1)] = { \
.if_dev = &(NET_IF_DEV_GET_NAME(dev_name, sfx)), \
NET_IF_CONFIG_INIT \
@ -2193,7 +2194,8 @@ struct net_if_api {
}; \
static Z_DECL_ALIGN(struct net_if) \
NET_IF_GET_NAME(dev_name, sfx)[NET_IF_MAX_CONFIGS] \
__used __in_section(_net_if, static, net_if) = { \
__used __in_section(_net_if, static, \
dev_name) = { \
[0 ... (NET_IF_MAX_CONFIGS - 1)] = { \
.if_dev = &(NET_IF_DEV_GET_NAME(dev_name, sfx)), \
NET_IF_CONFIG_INIT \