I am wondering how the location information of a variable is presented in a dwarf-file (a file with debug symbols), when the variable is declared as extern. A very simple example to illustrate my question:
simple.c:
#include <stdio.h>
extern int itest;
void main() {
printf("val: %d and addr: %p\n", itest, (void*) &itest);
}
simple_int.c:
int itest = 4;
compile:
gcc -g simple.c simple_int.c -o simple
When I inspect the executable simple using
dwarfdump simple | less
I get information for the variable itest like this:
< 1><0x00000072> DW_TAG_variable
DW_AT_name itest
DW_AT_decl_file 0x00000001 /<censored>/simple.c
DW_AT_decl_line 0x00000003
DW_AT_decl_column 0x0000000c
DW_AT_type <0x00000058>
DW_AT_external yes(1)
DW_AT_declaration yes(1)
There is no entry from which I could derive the location.
Usually I know entries like
DW_AT_location len 0x0009: 0x031440000000000000:
DW_OP_addr 0x00004014
or
DW_AT_location len 0x0002: 0x9164:
DW_OP_fbreg -28
So in which format is the location information stored for this variable declared as extern? Where can I read something about the location?
Thank you for your help