Bug 21992 - Invalid entry point used for executables on Windows
Summary: Invalid entry point used for executables on Windows
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.29
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-23 08:14 UTC by Frediano Ziglio
Modified: 2020-01-11 13:28 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments
Proposed patch (626 bytes, patch)
2017-08-23 08:14 UTC, Frediano Ziglio
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frediano Ziglio 2017-08-23 08:14:41 UTC
Created attachment 10359 [details]
Proposed patch

If you specify -pie option a different entry point is used for PE/PE+ executables, specifically the entry point for a DLL.

This for instance affects attempt to use --dynamicbase which needs an relocatable executable. As different thread on internet suggests to use -pie option to enable relocations on an executable the current behaviour seems wrong.

I tested with a project we have and with this patch and --dynamicbase --pie --subsystem console the correct entry point is called.
Comment 1 Hannes Domani 2020-01-11 13:28:55 UTC
(In reply to Frediano Ziglio from comment #0)
> If you specify -pie option a different entry point is used for PE/PE+
> executables, specifically the entry point for a DLL.

The workaround with -pie should no longer be necessary any more.
Since https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=dc9bd8c92af67947db44b3cb428c050259b15cd0 the relocation table is no longer stripped if you specify -dynamicbase.