Gcc 二进制文件中缺少.dbug_loc
我正在检查下面提到的代码的ELF二进制文件。 我在Ubuntu x86_64系统的gcc 7.4.0虚拟盒中编译了它,如下所示:Gcc 二进制文件中缺少.dbug_loc,gcc,x86-64,elf,abi,dwarf,Gcc,X86 64,Elf,Abi,Dwarf,我正在检查下面提到的代码的ELF二进制文件。 我在Ubuntu x86_64系统的gcc 7.4.0虚拟盒中编译了它,如下所示: gcc -g scratch1.c -o scratch1.out #include <stdio.h> void do_stuff(int my_arg){ int my_local = my_arg + 2; int i; for (i = 0; i < my_local; ++i) printf("i = %d\n",
gcc -g scratch1.c -o scratch1.out
#include <stdio.h>
void do_stuff(int my_arg){
int my_local = my_arg + 2;
int i;
for (i = 0; i < my_local; ++i) printf("i = %d\n", i);
}
int main(){
do_stuff(2);
return 0;
}
尽管如此,我还是看到了其他一些调试部分
[26] .debug_aranges PROGBITS 0000000000000000 0000103b
0000000000000030 0000000000000000 0 0 1
[27] .debug_info PROGBITS 0000000000000000 0000106b
000000000000035f 0000000000000000 0 0 1
[28] .debug_abbrev PROGBITS 0000000000000000 000013ca
0000000000000125 0000000000000000 0 0 1
[29] .debug_line PROGBITS 0000000000000000 000014ef
00000000000000e6 0000000000000000 0 0 1
[30] .debug_str PROGBITS 0000000000000000 000015d5
00000000000002b5 0000000000000001 MS 0 0 1
需要您的帮助,为什么缺少此部分
需要您的帮助,为什么缺少此部分
.debug_loc部分包含DW_AT_位置列表,通常仅为优化代码发出
由于编译时没有进行优化,编译器没有发出此节。尝试通过以下方式构建:
gcc -g -O3 scratch1.c -o scratch1.out
以下是我对gcc 8.3.0的看法:
$ gcc -g scratch.c && readelf -WS a.out | grep debug_loc
# no output
$ gcc -g scratch.c -O3 && readelf -WS a.out | grep debug_loc
[32] .debug_loc PROGBITS 0000000000000000 0039db 000230 00 0 0 1
需要您的帮助,为什么缺少此部分
.debug_loc部分包含DW_AT_位置列表,通常仅为优化代码发出
由于编译时没有进行优化,编译器没有发出此节。尝试通过以下方式构建:
gcc -g -O3 scratch1.c -o scratch1.out
以下是我对gcc 8.3.0的看法:
$ gcc -g scratch.c && readelf -WS a.out | grep debug_loc
# no output
$ gcc -g scratch.c -O3 && readelf -WS a.out | grep debug_loc
[32] .debug_loc PROGBITS 0000000000000000 0039db 000230 00 0 0 1
谢谢,我不知道-我在O1级也得到了。谢谢,我不知道-我在O1级也得到了。