We have a third party Software that's picks out information from generated .elf about our global variables which are using DWARF debug info to find it. Previously we have been using IAR compiler which producing the .elf file including debugging DWARF info. With the .elf file produced from IAR there is no problem finding out location address in memory and name of variable. But when producing the .elf file with gcc "GNU Arm Embedded Toolchain 9-2020-q3-update) 9.3.1 20200408 (release)” the SW have problem locating the variables that are global variables that are declared extern in header file and definition I .c file.
So to my question, is there a way to get the DWARF info regarding external global variables to look more like the ones produced by IAR, look at example below showing an extern global variable using readelf.
Programming language: C CFLAGS: (-ggdb -ffunction-sections -O0 -gpubnames)(I've tried alot of different Compiler options regardning DWARF settings but with no luck)
The IAR produces this:
<1><2f1ab>: Abbrev Number: 3 (DW_TAG_variable)
<2f1ac> DW_AT_name : StopBtn_StopBtnActvd_flg
<2f1c5> DW_AT_type : <0x29d80>
<2f1c9> DW_AT_decl_file : 4
<2f1ca> DW_AT_decl_line : 46
<2f1cb> DW_AT_decl_column : 11
<2f1cc> Unknown AT value: 276a: 34
<2f1cd> DW_AT_external : 1
<2f1ce> DW_AT_location : 5 byte block: 3 aa 45 1 20 (DW_OP_addr: 200145aa)
<2f1d4> Unknown AT value: 2768: 1
<1><2f1d5>: Abbrev Number: 0
GCC produces this (information is divided into 2 sections when using gcc in _debug:info):
<1><46158>: Abbrev Number: 45 (DW_TAG_variable)
<46159> DW_AT_name : (indirect string, offset: 0x21a4): StopBtn_StopBtnActvd_flg
<4615d> DW_AT_decl_file : 11
<4615e> DW_AT_decl_line : 102
<4615f> DW_AT_decl_column : 17
<46160> DW_AT_type : <0x45dc1>
<46164> DW_AT_external : 1
<46164> DW_AT_declaration : 1
<1><46164>: Abbrev Number: 45 (DW_TAG_variable)
--
<1><46655>: Abbrev Number: 46 (DW_TAG_variable)
<46656> DW_AT_specification: <0x46158>
<4665a> DW_AT_decl_file : 12
<4665b> DW_AT_decl_line : 46
<4665c> DW_AT_decl_column : 11
<4665d> DW_AT_location : 5 byte block: 3 7a 4 0 20 (DW_OP_addr: 2000047a)
<1><46663>: Abbrev Number: 46 (DW_TAG_variable)
<46664> DW_AT_specification: <0x46164>
<46668> DW_AT_decl_file : 12
<46669> DW_AT_decl_line : 47