scripts: Improve gen_kobject_list.py variable address determination

The gen_kobject_list.py script looks at DWARF debug information in the
elf file to determine the address of variables. Make sure that when
looking at DW_FORM_exprloc, it looks at both DW_OP_addr and
DW_OP_plus_uconst.

Signed-off-by: Nick Goote <ngoote@gmail.com>
This commit is contained in:
Nick Goote 2024-04-09 13:08:36 -05:00 committed by Anas Nashif
commit 0b8714bcde

View file

@ -171,6 +171,7 @@ def debug_die(die, text):
# -- ELF processing # -- ELF processing
DW_OP_addr = 0x3 DW_OP_addr = 0x3
DW_OP_plus_uconst = 0x23
DW_OP_fbreg = 0x91 DW_OP_fbreg = 0x91
STACK_TYPE = "z_thread_stack_element" STACK_TYPE = "z_thread_stack_element"
thread_counter = 0 thread_counter = 0
@ -622,6 +623,11 @@ def find_kobjects(elf, syms):
addr = ((loc.value[1] << 0 ) | (loc.value[2] << 8) | addr = ((loc.value[1] << 0 ) | (loc.value[2] << 8) |
(loc.value[3] << 16) | (loc.value[4] << 24)) (loc.value[3] << 16) | (loc.value[4] << 24))
# Handle a DW_FORM_exprloc that contains a DW_OP_addr, followed immediately by
# a DW_OP_plus_uconst.
if len(loc.value) >= 7 and loc.value[5] == DW_OP_plus_uconst:
addr += (loc.value[6])
if addr == 0: if addr == 0:
# Never linked; gc-sections deleted it # Never linked; gc-sections deleted it
continue continue