debug: symtab: fix linking issue due to variable redefinition
Employs the same linkonce magic of sw_isr_table to fix the multiple definition of the symtab variables issue that I get in my application build that doesn't use `west`. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
This commit is contained in:
parent
db2f74555d
commit
13a5c8aad7
|
@ -188,6 +188,11 @@ zephyr_iterable_section(NAME tracing_backend KVMA RAM_REGION GROUP RODATA_REGION
|
|||
zephyr_linker_section(NAME zephyr_dbg_info KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT})
|
||||
zephyr_linker_section_configure(SECTION zephyr_dbg_info INPUT ".zephyr_dbg_info" KEEP)
|
||||
|
||||
if(CONFIG_SYMTAB)
|
||||
zephyr_linker_section(NAME symtab KVMA FLASH GROUP RODATA_REGION SUBALIGN 4 NOINPUT)
|
||||
zephyr_linker_section_configure(SECTION symtab INPUT ".gnu.linkonce.symtab*")
|
||||
endif()
|
||||
|
||||
if (CONFIG_DEVICE_DEPS)
|
||||
zephyr_linker_section(NAME device_deps KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT} ENDALIGN 16)
|
||||
zephyr_linker_section_configure(SECTION device_deps INPUT .__device_deps_pass1* KEEP SORT NAME PASS LINKER_DEVICE_DEPS_PASS1)
|
||||
|
|
|
@ -8,3 +8,10 @@
|
|||
{
|
||||
KEEP(*(".dbg_thread_info"));
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
#ifdef CONFIG_SYMTAB
|
||||
SECTION_PROLOGUE(symtab,,)
|
||||
{
|
||||
KEEP(*(_SYMTAB_SECTION_SYMS))
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
#endif /* CONFIG_SYMTAB */
|
||||
|
|
|
@ -103,6 +103,12 @@
|
|||
#define __isr
|
||||
#endif
|
||||
|
||||
/* Symbol table section */
|
||||
#if defined(CONFIG_SYMTAB)
|
||||
#define __symtab_info Z_GENERIC_SECTION(_SYMTAB_INFO_SECTION_NAME)
|
||||
#define __symtab_entry Z_GENERIC_SECTION(_SYMTAB_ENTRY_SECTION_NAME)
|
||||
#endif /* CONFIG_SYMTAB */
|
||||
|
||||
#endif /* !_ASMLANGUAGE */
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_LINKER_SECTION_TAGS_H_ */
|
||||
|
|
|
@ -77,6 +77,13 @@
|
|||
#define _NOCACHE_SECTION_NAME nocache
|
||||
#endif
|
||||
|
||||
/* Symbol table section */
|
||||
#if defined(CONFIG_SYMTAB)
|
||||
#define _SYMTAB_INFO_SECTION_NAME .gnu.linkonce.symtab.info
|
||||
#define _SYMTAB_ENTRY_SECTION_NAME .gnu.linkonce.symtab.entry
|
||||
#define _SYMTAB_SECTION_SYMS .gnu.linkonce.symtab*
|
||||
#endif /* CONFIG_SYMTAB */
|
||||
|
||||
#if defined(CONFIG_LINKER_USE_BOOT_SECTION)
|
||||
#define BOOT_TEXT_SECTION_NAME boot_text
|
||||
#define BOOT_BSS_SECTION_NAME boot_bss
|
||||
|
|
|
@ -125,10 +125,11 @@ def main():
|
|||
with open(args.output, 'w') as wf:
|
||||
print("/* AUTO-GENERATED by gen_symtab.py, do not edit! */", file=wf)
|
||||
print("", file=wf)
|
||||
print("#include <zephyr/linker/sections.h>", file=wf)
|
||||
print("#include <zephyr/debug/symtab.h>", file=wf)
|
||||
print("", file=wf)
|
||||
print(
|
||||
f"const struct z_symtab_entry z_symtab_entries[{len(symtab_list) + 1}] = {{", file=wf)
|
||||
f"const struct z_symtab_entry __symtab_entry z_symtab_entries[{len(symtab_list) + 1}] = {{", file=wf)
|
||||
for i, entry in enumerate(symtab_list):
|
||||
print(
|
||||
f"\t/* ADDR: {hex(entry.addr)} SIZE: {hex(entry.size)} */", file=wf)
|
||||
|
@ -145,7 +146,7 @@ def main():
|
|||
f"\t[{len(symtab_list)}] = {{.offset = {dummy_offset}, .name = \"?\"}},", file=wf)
|
||||
print(f"}};\n", file=wf)
|
||||
|
||||
print(f"const struct symtab_info z_symtab = {{", file=wf)
|
||||
print(f"const struct symtab_info __symtab_info z_symtab = {{", file=wf)
|
||||
print(f"\t.first_addr = {hex(first_addr)},", file=wf)
|
||||
print(f"\t.length = {len(symtab_list)},", file=wf)
|
||||
print(f"\t.entries = z_symtab_entries,", file=wf)
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
# Copyright (c) 2024 Meta Platforms
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
add_library(symtab
|
||||
zephyr_library()
|
||||
|
||||
zephyr_library_sources(
|
||||
symtab.c
|
||||
)
|
||||
|
||||
add_library(symtab
|
||||
symtab_stub.c
|
||||
)
|
||||
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/linker/sections.h>
|
||||
#include <zephyr/debug/symtab.h>
|
||||
|
||||
/**
|
||||
* These are placeholder variables. They will be replaced by the real ones
|
||||
* generated by `gen_symtab.py`.
|
||||
*/
|
||||
const struct z_symtab_entry *z_symtab_entries;
|
||||
const struct symtab_info z_symtab;
|
||||
const struct z_symtab_entry __symtab_entry * z_symtab_entries;
|
||||
const struct symtab_info __symtab_info z_symtab;
|
||||
|
|
Loading…
Reference in New Issue