Chinaunix

标题: 请教cygwin下wpcap的链接问题. 谢先 [打印本页]

作者: 傻旦    时间: 2008-06-10 17:21
标题: 请教cygwin下wpcap的链接问题. 谢先
gcc -Wall -Wno-format-zero-length -o demo_test  -lpthread -lwpcap demo_test.o
demo_test.o:demo_test.c:(.text+0x4ab): undefined reference to `_pcap_sendpacket'
demo_test.o:demo_test.c.text+0x611): undefined reference to `_pcap_next_ex'

demo_test.o:demo_test.c:(.text+0x9b5): undefined reference to `_pcap_open_live'
demo_test.o:demo_test.c.text+0xa50): undefined reference to `_pcap_compile'

demo_test.o:demo_test.c:(.text+0xa9f): undefined reference to `_pcap_close'
demo_test.o:demo_test.c.text+0xacf): undefined reference to `_pcap_setfilter'

demo_test.o:demo_test.c:(.text+0xb1e): undefined reference to `_pcap_close'
demo_test.o:demo_test.c.text+0xba9): undefined reference to `_pcap_close'

demo_test.o:demo_test.c:(.text+0xbf8): undefined reference to `_pcap_close



nm libwpcap的结果,可以看到Text段中有相关的接口.
d000010.o:
00000000 i .idata$4
00000000 i .idata$5
00000000 i .idata$6
00000000 i .idata$7
00000000 t .text
         U __head_wpcap_dll
00000000 I __imp__pcap_close
00000000 T _pcap_close


反汇编的结果比较奇怪:

00000000 <.idata$6>:
   0:    0a 00                    or     (%eax),%al
   2:    70 63                    jo     67 <_pcap_compile+0x67>
   4:    61                       popa   
   5:    70 5f                    jo     66 <_pcap_compile+0x66>
   7:    63 6f 6d                 arpl   %bp,0x6d(%edi)
   a:    70 69                    jo     75 <_pcap_compile+0x75>
   c:    6c                       insb   (%dx),%es:(%edi)
   d:    65 00 00                 add    %al,%gs:(%eax)

d000010.o:     file format pe-i386

Disassembly of section .text:

00000000 <_pcap_close>:
   0:    ff 25 00 00 00 00        jmp    *0x0
   6:    90                       nop   
   7:    90                       nop   
Disassembly of section .idata$7:

00000000 <.idata$7>:
   0:    00 00                    add    %al,(%eax)
    ...
Disassembly of section .idata$5:

00000000 <__imp__pcap_close>:
   0:    00 00                    add    %al,(%eax)
    ...
Disassembly of section .idata$4:

00000000 <.idata$4>:
   0:    00 00                    add    %al,(%eax)
    ...
Disassembly of section .idata$6:


[ 本帖最后由 傻旦 于 2008-6-10 17:51 编辑 ]
作者: 傻旦    时间: 2008-06-10 22:28
up一下




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2