-fPIC产生位置无关代码(PIC),一般创建共享库时用到。
在x86上,PIC的代码的符号引用都是通过ebx进行操作的。
(gdb) disassemble main
Dump of assembler code for function main:
0x0804840a <+0>: push %ebp
0x0804840b <+1>: mov %esp,%ebp
0x0804840d <+3>: push %ebx
0x0804840e <+4>: and $0xfffffff0,%esp
0x08048411 <+7>: call 0x804842b <__i686.get_pc_thunk.bx>
0x08048416 <+12>: add $0x1bde,%ebx //ebx里面存放着是GOT表的地址
0x0804841c <+18>: call 0x80483e4 <hi>
0x08048421 <+23>: mov $0x0,%eax
0x08048426 <+28>: mov -0x4(%ebp),%ebx
0x08048429 <+31>: leave
0x0804842a <+32>: ret
End of assembler dump.
http://www.xfocus.net/articles/200112/320.html