Skip to content

code relocation generating different memory layout cause user mode not working #17038

@wentongwu

Description

@wentongwu

Describe the bug
In the magic building process for user mode, there are different memory layout as below log show.
The map file of building zephyr_prebuilt.elf is:

 .text.sedi_pm_pmu2nvic_isr
                0x0000000060011188        0xa libbsp_sedi_arm.a(pm.c.obj)
                0x0000000060011188                sedi_pm_pmu2nvic_isr
 *(SORT_BY_ALIGNMENT(.gnu.linkonce.t.*))
 *(SORT_BY_ALIGNMENT(.glue_7t))
 .glue_7t       0x0000000060011192        0x0 linker stubs
 *(SORT_BY_ALIGNMENT(.glue_7))
 .glue_7        0x0000000060011192        0x0 linker stubs
 *(SORT_BY_ALIGNMENT(.vfp11_veneer))
 .vfp11_veneer  0x0000000060011192        0x0 linker stubs
 *(SORT_BY_ALIGNMENT(.v4_bx))
 .v4_bx         0x0000000060011192        0x0 linker stubs
                0x0000000060011192                _priv_stacks_text_area_start = .
 *(SORT_BY_ALIGNMENT(.priv_stacks.text*))
 *fill*         0x0000000060011192        0x2 

And ztest_thread_stack located in 0x60030000 from below log and we can also find it from map file.
gen_kobject_list.py: symbol 'ztest_thread_stack' at 0x60030000 contains 1 object(s)

The map file of building priv_stacks_prebuilt.elf is:

.text.sedi_pm_pmu2nvic_isr
                0x0000000060011188        0xa libbsp_sedi_arm.a(pm.c.obj)
                0x0000000060011188                sedi_pm_pmu2nvic_isr
 *fill*         0x0000000060011192        0x6 
 .text.sedi_pm_pmu2nvic_isr.__stub
                0x0000000060011198       0x68 linker stubs
 *(SORT_BY_ALIGNMENT(.gnu.linkonce.t.*))
 *(SORT_BY_ALIGNMENT(.glue_7t))
 .glue_7t       0x0000000060011200        0x0 linker stubs
 *(SORT_BY_ALIGNMENT(.glue_7))
 .glue_7        0x0000000060011200        0x0 linker stubs
 *(SORT_BY_ALIGNMENT(.vfp11_veneer))
 .vfp11_veneer  0x0000000060011200        0x0 linker stubs
 *(SORT_BY_ALIGNMENT(.v4_bx))
 .v4_bx         0x0000000060011200        0x0 linker stubs
                0x0000000060011200                _priv_stacks_text_area_start = .

And ztest_thread_stack located in 0x60050000 from below log and we can also find it from map file.
gen_priv_stacks.py: symbol 'ztest_thread_stack' at 0x60050000 contains 1 object(s)

So that difference will cause the wrong hash table in priv_stacks_hash.c because of the different .rodata .noinit .data sections in the same one sram region and it will cause the user mode doesn't work.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions