This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 6744
  --export-dynamic does nothing for Cygwin .exe's Last modified: 2009-05-24 03:23:44
     Query page      Enter new bug
Bug#: 6744   Hardware:   Reporter: Cygwin/X maintainer <yselkowitz@cygwin.com>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: FIXED   Severity:  
Assigned To: Dave Korn <dave.korn.cygwin@gmail.com>   Target Milestone:  
Summary:
Keywords:

Attachment Description Type Created Actions
dlopen-self.c dlopen-self test case text/plain 2008-07-13 20:13 Edit None
pr6744.diff Add warning and docs. patch 2009-04-01 18:16 Edit | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 6744 depends on: Show dependency tree
Show dependency graph
Bug 6744 blocks:

Additional Comments:


Leave as RESOLVED FIXED
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2008-07-13 20:13
When linking a program with -Wl,--export-dynamic, no symbols are
exported.  The problem arises when the executable needs to either dlopen
itself, or when it has plugins which are "linked" against it.  Both
scenarios are not uncommon, particularly with GNOME software.

While this does work on Linux, it does not work on Cygwin with
--export-dynamic; only --export-all-symbols, an i386PE-specific flag,
will accomplish this.

I'm attaching a test case; it's a simplified version of the test used in
LT_SYS_DLOPEN_SELF (prev. AC_LIBTOOL_DLOPEN_SELF):

$ gcc -o test.exe dlopen-self.c && ./test.exe
status = 0

$ gcc -Wl,--export-dynamic -o test.exe dlopen-self.c && ./test.exe
status = 0

$ gcc -Wl,--export-all-symbols -o test.exe dlopen-self.c && ./test.exe
status = 1

Running 'objdump -p test.exe' will also show that the export table is
only generated in the last case.

I would appreciate your input on this issue.

------- Additional Comment #1 From Cygwin/X maintainer 2008-07-13 20:13 -------
Created an attachment (id=2826)
dlopen-self test case

------- Additional Comment #2 From Dave Korn 2009-03-23 13:12 -------
--export-dynamic is an ELF format option, and --export-all-symbols is the PE
equivalent.  We could reasonably make --export-dynamic a synonym for PE, I expect.

