Bug 21964 - __start_SCN symbols aren't exported anymore
Summary: __start_SCN symbols aren't exported anymore
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.30
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-17 14:55 UTC by Frediano Ziglio
Modified: 2018-03-31 12:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Proposed patch (627 bytes, patch)
2017-08-17 14:55 UTC, Frediano Ziglio
Details | Diff
Updated patch (626 bytes, patch)
2017-08-21 14:38 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-17 14:55:37 UTC
Created attachment 10349 [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 cvs-commit@gcc.gnu.org 2017-08-21 14:31:25 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=487b6440dad57440939fab7afdd84a218b612796

commit 487b6440dad57440939fab7afdd84a218b612796
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Aug 21 13:28:06 2017 +0930

    Make __start/__stop symbols protected visibility
    
    They can't be hidden visibility since apparently people use dlsym to
    look them up.
    
    bfd/
    	PR ld/21964
    	* elf-bfd.h (SYMBOLIC_BIND): Return TRUE for __start/__stop symbols.
    	* elflink.c (bfd_elf_define_start_stop): Rewrite.
    ld/
    	PR ld/21964
    	* testsuite/ld-elf/pr21562a.d: Update for changed start/stop symbols.
    	* testsuite/ld-elf/pr21562b.d: Likewise.
    	* testsuite/ld-elf/pr21562c.d: Likewise.
    	* testsuite/ld-elf/pr21562d.d: Likewise.
    	* testsuite/ld-elf/pr21562e.d: Likewise.
    	* testsuite/ld-elf/pr21562f.d: Likewise.
    	* testsuite/ld-elf/pr21562g.d: Likewise.
    	* testsuite/ld-elf/pr21562h.d: Likewise.
    	* testsuite/ld-elf/pr21562i.d: Likewise.
    	* testsuite/ld-elf/pr21562j.d: Likewise.
    	* testsuite/ld-elf/pr21562k.d: Likewise.
    	* testsuite/ld-elf/pr21562l.d: Likewise.
    	* testsuite/ld-elf/pr21562m.d: Likewise.
    	* testsuite/ld-elf/pr21562n.d: Likewise.
    	* testsuite/ld-elf/sizeofa.d: Likewise.
    	* testsuite/ld-elf/sizeofb.d: Likewise.
    	* testsuite/ld-elf/startofa.d: Likewise.
    	* testsuite/ld-elf/startofb.d: Likewise.
    	* testsuite/ld-gc/pr20022.d: Likewise.
    	* testsuite/ld-gc/start.d: Likewise.
    	* testsuite/ld-elf/pr21964-1a.c: New file.
    	* testsuite/ld-elf/pr21964-1b.c: New file.
    	* testsuite/ld-elf/pr21964-2a.c: New file.
    	* testsuite/ld-elf/pr21964-2b.c: New file.
    	* testsuite/ld-elf/shared.exp: Run PR ld/21964 tests.
Comment 2 Frediano Ziglio 2017-08-21 14:38:06 UTC
Created attachment 10355 [details]
Updated patch
Comment 3 Alan Modra 2017-08-22 13:14:32 UTC
Comment #1 is about the original pr21964, lost when the bugzilla database needed to be restored from backup.  See the thread starting at
http://lists.gnu.org/archive/html/bug-binutils/2017-08/msg00195.html
Comment 4 Frediano Ziglio 2017-08-22 15:01:52 UTC
(In reply to Alan Modra from comment #3)
> Comment #1 is about the original pr21964, lost when the bugzilla database
> needed to be restored from backup.  See the thread starting at
> http://lists.gnu.org/archive/html/bug-binutils/2017-08/msg00195.html

Oh... so they have same id.
Should I open a new bug to avoid these issues?
Comment 5 cvs-commit@gcc.gnu.org 2017-08-22 16:42:48 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8dfb7cbf8401be97077f5919ac7473bdbfa8b692

commit 8dfb7cbf8401be97077f5919ac7473bdbfa8b692
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Aug 22 09:41:21 2017 -0700

    Update PR ld/21964 tests
    
    	* testsuite/ld-elf/pr21964-1a.c (foo): Renamed to ...
    	(foo1): This.
    	* testsuite/ld-elf/pr21964-1b.c: Rewrite.
    	* testsuite/ld-elf/pr21964-1c.c: New file.
    	* testsuite/ld-elf/pr21964-2c.c: Likewise.
    	* testsuite/ld-elf/pr21964-2a.c (foo): Renamed to ...
    	(foo1): This.
    	* testsuite/ld-elf/pr21964-2b.c: Rewrite.
    	* testsuite/ld-elf/shared.exp: Update PR ld/21964 tests.
Comment 6 cvs-commit@gcc.gnu.org 2017-08-23 03:26:59 UTC
The binutils-2_29-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f399679112df997c1416f7993eaac0f5fd76c144

commit f399679112df997c1416f7993eaac0f5fd76c144
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Aug 21 13:28:06 2017 +0930

    Make __start/__stop symbols protected visibility
    
    They can't be hidden visibility since apparently people use dlsym to
    look them up.
    
    bfd/
    	PR ld/21964
    	* elf-bfd.h (SYMBOLIC_BIND): Return TRUE for __start/__stop symbols.
    	* elflink.c (bfd_elf_define_start_stop): Rewrite.
    ld/
    	PR ld/21964
    	* testsuite/ld-elf/pr21562a.d: Update for changed start/stop symbols.
    	* testsuite/ld-elf/pr21562b.d: Likewise.
    	* testsuite/ld-elf/pr21562c.d: Likewise.
    	* testsuite/ld-elf/pr21562d.d: Likewise.
    	* testsuite/ld-elf/pr21562e.d: Likewise.
    	* testsuite/ld-elf/pr21562f.d: Likewise.
    	* testsuite/ld-elf/pr21562g.d: Likewise.
    	* testsuite/ld-elf/pr21562h.d: Likewise.
    	* testsuite/ld-elf/pr21562i.d: Likewise.
    	* testsuite/ld-elf/pr21562j.d: Likewise.
    	* testsuite/ld-elf/pr21562k.d: Likewise.
    	* testsuite/ld-elf/pr21562l.d: Likewise.
    	* testsuite/ld-elf/pr21562m.d: Likewise.
    	* testsuite/ld-elf/pr21562n.d: Likewise.
    	* testsuite/ld-elf/sizeofa.d: Likewise.
    	* testsuite/ld-elf/sizeofb.d: Likewise.
    	* testsuite/ld-elf/startofa.d: Likewise.
    	* testsuite/ld-elf/startofb.d: Likewise.
    	* testsuite/ld-gc/pr20022.d: Likewise.
    	* testsuite/ld-gc/start.d: Likewise.
    	* testsuite/ld-elf/pr21964-1a.c: New file.
    	* testsuite/ld-elf/pr21964-1b.c: New file.
    	* testsuite/ld-elf/pr21964-2a.c: New file.
    	* testsuite/ld-elf/pr21964-2b.c: New file.
    	* testsuite/ld-elf/shared.exp: Run PR ld/21964 tests.
Comment 7 Alan Modra 2017-08-23 10:25:37 UTC
Original 21964 fixed, and new pr21992 created for windows bug
Comment 8 cvs-commit@gcc.gnu.org 2018-01-31 13:12:04 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=823143c6ca8ef4267e67ba03771991e08d09fabd

commit 823143c6ca8ef4267e67ba03771991e08d09fabd
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jan 31 05:10:40 2018 -0800

    Check if __start/__stop symbols are referenced by shared objects
    
    Define  __start/__stop symbols if they are referenced by shared objects,
    not if they are also defined in shared objects.
    
    bfd/
    
    	PR ld/21964
    	* elflink.c (bfd_elf_define_start_stop): Check if __start and
    	__stop symbols are referenced by shared objects.
    
    ld/
    
    	PR ld/21964
    	* testsuite/ld-elf/pr21964-4.c: New file.
    	* testsuite/ld-elf/shared.exp: Run pr21964-4 test on Linux.