delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/07/03/10:40:45

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <486CE4BF.9040409@users.sourceforge.net>
Date: Thu, 03 Jul 2008 09:39:59 -0500
From: "Yaakov (Cygwin Ports)" <yselkowitz AT users DOT sourceforge DOT net>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: binutils: ld --export-dynamic
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------060700050701050503020403
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

-----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-----

--------------060700050701050503020403
Content-Type: text/plain;
 name="dlopen-self.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="dlopen-self.c"

#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);
}


--------------060700050701050503020403
Content-Type: text/plain; charset=us-ascii

--
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/
--------------060700050701050503020403--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019