【发布时间】:2018-05-10 08:51:50
【问题描述】:
当我调用一个函数 DLLFunction(int) 时,它是在 DLL 中定义的。我的 Intel X86 PC 上的 Visual Studio 2013 将其编译为以下指令
CALL [__imp__DLLFunction@4] // Call absolute indirect address
FF 15 00 90 40 00 CALL [00409000h] // original absolute CALL instruction
FF 15 00 90 39 01 CALL [01399000h] // After address fixup by OS loader
// __imp__DLLFunction@4 is the IAT entry address for DLLFunction, where there stores the address for DLLFunction().
调用者图像中IAT的RVA(相对视觉地址)为0x9000,其中存储了导入函数的地址。
RVA Import Function Address
0x9000 0x60fd1014 // DLLFunction
0x9004 0x60fdxxxx // someOtherDLLFunction0
0x9008 0x60fdxxxx // someOtherDLLFunction1
...
为什么编译器不生成相关的CALL指令?
如果使用相对 CALL 指令,加载器不需要像这样为所有这些 CALL 指令固定地址。
【问题讨论】:
标签: visual-studio dll x86 dllimport