Free Pascal => General => Topic started by: _Tom_ on October 03, 2015, 07:38:44 pm

Title: /STUB compiler argument?
Post by: _Tom_ on October 03, 2015, 07:38:44 pm
Is it currently possible to use this function in Freepascal compiler/linker?
Basically it gives you the ability to customize the file header and create double EXEs with both PE and MZ parts in 1 EXE.  Currently I'm doing it via hex editing but its very time consuming to do it every release.
I'm using win32 compiler and running Lazarus in win32.
If it isn't possible are there any other programs that you can use as linkers to link your .o files or any way to use microsoft's linker together with your objects?
Title: Re: /STUB compiler argument?
Post by: Jonas Maebe on October 04, 2015, 11:15:12 am
There's an open feature request for this at , but as you can see we don't have plans to add support for this ourselves.
Title: Re: /STUB compiler argument?
Post by: skalogryz on October 05, 2015, 04:32:08 am
The task itself isn't complicated.

The input Dos executable needs to be prepared for PE header.
Thus the Dos header must be extended up to $40 bytes (the last four bytes must point to the valid PE header)
The relocation table must start from $40, but copied as is (no changes)
If needed the code section must be moved to satisfy paragraph (16-bytes) boundary.