This is the mail archive of the 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]

Library strip, automatic imports and specific imports


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

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)

<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
        strip --strip-unneeded libmydll2.dll.a

        rm -f *.o
        rm -f *.a
        rm -f *.dll
        rm -f *.exe
        rm -f *.stackdump
<File fn="dllcode.c">
extern __declspec(dllimport) level2;
int somebss;
int somedata=2;
int sometext()
<File fn="dllcode2.c">
__declspec(dllexport) int level2=1;
<File fn="maincode.c">
extern __declspec(dllimport) int somebss;
extern __declspec(dllimport) int somedata;
extern __declspec(dllimport) int sometext();
int main()

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.



Unsubscribe info:
Problem reports:

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