有关目标文件链接时怎样实现重定位的问题
本帖最后由 kingyaying 于 2013-08-26 08:26:19 编辑 我想知道目标文件里面的变量和函数是以地址存在还是仍以符号形式存在?因为目标文件已经经过是二进制文件所以我觉得已经不是符号。可是因为引用其他模块的变量或函数的语句里目标文件在链接时还需要找到引用的别的目标文件里的变量和函数地址,这个是怎么找到的呢?不是已经不存在符号了怎么还可以找到?另外,有时候目标文件用的是早就写好的dll文件,那么那些dll文件里各种变量和函数应该都不是符号的形式存在了,那么需要调用他们的程序的目标文件怎么知道所需的函数和变量的地址的呢?
[解决办法]
推荐阅读《Windows PE权威指南》
Run-Time Type Information
Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution. RTTI was added to the C++ language because many vendors of class libraries were implementing this functionality themselves. This caused incompatibilities between libraries. Thus, it became obvious that support for run-time type information was needed at the language level.
For the sake of clarity, this discussion of RTTI is almost completely restricted to pointers. However, the concepts discussed also apply to references.
There are three main C++ language elements to run-time type information:
The dynamic_cast operator.
Used for conversion of polymorphic types. See dynamic_cast Operator for more information.
The typeid operator.
Used for identifying the exact type of an object.
The type_info class.
Used to hold the type information returned by the typeid operator.
[解决办法]
会有列表专门负责这些东西