gcc の shared library呼び出しって面白い
sexyhookをよりセクシーにするべきgcc対応やっているんですが、gccって time() みたいな shared libraryの呼び出しって面白いですね。
{ time_t t = time(NULL); 080487b5 <main+0x51> movl $0x0,(%esp) 080487bc <main+0x58> call 080485bc <time@plt> 080487c1 <main+0x5d> mov %eax,-0x14(%ebp) printf("TIME:%p\r\n",time); 080487c4 <main+0x60> movl $0x80485bc,0x4(%esp) 080487cc <main+0x68> movl $0x80489bb,(%esp) 080487d3 <main+0x6f> call 0804859c <printf@plt> hexDump((void*)time,10); 080487d8 <main+0x74> movl $0xa,0x4(%esp) 080487e0 <main+0x7c> movl $0x80485bc,(%esp) 080487e7 <main+0x83> call 080486de <hexDump(void*, int)> }
って感じらしい。
080485bcっていうのを見てみると、
080485bc <time@plt> jmp *0x8049ba8
って感じでジャンプテーブルですね。本当にありがとうござい(ry
で、マシン語をみたかったんで、こんな感じでダンプ関数を作った。
void hexDump(void* p,int size) { printf("DUMP %p:",p); int i = 0; for( ; i < size ; i ++) { printf(" %02X", 0x000000ff & (unsigned int)*(((char*)p)+i)); if (i % 16 == 15) { printf("\r\n"); } } printf("\r\n"); }
んで、ダンプしてみると、
DUMP 0x80485bc: FF 25 A8 9B 04 08 68 40 00 00
らしい。
FF 25 ってなんか知らないけど、その後には、 本来のアドレスか書いてあるから、即値で無条件ジャンプ命令かな。