From ed6ce291baf265d7fe76263636deafc96446e9ff Mon Sep 17 00:00:00 2001 From: Wentong Wu Date: Wed, 28 Aug 2019 05:08:40 +0800 Subject: [PATCH] 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 --- scripts/elf_helper.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/elf_helper.py b/scripts/elf_helper.py index 6de89e5c939d..68a4a5973bf2 100644 --- a/scripts/elf_helper.py +++ b/scripts/elf_helper.py @@ -331,9 +331,14 @@ def analyze_die_array(die): elements.append(ub.value + 1) if not elements: - return - - type_env[die.offset] = ArrayType(die.offset, elements, type_offset) + if type_offset in type_env.keys(): + mt = type_env[type_offset] + if mt.has_kobject(): + if isinstance(mt, KobjectType) and mt.name == STACK_TYPE: + elements.append(1) + type_env[die.offset] = ArrayType(die.offset, elements, type_offset) + else: + type_env[die.offset] = ArrayType(die.offset, elements, type_offset) def analyze_typedef(die):