Excude whole libs when building w32 dlls with -export-all

Danny Smith danny_r_smith_2001@yahoo.co.nz
Sat Apr 27 01:42:00 GMT 2002


The auto-export feature of ld for pe-dll targets would be more flexible
with an option to exclude whole archive libs from export.

Here is an example:

test.c==================================================
/* test.c */
#include <libiberty.h> /* for lbasename */

__attribute__((dllexport))  void
dll_test (void)
{
  printf("%s\n", lbasename ("./test.c"));
};
test.c==================================================


This command:

gcc -shared -o test.dll test.c  -Wl,--export-all -liberty

currently produces a dll that exports these symbols:

dll_test
lbasename    ; from libiberty.a
_sch_istable ; from libiberty.a
_sch_tolower ; from libiberty.a
_sch_toupper ; from libiberty.a
 

The following patch allows exclusion of specified libs or all libs.
So that:
gcc -shared -o test.dll test.c  -Wl,--export-all,
  -Wl,--exclude-libs,libiberty.a \
  -liberty

exports only dll_test.

-Wl,--exclude-libs,ALL
would do the same.

Explicitly listing exports in .def file will override the --exclude-lib switch,
eg

test.def==============================================

;test.def
EXPORTS
lbasename

test.def=============================================

gcc -shared -o test.dll test.c test.def  -Wl,--export-all,
  -Wl,--exclude-libs,libiberty.a \
  -liberty

exports:
dll_test
lbasename

The patch also adds a few more default system lib excludes. I haven't tried
-shared with Ada runtime libs.  libgnat.a maybe another one that should be
excluded by default.

2002-04-27  Danny Smith  <dannysmith@users.sourceforge.net>

	* emultempl/pe.em (OPTION_EXCLUDE_LIBS): Add new define.
	(longopts): Add new option --exclude-libs.
	(gld_${EMULATION_NAME}_list_options): Give quick help about it.
	(gld_${EMULATION_NAME}_parse_args): Use it.
	* pe-dll.h (pe_dll_add_excludes): Add second param to prototype.
	* pe-dll.c (exclude_list_struct): Add field type to distinguish
	symbols from whole archives.
	(pe_dll_add_excludes): Set excludes->type.
	(auto_export): Add new variable libname and set to
 	archive basename if abfd. Use it when filtering default and
	user-specified libarary excludes. Let string "ALL" mean all libs
	when filtering user-specified libs.
	* ld.texinfo: Document --exclude-libs.

	* pe-dll.c (autofilter_liblist): Add more libs excluded by
	 default.
	
Diff file is attached.  There are some long lines in pe.em
(gld_${EMULATION_NAME}_list_options) that may get wrapped. 

Danny




http://messenger.yahoo.com.au - Yahoo! Messenger
- A great way to communicate long-distance for FREE!
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pe-dll-auto-export.diff
URL: <http://cygwin.com/pipermail/cygwin-apps/attachments/20020427/a6b5a934/attachment.ksh>


More information about the Cygwin-apps mailing list