Re: Excude whole libs when building w32 dlls with -export-all [Refresh]

2002-05-30 Thread Charles Wilson

FWIW, it appears that this patch was committed on 21 May 2002.

--Chuck


Danny Smith wrote:

 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.





RE: Excude whole libs when building w32 dlls with -export-all [Refresh]

2002-05-20 Thread Danny Smith

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) 

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

2002-04-27 Thread Robert Collins



 -Original Message-
 From: Danny Smith [mailto:[EMAIL PROTECTED]] 
 Sent: Saturday, April 27, 2002 5:48 PM
 To: binutils
 Cc: cygwin-apps
 Subject: Excude whole libs when building w32 dlls with -export-all
 
 
 The auto-export feature of ld for pe-dll targets would be 
 more flexible with an option to exclude whole archive libs 
 from export.

Can we detect libs and automatically exclude symbols from shared
libraries? 

i.e. when linking against libcygwin.a, ALL symbols therein are from a
dll, so -by default- should not be exported.

That would remove the need for many default exclusions, and be closer to
unix behaviour (as I understand it).

Rob



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

2002-04-27 Thread Charles Wilson

Robert Collins wrote:


 Can we detect libs and automatically exclude symbols from shared
 libraries? 
 
 i.e. when linking against libcygwin.a, ALL symbols therein are from a
 dll, so -by default- should not be exported.


Picky point: that's not true in this case.  libcygwin.a, unlike most 
import libs, contains actual code as well as import thunks for cygwin1.dll.

 
 That would remove the need for many default exclusions, and be closer to
 unix behaviour (as I understand it).


We already exclude symbols beginning with _imp_, and Ralf's patch (well, 
part of it, IIRC) adds an additional exclusion for symbols beginning 
with _nm_.  And, of course, the data thunks _fu0_ are never re-exported.

I dunno if we need something *less* granular (e.g. never never never 
export ANY symbol of ANY kind that comes from *.dll) ... maybe so.  But, 
this is a separate argument from Danny's proposed patch.

Danny is addressing Ralf's long-desired ability to exclude symbols from 
static convenience libraries that are used by multiple KDE dlls. 
Without this ability, multiple KDE DLLs have export the same symbols, 
leading to linking errors when building apps.  This has forced Ralf to 
se a specially hacked binutils for all KDE builds.

I like Danny's patch, as it is more flexible than the one Ralf has been 
using (Ralf's was basically:  --exclude-libs -lfoo -bar 
--no-exclude-libs -baz IIRC, so that symbols from libfoo and libbar 
would not be exported, but symbols from libbaz would be).

Ordinarily, at this point, I'd say: I'll build a binutils and give your 
patch a try -- except for the reports that say binutils has been broken 
on x86 since mid-December.  I *really* don't have the time right now to 
track THAT down, just to test Danny's patch -- I'm in hardcore 
dissertation mode, right now...

--Chuck




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

2002-04-27 Thread Robert Collins



 -Original Message-
 From: Robert Collins 
 Sent: Sunday, April 28, 2002 3:36 AM

 Yeah well :}. Actually most import libs can be considered to 
 contain code - that's what the standard stub is. The 


Oops. The standar=d stub *used* to be. *blush*.

Rob