Recent

Author Topic: Linker - making .rsrc section last?  (Read 5780 times)

dmitry

  • New Member
  • *
  • Posts: 32
    • Outlook Developer Tools
Linker - making .rsrc section last?
« on: June 21, 2010, 09:06:30 am »
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?

Thanks!
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12201
  • FPC developer.
Re: Linker - making .rsrc section last?
« Reply #1 on: July 05, 2010, 12:02:34 pm »
Could you open a bugticket for this? It sounds like something the devels would be interested in.

dmitry

  • New Member
  • *
  • Posts: 32
    • Outlook Developer Tools
Re: Linker - making .rsrc section last?
« Reply #2 on: July 06, 2010, 04:19:58 am »
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12201
  • FPC developer.
Re: Linker - making .rsrc section last?
« Reply #3 on: July 28, 2010, 05:29:17 am »
Did you try to reorder the lines near cgcoff:2338, and rebuild the compiler?

They read:

    UpdateDataDir('.idata',PE_DATADIR_IDATA);
    UpdateDataDir('.edata',PE_DATADIR_EDATA);
    UpdateDataDir('.rsrc',PE_DATADIR_RSRC);
    UpdateDataDir('.pdata',PE_DATADIR_PDATA);
    UpdateDataDir('.reloc',PE_DATADIR_RELOC);

 

TinyPortal © 2005-2018