我写了一个程序,使用 time() 函数,
我gdb的时候:</p>
[VM_241_149_tlinux ~/test]$ gdb ./testsys_d -q
Reading symbols from /data/home/youngxiao/test/testsys_d...(no debugging symbols found)...done.
(gdb) b __GI_time
Function "__GI_time" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (__GI_time) pending.
(gdb) r
Starting program: /data/home/youngxiao/test/testsys_d
Breakpoint 1, 0x00007ffff7345770 in time () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.149.tl1.6.x86_64 libgcc-4.4.6-4.tl1.x86_64 libstdc++-4.4.6-4.tl1.x86_64
(gdb) bt
#0 0x00007ffff7345770 in time () from /lib64/libc.so.6
#1 0x0000000000400671 in main ()
(gdb) disass
Dump of assembler code for function time:
=> 0x00007ffff7345770 <+0>: sub $0x8,%rsp
0x00007ffff7345774 <+4>: mov $0xffffffffff600400,%rax
0x00007ffff734577b <+11>: callq *%rax
0x00007ffff734577d <+13>: add $0x8,%rsp
0x00007ffff7345781 <+17>: retq
End of assembler dump.
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
我们可以看到 time() 使用 vsyscall,而不使用 vdso,为什么?
我还测试了 gettimeofday() ,它使用 vdso ...