Mail Archives: cygwin-apps/2002/05/20/18:47:54
--0-703562413-1021934755=:11533
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
This is a refresh of:
http://sources.redhat.com/ml/binutils/2002-04/msg00472.html
The patch allows exclusion of symbols in specified libs (optionally all
libs) from export table when producing dll's using ld --shared.
Listing of symbol names in a .def file forces those specific symbols
to be included even if they are contained in excluded libs.
Can this be reviewed?
The diff updated to current CVS is attached.
2002-05-21 Danny Smith <dannysmith AT users DOT sourceforge DOT 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.
http://briefcase.yahoo.com.au - Yahoo! Briefcase
- Save your important files online for easy access!
--0-703562413-1021934755=:11533
Content-Type: text/plain; name="exclude_libs.diff"
Content-Description: exclude_libs.diff
Content-Disposition: inline; filename="exclude_libs.diff"
Index: src/ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.67
diff -u -p -r1.67 ld.texinfo
--- src/ld/ld.texinfo 8 Apr 2002 00:24:02 -0000 1.67
+++ src/ld/ld.texinfo 20 May 2002 22:07:44 -0000
@@ -1656,6 +1656,14 @@ These cygwin-excludes are: @code{_cygwin
Specifies a list of symbols which should not be automatically
exported. The symbol names may be delimited by commas or colons.
+@kindex --exclude-libs
+@item --exclude-libs @var{lib},@var{lib},...
+Specifies a list of archive libraries from which symbols should not be automatically
+exported. The library names may be delimited by commas or colons. Specifying
+@code{--exclude-libs ALL} excludes symbols in all archive libraries from
+automatic export. Symbols explicitly listed in a .def file are still exported,
+regardless of this option.
+
@kindex --file-alignment
@item --file-alignment
Specify the file alignment. Sections in the file will always begin at
Index: src/ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.39
diff -u -p -r1.39 pe-dll.c
--- src/ld/pe-dll.c 3 May 2002 13:48:55 -0000 1.39
+++ src/ld/pe-dll.c 20 May 2002 22:07:50 -0000
@@ -368,14 +373,16 @@ typedef struct exclude_list_struct
{
char *string;
struct exclude_list_struct *next;
+ int type;
}
exclude_list_struct;
static struct exclude_list_struct *excludes = 0;
void
-pe_dll_add_excludes (new_excludes)
+pe_dll_add_excludes (new_excludes, type)
const char *new_excludes;
+ const int type;
{
char *local_copy;
char *exclude_string;
@@ -391,6 +398,7 @@ pe_dll_add_excludes (new_excludes)
xmalloc (sizeof (struct exclude_list_struct)));
new_exclude->string = (char *) xmalloc (strlen (exclude_string) + 1);
strcpy (new_exclude->string, exclude_string);
+ new_exclude->type = type;
new_exclude->next = excludes;
excludes = new_exclude;
}
@@ -398,6 +406,7 @@ pe_dll_add_excludes (new_excludes)
free (local_copy);
}
+
/* abfd is a bfd containing n (or NULL)
It can be used for contextual checks. */
@@ -410,6 +419,9 @@ auto_export (abfd, d, n)
int i;
struct exclude_list_struct *ex;
autofilter_entry_type *afptr;
+ const char * libname = 0;
+ if (abfd && abfd->my_archive)
+ libname = lbasename (abfd->my_archive->filename);
/* We should not re-export imported stuff. */
if (strncmp (n, "_imp__", 6) == 0)
@@ -429,14 +441,14 @@ auto_export (abfd, d, n)
n, abfd, abfd->my_archive);
/* First of all, make context checks:
- Don't export anything from libgcc. */
- if (abfd && abfd->my_archive)
+ Don't export anything from standard libs. */
+ if (libname)
{
afptr = autofilter_liblist;
while (afptr->name)
{
- if (strstr (abfd->my_archive->filename, afptr->name))
+ if (strncmp (libname, afptr->name, afptr->len) == 0 )
return 0;
afptr++;
}
@@ -495,8 +507,17 @@ auto_export (abfd, d, n)
}
for (ex = excludes; ex; ex = ex->next)
- if (strcmp (n, ex->string) == 0)
- return 0;
+ {
+ if (ex->type == 1) /* exclude-libs */
+ {
+ if (libname
+ && ((strcmp (libname, ex->string) == 0)
+ || (stricmp ("ALL", ex->string) == 0)))
+ return 0;
+ }
+ else if (strcmp (n, ex->string) == 0)
+ return 0;
+ }
return 1;
}
Index: src/ld/pe-dll.h
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.h,v
retrieving revision 1.5
diff -u -p -r1.5 pe-dll.h
--- src/ld/pe-dll.h 12 Sep 2001 15:58:10 -0000 1.5
+++ src/ld/pe-dll.h 20 May 2002 22:07:50 -0000
@@ -36,7 +36,7 @@ extern int pe_dll_compat_implib;
extern int pe_dll_extra_pe_debug;
extern void pe_dll_id_target PARAMS ((const char *));
-extern void pe_dll_add_excludes PARAMS ((const char *));
+extern void pe_dll_add_excludes PARAMS ((const char *, const int));
extern void pe_dll_generate_def_file PARAMS ((const char *));
extern void pe_dll_generate_implib PARAMS ((def_file *, const char *));
extern void pe_process_import_defs PARAMS ((bfd *, struct bfd_link_info *));
Index: src/ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.59
diff -u -p -r1.59 pe.em
--- src/ld/emultempl/pe.em 15 Feb 2002 02:11:05 -0000 1.59
+++ src/ld/emultempl/pe.em 20 May 2002 22:07:56 -0000
@@ -221,6 +221,7 @@ gld_${EMULATION_NAME}_before_parse()
#define OPTION_DLL_ENABLE_AUTO_IMPORT (OPTION_NO_DEFAULT_EXCLUDES + 1)
#define OPTION_DLL_DISABLE_AUTO_IMPORT (OPTION_DLL_ENABLE_AUTO_IMPORT + 1)
#define OPTION_ENABLE_EXTRA_PE_DEBUG (OPTION_DLL_DISABLE_AUTO_IMPORT + 1)
+#define OPTION_EXCLUDE_LIBS (OPTION_ENABLE_EXTRA_PE_DEBUG + 1)
static struct option longopts[] = {
/* PE options */
@@ -247,6 +248,7 @@ static struct option longopts[] = {
{"output-def", required_argument, NULL, OPTION_OUT_DEF},
{"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL},
{"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMBOLS},
+ {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
{"kill-at", no_argument, NULL, OPTION_KILL_ATS},
{"add-stdcall-alias", no_argument, NULL, OPTION_STDCALL_ALIASES},
{"enable-stdcall-fixup", no_argument, NULL, OPTION_ENABLE_STDCALL_FIXUP},
@@ -333,6 +335,7 @@ gld_${EMULATION_NAME}_list_options (file
fprintf (file, _(" --disable-stdcall-fixup Don't link _sym to _sym AT nn\n"));
fprintf (file, _(" --enable-stdcall-fixup Link _sym to _sym AT nn without warnings\n"));
fprintf (file, _(" --exclude-symbols sym,sym,... Exclude symbols from automatic export\n"));
+ fprintf (file, _(" --exclude-libs lib,lib,... Exclude libraries from automatic export\n"));
fprintf (file, _(" --export-all-symbols Automatically export all globals to DLL\n"));
fprintf (file, _(" --kill-at Remove @nn from exported symbols\n"));
fprintf (file, _(" --out-implib <file> Generate import library\n"));
@@ -586,7 +589,10 @@ gld_${EMULATION_NAME}_parse_args(argc, a
pe_dll_export_everything = 1;
break;
case OPTION_EXCLUDE_SYMBOLS:
- pe_dll_add_excludes (optarg);
+ pe_dll_add_excludes (optarg, 0);
+ break;
+ case OPTION_EXCLUDE_LIBS:
+ pe_dll_add_excludes (optarg, 1);
break;
case OPTION_KILL_ATS:
pe_dll_kill_ats = 1;
--0-703562413-1021934755=:11533--
- Raw text -