linker

Joined
Feb 12, 2008
Messages
108
Reaction score
0
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.
--------------------


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,961
Messages
2,570,130
Members
46,689
Latest member
liammiller

Latest Threads

Top