The previous post had incorrect subject heading. This is a repost. Sorry.
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 [EMAIL PROTECTED]
* 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!
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 - 1.67
+++ src/ld/ld.texinfo 20 May 2002 22:07:44 -
@@ -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 - 1.39
+++ src/ld/pe-dll.c 20 May 2002 22:07:50 -
@@ -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)