函数地址不实际的code类地址 [英] Address of function is not actual code address

查看:129
本文介绍了函数地址不实际的code类地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调试在Visual Studio 2008(C ++)的一些code,我注意到,在我的函数指针变量的地址不是函数本身的实际地址。这是一个externC的功能。

Debugging some code in Visual Studio 2008 (C++), I noticed that the address in my function pointer variable is not the actual address of the function itself. This is an extern "C" function.

int main() {
   void (*printaddr)(const char *) = &print; // debug shows printaddr == 0x013C1429

}

Address: 0x013C4F10
void print() {
  ...
}

服用函数地址的拆装:

The disassembly of taking the function address is:

   void (*printaddr)(const char *) = &print;
013C7465 C7 45 BC 29 14 3C 01 mov         dword ptr [printaddr],offset print (13C1429h) 

编辑:我看到了code地址013C4F10,并在该地址的编译器显然是插入JMP指令

I viewed the code at address 013C4F10 and the compiler is apparently inserting a "jmp" instruction at that address.

013C4F10 E9 C7 3F 00 00   jmp         print (013C1429h) 

实际上有在该.exe每个方法的整体跳转表。

There is actually a whole jump table of every method in the .exe.

有人能阐述为什么它这样做?它是一个调试的功能?

Can someone expound on why it does this? Is it a debugging "feature" ?

推荐答案

这是由增量链接'造成的。如果禁用,在你的编译器/连接器设置跳跃会自行消失。

That is caused by 'Incremental Linking'. If you disable that in your compiler/linker settings the jumps will go away.

<一个href=\"http://msdn.microsoft.com/en-us/library/4khtbfyf(VS.80).aspx\">http://msdn.microsoft.com/en-us/library/4khtbfyf(VS.80).aspx

这篇关于函数地址不实际的code类地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