G
George3
Hello everyone,
Here are two conflicting documents from MSDN. About whether linker will
modify code generated by compiler. I quote both of them here.
Document (1) mentioned linker can not modify any code generated by
compiler, but document (2) mentioned linker will replace address code
generated by compiler during fixup process.
Which one is correct?
1.
http://blogs.msdn.com/oldnewthing/archive/2006/07/21/673830.aspx
--------------------
But the linker can't rewrite the code generated by the compiler.
--------------------
2.
http://www.microsoft.com/msj/0797/hood0797.aspx
--------------------
Consider a call to a function named Foo in C++:
//...
Foo();
//...
The exact bytes emitted from a 32-bit C++ compiler will be this:
E8 00 00 00 00
The 0xE8 is the CALL instruction opcode. The next DWORD should contain
the offset to the Foo function (relative to the CALL instruction). It's
pretty clear that Foo probably isn't zero bytes away from the CALL
instruction. Simply put, this code wouldn't work as expected if you were
to execute it. The code is broken, and needs to be fixed up. In the
above example, the linker needs to replace the DWORD following the CALL
opcode with the correct address of Foo.
Here are two conflicting documents from MSDN. About whether linker will
modify code generated by compiler. I quote both of them here.
Document (1) mentioned linker can not modify any code generated by
compiler, but document (2) mentioned linker will replace address code
generated by compiler during fixup process.
Which one is correct?
1.
http://blogs.msdn.com/oldnewthing/archive/2006/07/21/673830.aspx
--------------------
But the linker can't rewrite the code generated by the compiler.
--------------------
2.
http://www.microsoft.com/msj/0797/hood0797.aspx
--------------------
Consider a call to a function named Foo in C++:
//...
Foo();
//...
The exact bytes emitted from a 32-bit C++ compiler will be this:
E8 00 00 00 00
The 0xE8 is the CALL instruction opcode. The next DWORD should contain
the offset to the Foo function (relative to the CALL instruction). It's
pretty clear that Foo probably isn't zero bytes away from the CALL
instruction. Simply put, this code wouldn't work as expected if you were
to execute it. The code is broken, and needs to be fixed up. In the
above example, the linker needs to replace the DWORD following the CALL
opcode with the correct address of Foo.