我正在为NetBSD系统使用英特尔的ICC编译器。我一直在与一个bug斗争,当我从核心转储中观察到来自gdb中两个不同机制的符号地址不同时,我更加惊讶。
当使用" info symbol connection_out"检查时,变量connection_out似乎具有不同的地址。和p& connection_out。
它是否看起来像编译器问题,其中优化为CPU寄存器的badf_errcnt被分配了一个内存位置,然后编译器在两者之间混淆了?
我有编译器O2级别优化ON。 有问题的变量是一个全局静态int变量。 我不认为指针别名在此处起作用,因为正在使用变量的内存位置。
我看到未经剥离的符号文件也同意反汇编代码中的地址。
gdb$ disassemble sigusr1_rt
Dump of assembler code for function sigusr1_rt:
0x01845000 <+0>: push %ebp
0x01845001 <+1>: mov %esp,%ebp
0x01845003 <+3>: sub $0x8,%esp
0x01845006 <+6>: movl $0x16c156a,0x188f05c
0x01845010 <+16>: mov %ebp,%esp
0x01845012 <+18>: pop %ebp
0x01845013 <+19>: ret
0x01845014 <+20>: lea 0x0(%esi),%esi
0x0184501a <+26>: lea 0x0(%edi),%edi
End of assembler dump.
gdb$ info symbol 0x188f05c
connection_out in section .bss of /sites/eqx/work/swcores/tripunjay/F10ACOREDIR/f10cp_sshd.login-eqx-06.6402/sshd
gdb$ p &connection_out
$10 = (int *) 0x188f048
gdb$ p/d 0x188f05c - 0x188f048
$11 = 20
gdb$ p/x 0x188f05c - 0x188f048
$12 = 0x14
gdb$ info symbol 0x188f048
badf_errcnt.5450.0.13 in section .bss of /sites/eqx/work/swcores/tripunjay/F10ACOREDIR/f10cp_sshd.login-eqx-06.6402/sshd
gdb$ p &badf_errcnt
No symbol "badf_errcnt" in current context.
gdb$ select-frame 5
gdb$ frame
Stack level 5, frame at 0xbb4aca20:
eip = 0x1846007 in wait_until_can_do_something (serverloop.c:404); saved eip 0x1846698
called by frame at 0xbb4b0af0, caller of frame at 0xbb4ac9d0
source language c.
Arglist at 0xbb4aca18, args: readsetp=0xbb4b0ab4, writesetp=0xbb4b0ab8, maxfdp=0x4, nallocp=0xbb4b0abc, max_time_milliseconds=0x0
Locals at 0xbb4aca18, Previous frame's sp is 0xbb4aca20
Saved registers:
ebx at 0xbb4aca00, ebp at 0xbb4aca18, esi at 0xbb4ac9fc, edi at 0xbb4aca04, eip at 0xbb4aca1c
readsetp = 0xbb4b0ab4
writesetp = 0xbb4b0ab8
maxfdp = 0x4
nallocp = 0xbb4b0abc
max_time_milliseconds = 0x0
badf_errcnt = <optimized out>
tv = <optimized out>
tvp = <optimized out>
client_alive_scheduled = 0x0
gdb$ p &badf_errcnt
Can't take address of "badf_errcnt" which isn't an lvalue.
prompt$ nm sshd.unstripped | grep connection_out
0188f05c b connection_out
答案 0 :(得分:2)
这看起来像ICC生成的调试信息或链接器中的可能错误。
特别是,符号表中的connection_out
地址似乎与connection_out
中.debug_info
的地址不符。
要在符号表中查找&connection_out
,请执行以下操作:
readelf -Ws /sites/.../f10cp_sshd.login-eqx-06.6402/sshd |
grep connection_out
并与
的输出进行比较readelf -wi /sites/.../f10cp_sshd.login-eqx-06.6402/sshd
应该有connection_out
的条目,与此类似:
<1><b6>: Abbrev Number: 9 (DW_TAG_variable)
<b7> DW_AT_name : (indirect string, offset: 0x84): connection_out
<bb> DW_AT_decl_file : 1
<bc> DW_AT_decl_line : 5
<bd> DW_AT_type : <0x73>
<c1> DW_AT_external : 1
<c1> DW_AT_location : 9 byte block: 3 60 10 60 0 0 0 0 0 (DW_OP_addr: 601060)
如果符号表中的地址与.debug_info
(DW_AT_location
条目)中的地址不同,则会出现编译器(或链接器)错误。如果它们相同,则会出现GDB错误。