------- Additional Comment #3 From Cygwin/X maintainer 2009-03-24 02:02 -------
(In reply to comment #2)
> --export-dynamic is an ELF format option, and --export-all-symbols is the PE
> equivalent.

Dave, thanks for looking at this.  The ld texinfo docs say nothing about
--export-dynamic being ELF-specific, so if this is indeed the case, that should
be made clear.

> We could reasonably make --export-dynamic a synonym for PE, I expect.

Sounds like a good idea.


------- Additional Comment #4 From Dave Korn 2009-03-24 04:07 -------
(In reply to comment #3)
> (In reply to comment #2)
> > --export-dynamic is an ELF format option, and --export-all-symbols is the PE
> > equivalent.
> 
> Dave, thanks for looking at this.  The ld texinfo docs say nothing about
> --export-dynamic being ELF-specific, so if this is indeed the case, that should
> be made clear.

  Well it's strongly implied by the wording "When creating a dynamically linked
executable ..." that it's not going to apply to platforms that don't support
dynamically linked executables.  This may also imply that the scope is slightly
wider than my assumption of "just Elf", which means the docs maybe are OK as
they are.

  I'm a little (only a little) concerned that if we make it a synonym on PE For
--export-all-symbols, it might confuse people into thinking that other linker
options related to dynamic objects would also function as expected, but they
seem to all be clearly documented as to which platforsm they support.  It would
certainly be technically correct if libtool chose to use --e-a-s rather than
--e-d when linking for a cygwin target, since it's the target-specific equivalent.

  Why not post an RFC on the binutils list asking if anyone can see a downside
of making --e-d a synonym for --e-a-s?

------- Additional Comment #5 From Cygwin/X maintainer 2009-03-24 06:45 -------
> It would certainly be technically correct if libtool chose to use --e-a-s 
> rather than --e-d when linking for a cygwin target, since it's the target-
> specific equivalent.

Good point, changing libtool would cover most, but not all, of the cases.

>   Why not post an RFC on the binutils list asking if anyone can see a downside
> of making --e-d a synonym for --e-a-s?

I don't follow the binutils list nowadays.

------- Additional Comment #6 From Nick Clifton 2009-04-01 14:43 -------
Hi Guys,

  I would prefer not to make -export-dynamic a synonym for -export-all-symbols
for the reason that Dave mentioned.  I would not object to adding code to
generate a warning message saying something like: "--export-dynamic is not
supported for COFF/PE targets, did you mean --export-all-symbols ?".

Cheers
  Nick

------- Additional Comment #7 From Cygwin/X maintainer 2009-04-01 16:18 -------
Chuck has pushed the corresponding libtool patch upstream, so this should handle
many cases where it would be used.  I suppose a warning would be appropriate, as
would clarification in the documentation on this flag.

------- Additional Comment #8 From Dave Korn 2009-04-01 17:41 -------
I'm m(In reply to comment #7)
>  I suppose a warning would be appropriate, as
> would clarification in the documentation on this flag.

I'm working on a patch to do this right now.


------- Additional Comment #9 From Dave Korn 2009-04-01 18:16 -------
Created an attachment (id=3860)
Add warning and docs.

This patch adds warnings to both PE and PE+ emulations, (which are the only
COFF emulations that implement --export-all-symbols).  It also mentions --e-a-s
in the --export-dynamic documentation.

Tested on cygwin so far, will cross-test to x86_64-mingw later but have to go
AFK for a few hours.  "make info" worked on the docs, but make html,pdf and dvi
are all currently broken for me, for what appear to be unrelated reasons.

------- Additional Comment #10 From Cygwin/X maintainer 2009-04-02 03:45 -------
(In reply to comment #9)
> It also mentions --e-a-s in the --export-dynamic documentation.

"PE targets support a similar function to export all symbols from a DLL;"

or EXE, which is actually what I'm more concerned about here.

------- Additional Comment #11 From Dave Korn 2009-04-02 05:10 -------
Thanks for proofreading.  Revised patch (also contains testcase) about to be posted.

------- Additional Comment #12 From cvs-commit@gcc.gnu.org 2009-04-02 14:42 -------
Subject: Bug 6744

CVSROOT:	/cvs/src
Module name:	src
Changes by:	davek@sourceware.org	2009-04-02 14:42:41

Modified files:
	ld             : ld.texinfo ChangeLog 
	ld/emultempl   : pe.em pep.em 
	ld/testsuite/ld-pe: pe.exp 
	ld/testsuite   : ChangeLog 
Added files:
	ld/testsuite/ld-pe: export_dynamic_warning.d 
	                    export_dynamic_warning.s 

Log message:
	ld/ChangeLog
	
	PR ld/6744
	* ld.texinfo (--export-dynamic):  Mention --export-all-symbols.
	* emultempl/pe.em (gld_${EMULATION_NAME}_after_parse):  Issue
	warning if --export-dynamic was passed on command-line.
	* emultempl/pep.em (gld_${EMULATION_NAME}_after_parse):  Likewise.
	
	ld/testsuite/ChangeLog
	
	PR ld/6744
	* ld-pe/export_dynamic_warning.d:  New test control file.
	* ld-pe/export_dynamic_warning.s:  New test source file.
	* ld-pe/pe.exp:  Also run export_dynamic_warning dump test.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/ld.texinfo.diff?cvsroot=src&r1=1.236&r2=1.237
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.1956&r2=1.1957
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/emultempl/pe.em.diff?cvsroot=src&r1=1.147&r2=1.148
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/emultempl/pep.em.diff?cvsroot=src&r1=1.24&r2=1.25
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-pe/export_dynamic_warning.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-pe/export_dynamic_warning.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-pe/pe.exp.diff?cvsroot=src&r1=1.9&r2=1.10
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1066&r2=1.1067


------- Additional Comment #13 From Dave Korn 2009-05-24 03:23 -------
Closing out old PR.

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In