Skip to content

Commit 9969888

Browse files
committed
Bintuils patch to exclude more symbols from export
In bfd is a list of known libraries whose symbols are excluded when exporting all symbols, the default behavior when no exports are chosen, or with --export-all-symbols. The list is incomplete for w64dk and is missing 15 additional "standard" libraries. The result is that Windows-unaware builds using any of these libraries, including any C++ program due to libpthread, tends to be broken. Instead of adding each library to the list, blanket-exclude all libraries that come from the sysroot. Since libpthread is so important, also add it to the known list. Its absence is essentially a Binutils bug.
1 parent e1d3826 commit 9969888

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/binutils-exclude-sysroot.patch

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
In bfd is a list of known libraries whose symbols are excluded when
2+
exporting all symbols, the default behavior when no exports are chosen,
3+
or with --export-all-symbols. However, the list is incomplete, and the
4+
following "standard" libraries in w64dk also contain definitions that
5+
should never be exported:
6+
7+
* libdloadhelper.a,
8+
* libdxerr8.a,
9+
* libdxerr9.a,
10+
* libgmon.a,
11+
* libmsvcr100.a,
12+
* libmsvcr110.a,
13+
* libmsvcr120.a,
14+
* libmsvcr120_app.a,
15+
* libmsvcr120d.a,
16+
* libmsvcr80.a,
17+
* libmsvcr90.a,
18+
* libmsvcr90d.a,
19+
* libpthread.a (!!!),
20+
* libucrtapp.a, and
21+
* libwinpthread.a
22+
23+
The result is that Windows-unaware builds using any of these libraries,
24+
including any C++ program due to libpthread, tends to be broken. Instead
25+
of adding each library to the list, blanket-exclude all libraries that
26+
come from the sysroot. Since libpthread is so important, also add it to
27+
the known list. Its absence is essentially a Binutils bug.
28+
29+
--- a/ld/pe-dll.c
30+
+++ b/ld/pe-dll.c
31+
@@ -347,4 +347,5 @@
32+
static const autofilter_entry_type autofilter_liblist[] =
33+
{
34+
+ { STRING_COMMA_LEN ("libpthread") },
35+
{ STRING_COMMA_LEN ("libcegcc") },
36+
{ STRING_COMMA_LEN ("libcygwin") },
37+
@@ -575,4 +576,16 @@
38+
libname = lbasename (bfd_get_filename (abfd->my_archive));
39+
40+
+ if (abfd && abfd->my_archive && ld_canon_sysroot)
41+
+ {
42+
+ const char *path = bfd_get_filename (abfd->my_archive);
43+
+ const char *real = lrealpath (path);
44+
+ int len = ld_canon_sysroot_len;
45+
+ int match = !filename_ncmp (real, ld_canon_sysroot, len)
46+
+ && IS_DIR_SEPARATOR (real[len]);
47+
+ free (real);
48+
+ if (match)
49+
+ return 0;
50+
+ }
51+
+
52+
key.name = key.its_name = (char *) n;
53+

0 commit comments

Comments
 (0)