https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99618
--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Looking at current binutils, it seems to misbehave though.
If I compile:
pr99618.c:
#include <stdio.h>
int i;
pr99618-2.c:
#include <stdio.h>
extern int i;
int
main ()
{
return i++;
}
gcc -g3 -gdwarf-5 -O2 -o pr99618{,.c,-2.c}
then readelf -wm shows:
Contents of the .debug_macro section:
Offset: 0x0
Version: 5
Offset size: 4
Offset into .debug_line: 0x0
DW_MACRO_import - offset : 0x14a
DW_MACRO_start_file - lineno: 0 filenum: 1 filename: pr99618.c
DW_MACRO_start_file - lineno: 0 filenum: 2 filename:
/usr/include/stdc-predef.h
DW_MACRO_import - offset : 0x9a0
DW_MACRO_end_file
...
Offset: 0x14a
Version: 5
Offset size: 4
DW_MACRO_define_strp - lineno : 0 macro : __STDC__ 1
DW_MACRO_define_strp - lineno : 0 macro : __STDC_VERSION__ 201710L
...
Offset: 0x11c2
Version: 5
Offset size: 4
Offset into .debug_line: 0x1ec
DW_MACRO_import - offset : 0x0
DW_MACRO_start_file - lineno: 0 filenum: 1 filename: pr99618-2.c
DW_MACRO_start_file - lineno: 0 filenum: 2 filename:
/usr/include/stdc-predef.h
DW_MACRO_import - offset : 0x0
DW_MACRO_end_file
Obviously the last two DW_MACRO_import should have been 0x14a and 0x9a0.
I don't think we can use a global symbol though, we don't want that exported
from libraries, nor have any special naming for those.