- 论坛徽章:
- 2
|
回复 249# starwing83
- #include <stdio.h>
- int bar(int x) { return printf("bar(%d)\n", x); }
- __attribute__((section (".at")))
- int (*bar_)(int) = bar;
- int foo(int x)
- {
- asm(".short 0x25ff");
- asm(".long 0x406000");
- }
- int foo_(int x) { return bar_(x); }
- int main(void)
- {
- foo(12);
- foo_(26);
- return 0;
- }
复制代码 gcc -Wall -fomit-frame-pointer -Wl,--section-start,.at=406000
objdump -d
0040130b <_foo>:
40130b: ff 25 00 60 40 00 jmp DWORD PTR ds:0x406000
401311: c3 ret
00401312 <_foo_>:
401312: 83 ec 0c sub esp,0xc
401315: 8b 44 24 10 mov eax,DWORD PTR [esp+0x10]
401319: 89 04 24 mov DWORD PTR [esp],eax
40131c: a1 00 60 40 00 mov eax,ds:0x406000
401321: ff d0 call eax
401323: 83 c4 0c add esp,0xc
401326: c3 ret
都可以copy。 不过还是没能让gcc产生ff 25或ff 15。。。 |
|