diff --git a/cmake/linker_script/common/kobject-text.cmake b/cmake/linker_script/common/kobject-text.cmake index 9fdf08b478f..10d33e21a01 100644 --- a/cmake/linker_script/common/kobject-text.cmake +++ b/cmake/linker_script/common/kobject-text.cmake @@ -24,25 +24,4 @@ if(CONFIG_USERSPACE) EXPR "(@_kobject_text_area_end@ - @_kobject_text_area_start@)" ) - - if(CONFIG_DYNAMIC_OBJECTS) - zephyr_linker_section_configure( - SECTION - _kobject_text_area - SYMBOLS - z_object_gperf_find - z_object_gperf_wordlist_foreach - PASS NOT LINKER_ZEPHYR_FINAL - ) - else() - zephyr_linker_section_configure( - SECTION - _kobject_text_area - SYMBOLS - k_object_find - k_object_wordlist_foreach - PASS NOT LINKER_ZEPHYR_FINAL - ) - endif() - -endif() \ No newline at end of file +endif() diff --git a/include/zephyr/linker/kobject-text.ld b/include/zephyr/linker/kobject-text.ld index f35a2009ed2..6a0abc2727b 100644 --- a/include/zephyr/linker/kobject-text.ld +++ b/include/zephyr/linker/kobject-text.ld @@ -14,15 +14,6 @@ *(".kobject_data.text*") PLACE_SYMBOL_HERE(_kobject_text_area_end); _kobject_text_area_used = _kobject_text_area_end - _kobject_text_area_start; -#ifndef LINKER_ZEPHYR_FINAL -#ifdef CONFIG_DYNAMIC_OBJECTS - PROVIDE(z_object_gperf_find = .); - PROVIDE(z_object_gperf_wordlist_foreach = .); -#else - PROVIDE(k_object_find = .); - PROVIDE(k_object_wordlist_foreach = .); -#endif -#endif /* In a valid build the MAX function will always evaluate to the second argument below, but to give the user a good error message diff --git a/kernel/userspace.c b/kernel/userspace.c index 7a66513c03e..adcf7817d04 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -521,6 +521,33 @@ void k_object_wordlist_foreach(_wordlist_cb_func_t func, void *context) } #endif /* CONFIG_DYNAMIC_OBJECTS */ +/* In the earlier linker-passes before we have the real generated + * implementation of the lookup functions, we need some weak dummies. + * Being __weak, they will be replaced by the generated implementations in + * the later linker passes. + */ +#ifdef CONFIG_DYNAMIC_OBJECTS +Z_GENERIC_SECTION(.kobject_data.text.dummies) +__weak struct k_object *z_object_gperf_find(const void *obj) +{ + return NULL; +} +Z_GENERIC_SECTION(.kobject_data.text.dummies) +__weak void z_object_gperf_wordlist_foreach(_wordlist_cb_func_t func, void *context) +{ +} +#else +Z_GENERIC_SECTION(.kobject_data.text.dummies) +__weak struct k_object *k_object_find(const void *obj) +{ + return NULL; +} +Z_GENERIC_SECTION(.kobject_data.text.dummies) +__weak void k_object_wordlist_foreach(_wordlist_cb_func_t func, void *context) +{ +} +#endif + static unsigned int thread_index_get(struct k_thread *thread) { struct k_object *ko;