PE: Difference between revisions

3 bytes removed ,  14 years ago
[unchecked revision][unchecked revision]
No edit summary
Line 32:
 
=== Position Independent Code ===
If each section specifies which virtual address to load it in to, you may be wondering how multiple DLLs can exist in one virtual address space without conflict. It is true that most code you'll find in a PE file (DLL or otherwise) is position dependent and linked to a specific address. However to resolve this issue there exist a structure called a Relocation Table that is attached to each section entry. If The table is basically a HUGE long list of every address stored in that section so you can offset it to the location where you loaded the section.
 
Because addresses can point across section borders, relocations should be done after each section is loaded into memory. Then reiterate over each section, iterate through each address in the Relocation Table, find out what section that RVA exists in and add/subtract the offset between that section's linked virtual address and the section's virtual address you loaded it into.
Anonymous user