JMP间接性的意义何在
What is the point of JMP indirection
我发现,当我在调试模式下使用VS2010编译C/C++程序时(我没有检查过其他编译器),当我查看反汇编时,所有函数调用,无论是库函数、我自己的函数、类成员函数等,都有一个两步调用。实际的函数调用被转换为call
指令,地址为a。当我转到地址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中,函数调用被编译为对函数体的直接调用。
这个间接函数调用有什么意义?
以下是@RaptorFactor:的答案
这是由"增量链接"引起的。如果你在编译器/链接器设置中禁用了它,跳转就会消失。
http://msdn.microsoft.com/en-us/library/4khtbfyf(VS.80).aspx
相关文章:
- 多态性和功能结合
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 为什么与常规GCC不同,即使有"学究性错误",MinGW-GCC也能容忍丢失的返回类型
- 使用取消引用的指针的多态性会产生意外的结果.为什么?
- 松弛原子与无同步情况下的记忆连贯性
- C++Union/Struct位域的实现和可移植性
- C++boost序列化多态性问题
- 如何更改唯一指针向量的可见性
- 获取 SFML 窗口的 HWND 和高可用性?
- 当指向对象的指针作为参数传递给 std::thread 时,内存可见性
- 为什么 std::reduce 需要交换性?
- 如何查找哪个类对象位于数组的特定索引上(多态性)
- 如何在多线程中正确使用unique_ptr进行多态性?
- C++ 优先性和关联性
- 具有两个间接寻址运算符 (C++) 的函数参数的用途
- 如何实现自定义匹配器以检查 Catch2 中的对象相等性
- OpenMP for 循环并行性问题
- 混叠和指针互转换性
- JMP间接性的意义何在
- C++成员访问/间接运算符等效性