delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/09/17/05:11:43

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
X-Scanned-By: AMaViS at pumpkin.vmfacility.fr
From: "Ivan Warren" <ivan AT vmfacility DOT fr>
To: <cygwin AT cygwin DOT com>
Subject: Library strip, automatic imports and specific imports
Date: Wed, 17 Sep 2003 11:11:22 +0200
Message-ID: <000101c37cfb$a9a675c0$1411d0d4@vmfacility.fr>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id h8H9Bfgw002058

Hello,

First of all, my apologies if this isssue has already been addressed. I
searched the archive but couldn't find anything relevant.

I am running into the following problem :

If I issue a 'strip --strip-unneeded' to a DLL import library (created with
--out-implib), Most .data and/or .bss external references generate linking
errors.

Furthermore, if I specify a __declspec(dllimport) to the reference *AND* the
symbol is referenced by a DLL itself, the application raises SIGSEGV upon
attempting to access the symbol.

I am not sure binary attachments are allowed on this list, so here is a copy
& paste of the files necessary to reproduce the problem :

(note : the Makefile should have the spaces changed to a tab character)

<sample>
<File fn="Makefile">
maincode: maincode.o libmydll.dll.a
        $(CC) $(CFLAGS) -o maincode maincode.o -L. -lmydll

libmydll.dll.a: dllcode.o libmydll2.dll.a
        $(CC) dllcode.o -o cygmydll.dll -shared -L. -lmydll2
-Wl,--out-implib -Wl,libmydll.dll.a
        strip --strip-unneeded libmydll.dll.a

libmydll2.dll.a: dllcode2.o
        $(CC) dllcode2.o -o cygmydll2.dll -shared -Wl,--out-implib
-Wl,libmydll2.dll.a
        strip --strip-unneeded libmydll2.dll.a

clean:
        rm -f *.o
        rm -f *.a
        rm -f *.dll
        rm -f *.exe
        rm -f *.stackdump
</File>
<File fn="dllcode.c">
extern __declspec(dllimport) level2;
int somebss;
int somedata=2;
int sometext()
{
    return(level2);
}
</File>
<File fn="dllcode2.c">
__declspec(dllexport) int level2=1;
</File>
<File fn="maincode.c">
extern __declspec(dllimport) int somebss;
extern __declspec(dllimport) int somedata;
extern __declspec(dllimport) int sometext();
int main()
{
    printf("%d\n",somebss);
    printf("%d\n",somedata);
    printf("%d\n",sometext());
}
</File>
</sample>

If you run './maincode' after make, the programs crashes.

If you remove '__declspec(dllimport) from file 'dllcode.c' the link fails.

If you comment out the 'strip' from the Makefile, the program links AND runs
to completion.

My questions is :

Is this a 'binutil' core issue or something introduced by cygwin ?
Is there a workaround (besides NOT stripping the import library) ?

Note : this issues is a main concern when using 'libtool' because this
behaviour is shown when using a libtool in confunction with
automake/autoconf and a 'make install-strip' is issued.

Thanks,

--Ivan


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


- Raw text -


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