Skip to content

Commit ed6ce29

Browse files
wentongwunashif
authored andcommitted
scripts: elf_helper.py: fix stack declared K_THREAD_STACK_EXTERN
If a stack is declared with K_THREAD_STACK_EXTERN first, analyze array in elf_helper.py will ignore this declaration which will be referenced by the actual instances via the tag DW_AT_specification, so that this stack can't be detected by the kernel object detection mechanism, and this will cause userspace not work. Fixes: #16760. Signed-off-by: Wentong Wu <[email protected]>
1 parent 9ca0d5e commit ed6ce29

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scripts/elf_helper.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,14 @@ def analyze_die_array(die):
331331
elements.append(ub.value + 1)
332332

333333
if not elements:
334-
return
335-
336-
type_env[die.offset] = ArrayType(die.offset, elements, type_offset)
334+
if type_offset in type_env.keys():
335+
mt = type_env[type_offset]
336+
if mt.has_kobject():
337+
if isinstance(mt, KobjectType) and mt.name == STACK_TYPE:
338+
elements.append(1)
339+
type_env[die.offset] = ArrayType(die.offset, elements, type_offset)
340+
else:
341+
type_env[die.offset] = ArrayType(die.offset, elements, type_offset)
337342

338343

339344
def analyze_typedef(die):

0 commit comments

Comments
 (0)