Resource section comes before the relocation table in dlls produced by FPC
Original Reporter info from Mantis: dmitry@dimastr.com
-
Reporter name: Dmitry Streblechenko
Original Reporter info from Mantis: dmitry@dimastr.com
- Reporter name: Dmitry Streblechenko
Description:
I have a dll that I compile both in Delphi and FPC. The dll can be customized using an end-user tool that adds a custom resource to the dll by calling BeginUpdateResource/UpdateResource/EndUpdateResource.
No problem with a 32 bit dll compiled by Delphi. The 64 bit dll compiled in FPC becomes corrupted after calling BeginUpdateResource/EndUpdateResource (without actually moddifying any resources there).
Looking at the dll, it appears that Delphi linker first inserts the .reloc section, then adds .rsrc section last.
The FPC linker on the other hand, first inserts .rsrc section follower by the .reloc section (and then a couple more sections - .stab and .stabstrI.
My guess is that modifying the .rsrc section invalidates the .reloc section thus rendering the dll corrupted - http://blogs.msdn.com/b/michkap/archive/2008/08/21/8883552.aspx
Is there any way I can make the FPC linker reorder the sections and put the .rsrc section last?
Steps to reproduce:
-
Create a dll in FPC. Just for testing purposes, eexport a DllRegietrServer function so that teh dll can be loaded and invoked by regsvr32.exe
-
Create an exe that calls BeginUpdateResource / UpdateResource on the dll from step 1. Doing so corrupts the dll and regsvr32.exe is no longer able to load the dll.
Mantis conversion info:
- Mantis ID: 16852
- OS: Windows
- OS Build: all
- Platform: Windows x64
- Version: 2.5.1
- Fixed in version: 2.6.0
- Fixed in revision: 18904 (#23b11793)
- Monitored by: » dmitry@dimastr.com (Dmitry Streblechenko), » scribly (Eric Heijnen)