Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix region_name parsing in elf32-extmap #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

NoMore201
Copy link

When parsing section data for priting extended map information in map file, function elf32_collect_extmap_info was trying to retrieve region_name from the userdata field of bfd_section.

extmap module has an internal representation of the userdata field not up to date with latest ld code, which writes a lang_output_section_statement_type inside this userdata field. So if user generates map file during executable linking, the extended map table was printing gargage as memory region name, like shown here:

0x800001f4 0x800001f4    0 g IfxCpu_Trap_vectorTable0_end                        .traptab_tc0 .traptab_cpu0                                      third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Cpu/Trap/IfxCpu_Trap.c.obj
0x80000200 0x80000213   20 g __thenan_df                                  ���VUU .rodata      .rodata                                            _thenan_df.o
0x80000214 0x8000021b    8 l IfxScuCcu_defaultFlashWaitstateConfig        ���VUU .rodata      .rodata.IfxScuCcu_defaultFlashWaitstateConfig      third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x8000021c 0x80000233   24 l IfxScuCcu_defaultPllConfigSteps              ���VUU .rodata      .rodata.IfxScuCcu_defaultPllConfigSteps            third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x80000234 0x8000024b   24 g IfxScuCcu_MA_percent                         ���VUU .rodata      .rodata.IfxScuCcu_MA_percent                       third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x8000024c 0x8000029b   80 g IfxScuCcu_defaultClockConfig                 ���VUU .rodata      .rodata.IfxScuCcu_defaultClockConfig               third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x8000029c 0x800002a3    8 g IfxScuCcu_defaultModConfig                   ���VUU .rodata      .rodata.IfxScuCcu_defaultModConfig                 third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x800002a4 0x800002a4    0 g __clear_table                                ���VUU .rodata      .rodata                                            src/aurix_sample_tc33x.elf
0x800002fc 0x800002fc    0 g __copy_table                                 ���VUU .rodata      .rodata                                            src/aurix_sample_tc33x.elf

To fix region name parsing, this code adds additional padding in the internal struct to be able to retrieve region name from userdata field. Now memory region name should be correctly written in extended map listing:

0x800001f4 0x800001f4    0 g IfxCpu_Trap_vectorTable0_end                 pfls0     .traptab_tc0 .traptab_cpu0                                      third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Cpu/Trap/IfxCpu_Trap.c.obj
0x80000200 0x80000213   20 g __thenan_df                                  pfls0     .rodata      .rodata                                            _thenan_df.o
0x80000214 0x8000021b    8 l IfxScuCcu_defaultFlashWaitstateConfig        pfls0     .rodata      .rodata.IfxScuCcu_defaultFlashWaitstateConfig      third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x8000021c 0x80000233   24 l IfxScuCcu_defaultPllConfigSteps              pfls0     .rodata      .rodata.IfxScuCcu_defaultPllConfigSteps            third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x80000234 0x8000024b   24 g IfxScuCcu_MA_percent                         pfls0     .rodata      .rodata.IfxScuCcu_MA_percent                       third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x8000024c 0x8000029b   80 g IfxScuCcu_defaultClockConfig                 pfls0     .rodata      .rodata.IfxScuCcu_defaultClockConfig               third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x8000029c 0x800002a3    8 g IfxScuCcu_defaultModConfig                   pfls0     .rodata      .rodata.IfxScuCcu_defaultModConfig                 third_party/CMakeFiles/InfineonLib.dir/infineon/Libraries/iLLD/TC33A/Tricore/Scu/Std/IfxScuCcu.c.obj
0x800002a4 0x800002a4    0 g __clear_table                                pfls0     .rodata      .rodata                                            src/aurix_sample_tc33x.elf
0x800002fc 0x800002fc    0 g __copy_table                                 pfls0     .rodata      .rodata                                            src/aurix_sample_tc33x.elf

When parsing section data for priting extended map information in map
file, function elf32_collect_extmap_info was trying to retrieve
region_name from the userdata field of bfd_section.

extmap module has an internal representation of the userdata field
not up to date with latest ld code, which writes a
lang_output_section_statement_type inside this userdata field.

To fix region name parsing, this code adds additional padding in the
internal struct to be able to retrieve region name from userdata field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant