diff mbox series

Exclude libmsvcrt and similar libraries from being autoexported from DLLs

Message ID 20171123102953.68132-1-martin@martin.st
State New
Headers show
Series Exclude libmsvcrt and similar libraries from being autoexported from DLLs | expand

Commit Message

Martin Storsjo Nov. 23, 2017, 10:29 a.m. UTC
In the latest git version of mingw-w64, one can set the default
libmsvcrt.a to actually be the import library of another CRT version,
to facilitate switching to ucrtbase.dll. In these versions, the
traditional libmsvcrt.a (for linking to msvcrt.dll) is also provided
with the name libmsvcrt-os.a.

The import libraries for the CRT also contain a number of compatibility
wrapper functions. The ones in libmsvcrt.a have so far been excluded
automatically since they in most cases come with a corresponding
__imp_foo function. None of these make sense to export automatically
from a DLL though, so add these libraries to the exclude list.

libucrtbase.a contains a number of compatibility wrapper functions
that don't have a corresponding __imp_foo symbol, which cause
these symbols to be exported from DLLs.

This can be worked around on the mingw-w64 side by adding extra
__imp_ symbols, but since they aren't strictly necessary for linking
to succeed, it's probably better long-term to add these libraries to
the exclusion list.

ld/ChangeLog:
2017-11-23  Martin Storsjo  <martin@martin.st>

       * pe-dll.c: Exclude libmsvcrt, libmsvcrt-os and libucrtbase.
---
 ld/ChangeLog | 4 ++++
 ld/pe-dll.c  | 3 +++
 2 files changed, 7 insertions(+)

-- 
2.13.6 (Apple Git-96)

Comments

Kai Tietz Nov. 23, 2017, 11 a.m. UTC | #1
Hello,

yes, that patch makes sense IMHO.  You have made papers with FSF for
binutils?  Nevertheless patch is small enough to be accepted (I
assume).

Nick, could you take care please?

Thanks,
Kai

2017-11-23 11:29 GMT+01:00 Martin Storsjo <martin@martin.st>:
> In the latest git version of mingw-w64, one can set the default

> libmsvcrt.a to actually be the import library of another CRT version,

> to facilitate switching to ucrtbase.dll. In these versions, the

> traditional libmsvcrt.a (for linking to msvcrt.dll) is also provided

> with the name libmsvcrt-os.a.

>

> The import libraries for the CRT also contain a number of compatibility

> wrapper functions. The ones in libmsvcrt.a have so far been excluded

> automatically since they in most cases come with a corresponding

> __imp_foo function. None of these make sense to export automatically

> from a DLL though, so add these libraries to the exclude list.

>

> libucrtbase.a contains a number of compatibility wrapper functions

> that don't have a corresponding __imp_foo symbol, which cause

> these symbols to be exported from DLLs.

>

> This can be worked around on the mingw-w64 side by adding extra

> __imp_ symbols, but since they aren't strictly necessary for linking

> to succeed, it's probably better long-term to add these libraries to

> the exclusion list.

>

> ld/ChangeLog:

> 2017-11-23  Martin Storsjo  <martin@martin.st>

>

>        * pe-dll.c: Exclude libmsvcrt, libmsvcrt-os and libucrtbase.

> ---

>  ld/ChangeLog | 4 ++++

>  ld/pe-dll.c  | 3 +++

>  2 files changed, 7 insertions(+)

>

> diff --git a/ld/ChangeLog b/ld/ChangeLog

> index 4cfcf6d8ba..b4abe6e1e6 100644

> --- a/ld/ChangeLog

> +++ b/ld/ChangeLog

> @@ -1,3 +1,7 @@

> +2017-11-23  Martin Storsjo  <martin@martin.st>

> +

> +       * pe-dll.c: Exclude libmsvcrt, libmsvcrt-os and libucrtbase.

> +

>  2017-11-21  Nick Clifton  <nickc@redhat.com>

>

>         PR 22419

> diff --git a/ld/pe-dll.c b/ld/pe-dll.c

> index aee7b9dacb..d916766ea0 100644

> --- a/ld/pe-dll.c

> +++ b/ld/pe-dll.c

> @@ -344,6 +344,9 @@ static const autofilter_entry_type autofilter_liblist[] =

>    { STRING_COMMA_LEN ("libsupc++") },

>    { STRING_COMMA_LEN ("libobjc") },

>    { STRING_COMMA_LEN ("libgcj") },

> +  { STRING_COMMA_LEN ("libmsvcrt") },

> +  { STRING_COMMA_LEN ("libmsvcrt-os") },

> +  { STRING_COMMA_LEN ("libucrtbase") },

>    { NULL, 0 }

>  };

>

> --

> 2.13.6 (Apple Git-96)

>
Martin Storsjo Nov. 23, 2017, 11:05 a.m. UTC | #2
On Thu, 23 Nov 2017, Kai Tietz wrote:

> Hello,

>

> yes, that patch makes sense IMHO.  You have made papers with FSF for

> binutils?  Nevertheless patch is small enough to be accepted (I

> assume).


Yes, I did the paperwork for binutils/gcc a couple years ago, even though 
I didn't end up getting anything significant merged back then.

// Martin
Nick Clifton Nov. 23, 2017, 12:09 p.m. UTC | #3
Hi Kai, Hi Martin,

> Nick, could you take care please?


Done. :-)

Cheers
  Nick
diff mbox series

Patch

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4cfcf6d8ba..b4abe6e1e6 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,7 @@ 
+2017-11-23  Martin Storsjo  <martin@martin.st>
+
+	* pe-dll.c: Exclude libmsvcrt, libmsvcrt-os and libucrtbase.
+
 2017-11-21  Nick Clifton  <nickc@redhat.com>
 
 	PR 22419
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index aee7b9dacb..d916766ea0 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -344,6 +344,9 @@  static const autofilter_entry_type autofilter_liblist[] =
   { STRING_COMMA_LEN ("libsupc++") },
   { STRING_COMMA_LEN ("libobjc") },
   { STRING_COMMA_LEN ("libgcj") },
+  { STRING_COMMA_LEN ("libmsvcrt") },
+  { STRING_COMMA_LEN ("libmsvcrt-os") },
+  { STRING_COMMA_LEN ("libucrtbase") },
   { NULL, 0 }
 };