【问题标题】:What is the point of JMP indirection [duplicate]JMP间接的意义是什么[重复]
【发布时间】:2013-12-02 13:22:47
【问题描述】:

发现当我在Debug模式下用VS2010编译我的C/C++程序(我没有检查其他编译器)时,反汇编的时候,所有的函数调用,是否到库函数,我自己的函数,类成员函数等都有一个两步调用。实际的函数调用被转换为指向地址Acall 指令。当我转到地址 A 时,我看到它是某种 jmp 指令的大列表,每个指令都有不同的功能。它的一个(小)部分可能看起来像这样

fooFunc:
08CB1776  jmp         fooFunc (8D11F60h) 
barFunc:
08CB177B  jmp         barFunc (8D25240h) 
std::allocator<unsigned int>::max_size:
08CB1780  jmp         std::allocator<unsigned int>::max_size (8CE3D00h) 
std::_Copy_backward_opt<int *,int *>:
08CB1785  jmp         std::_Copy_backward_opt<int *,int *> (8D325D0h) 
std::_Checked_base<int *>:
08CB178A  jmp         std::_Checked_base<int *> (8D32360h) 
@ILT+1950(_foobarFunc):
08CB17A3  jmp         foobarFunc (8F31450h) 
@ILT+1955(_anotherFunc):
08CB17A8  jmp         anotherFunc (8E4BD20h) 
std::vector<unsigned short,std::allocator<unsigned short> >::capacity:
08CB17B2  jmp         std::vector<unsigned short,std::allocator<unsigned short> >::capacity (8D8AAF0h) 
yetAnother:
08CB17B7  jmp         yetAnother (8D18630h) 
@ILT+1975(_f):
08CB17BC  jmp         f (8E4FC50h) 
std::_Debug_range<char *>:
08CB17C6  jmp         std::_Debug_range<char *> (8D32480h) 
std::_Vector_const_iterator<MyClass *,std::allocator<MyClass *> >::operator+=:
08CB17CB  jmp         std::_Vector_const_iterator<MyClass *,std::allocator<MyClass *> >::operator+= (8D64C80h) 

这些jmp 指令依次转到实际的函数体。这仅在调试模式下编译时。在 Release 中,函数调用被编译成对函数体的直接调用。

这个间接函数调用的意义何在?

【问题讨论】:

标签: c++ assembly compiler-construction compiler-optimization


【解决方案1】:

这是@RaptorFactor 的答案:

这是由“增量链接”引起的。如果您在编译器/链接器设置中禁用它,跳转将消失。

http://msdn.microsoft.com/en-us/library/4khtbfyf(VS.80).aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 2020-04-22
    相关资源
    最近更新 更多