Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Linker    [ Add a report in this area ]  
Report #:  123165   Status: Closed
[Win64] Relocation Table Missing from 64-bit .EXE
Project:  Delphi Build #:  XE3, ... XE5
Version:    19.2 Submitted By:   Stefan Fleischmann
Report Type:  Feature Specification issue Date Reported:  3/12/2014 9:00:29 AM
Severity:    Serious / Highly visible problem Last Updated: 4/15/2014 6:30:57 PM
Platform:    All versions Internal Tracking #:   48679
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE6
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 10
Description
Whenever I compile a program for Win64 with Delphi XE3, the  resulting .exe file seems to lack a relocation table. When I check the file, I see that the IMAGE_FILE_RELOCS_STRIPPED flag in the PE header is set, as if in my code I had the line
{$SetPEFlags IMAGE_FILE_RELOCS_STRIPPED}
but I don't! Also in the project's linking options there are no extra PE header flags set.

If I manually remove the flag from the .exe file (i.e. remove the flag that says that the relocation table is missing), with a hex editor, then Windows will not execute it. I guess because the relocation table is in fact missing.

More information about this flag here: http://hallvards.blogspot.hk/2006/09/hack12-create-smaller-exe-files.html
Only I want to do the exact opposite of what is described on that page. I do not want to strip the relocation table, I want to keep it. I do not understand why it is missing. If I compile the same projects for Win32, then the table exists.

An .exe file without relocation table is smaller (great), but can only be loaded at the specified address. For full address space layout randomization (ASLR) in the process, the load address of the image of the .exe file should be variable as well and randomly decided by the operating system. That requires a relocation table.

I am thinking Delphi XE3 is doing something wrong. If there is a misunderstanding on my part, sorry... Thanks a lot for any insights.
Steps to Reproduce:
Please see this thread.
https://forums.embarcadero.com/thread.jspa?messageID=639392&tstart=0
Workarounds
None
Attachment
None
Comments

Alex Alexeev at 3/19/2014 1:28:41 AM -
Why do you need relocation table for EXE?

I do not think this is a bug. Relocs table is missing because there is no need for it, not because you specified it.

Alex Alexeev at 3/19/2014 1:40:50 AM -
I just checked that relocation table will be added to your exe if you enable ASLR and NX.

Server Response from: ETNACODE01