This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

binutils: ld --export-dynamic


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

cgf,

While you're waiting for the binutils list to get back to you, here's
another binutils issue.  This is not a regression in 2.18, but rather a
longstanding difference in Cygwin behaviour versus Linux.

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've attached 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.


Yaakov -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEAREIAAYFAkhs5L4ACgkQpiWmPGlmQSOGSQCdG2UioO9OvKGUS5ZbrDzYfdb/
2rgAoL9sMQjWxj4cf5ZwdwMTkopyQHak
=W78e
-----END PGP SIGNATURE-----
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

#define LT_DLUNKNOWN		0
#define LT_DLNO_USCORE		1
#define LT_DLNEED_USCORE	2

void
fnord()
{
  int i=42;
}

int
main ()
{
  void *self = dlopen (0, RTLD_GLOBAL|RTLD_LAZY);
  int status = LT_DLUNKNOWN;

  if (self)
    {
      if (dlsym (self,"fnord"))          status = LT_DLNO_USCORE;
      else if (dlsym( self,"_fnord"))    status = LT_DLNEED_USCORE;
    }
  else
    puts (dlerror ());

	printf ("status = %i\n", status);
    exit (0);
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]