On 2/14/20 4:36 PM, Alexey Neyman wrote:
Hi all,
As reported here,
https://gcc.gnu.org/ml/gcc-help/2020-02/msg00062.html, GCC does not
behave according to manual when `-gdwarf -g1` options are used; it
does not generate the debugging information for external variables
even though it is supposed to (and it does so for other debugging
formats):
aneyman@supox:/tmp$ cat foo.c
int foo __attribute__((externally_visible));
Just as a clarification, the __attribute__((externally_visible)) is not
needed; this is copied from the original bug report to gcc-help mailing
list where it indicated that neither external linkage nor this attribute
made GCC behave as described in the manual.
Regards,
Alexey.
aneyman@supox:/tmp$ gcc -c -O2 -gdwarf -g1 foo.c
aneyman@supox:/tmp$ readelf -wi foo.o
aneyman@supox:/tmp$ gcc -c -O2 -gdwarf -g2 foo.c
aneyman@supox:/tmp$ readelf -wi foo.o
...
<1><1d>: Abbrev Number: 2 (DW_TAG_variable)
<1e> DW_AT_name : foo
The attached patch fixes this issue.
Regards,
Alexey.