Skip to content

Commit ae24045

Browse files
Ede123Alexpux
authored andcommitted
binutils - add upstream patch for bug in version 2.30 (msys2#3353)
https://sourceware.org/bugzilla/show_bug.cgi?id=22762
1 parent 322f1cf commit ae24045

2 files changed

Lines changed: 153 additions & 3 deletions

File tree

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
From a985e9b9deabd81e16754584f4397a638e9d3f36 Mon Sep 17 00:00:00 2001
2+
From: Nick Clifton <nickc@redhat.com>
3+
Date: Mon, 5 Feb 2018 09:12:42 +0000
4+
Subject: [PATCH] Import patch from mainline to remove PROVODE qualifiers
5+
around definitions of __CTOR_LIST__ and __DTOR_LIST__ in PE linker scripts.
6+
7+
PR 22762
8+
* scripttempl/pe.sc: Remove PROVIDE()s from __CTOR_LIST__ and
9+
__DTOR_LIST__ symbols. Add a comment explaining why this is
10+
necessary.
11+
* scripttemp/pep.sc: Likewise.
12+
* ld.texinfo (PROVIDE): Add a note about the effect of common
13+
symbols.
14+
---
15+
ld/ChangeLog | 14 ++++++++++++++
16+
ld/ld.texinfo | 6 ++++++
17+
ld/scripttempl/pe.sc | 24 ++++++++++++++++++++----
18+
ld/scripttempl/pep.sc | 24 ++++++++++++++++++++----
19+
4 files changed, 60 insertions(+), 8 deletions(-)
20+
21+
diff --git a/ld/ChangeLog b/ld/ChangeLog
22+
index 0f00265..bf129a1 100644
23+
--- a/ld/ChangeLog
24+
+++ b/ld/ChangeLog
25+
@@ -1,3 +1,17 @@
26+
+2018-02-05 Nick Clifton <nickc@redhat.com>
27+
+
28+
+ Import from mainline:
29+
+
30+
+ 2018-02-03 Nick Clifton <nickc@redhat.com>
31+
+
32+
+ PR 22762
33+
+ * scripttempl/pe.sc: Remove PROVIDE()s from __CTOR_LIST__ and
34+
+ __DTOR_LIST__ symbols. Add a comment explaining why this is
35+
+ necessary.
36+
+ * scripttemp/pep.sc: Likewise.
37+
+ * ld.texinfo (PROVIDE): Add a note about the effect of common
38+
+ symbols.
39+
+
40+
2018-01-27 Nick Clifton <nickc@redhat.com>
41+
42+
Back to development.
43+
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
44+
index c89915f..764c401 100644
45+
--- a/ld/ld.texinfo
46+
+++ b/ld/ld.texinfo
47+
@@ -4001,6 +4001,12 @@ underscore), the linker will silently use the definition in the program.
48+
If the program references @samp{etext} but does not define it, the
49+
linker will use the definition in the linker script.
50+
51+
+Note - the @code{PROVIDE} directive considers a common symbol to be
52+
+defined, even though such a symbol could be combined with the symbol
53+
+that the @code{PROVIDE} would create. This is particularly important
54+
+when considering constructor and destructor list symbols such as
55+
+@samp{__CTOR_LIST__} as these are often defined as common symbols.
56+
+
57+
@node PROVIDE_HIDDEN
58+
@subsection PROVIDE_HIDDEN
59+
@cindex PROVIDE_HIDDEN
60+
diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc
61+
index c8a45ca..f56d783 100644
62+
--- a/ld/scripttempl/pe.sc
63+
+++ b/ld/scripttempl/pe.sc
64+
@@ -98,8 +98,22 @@ SECTIONS
65+
${RELOCATING+*(.glue_7t)}
66+
${RELOCATING+*(.glue_7)}
67+
${CONSTRUCTING+
68+
- PROVIDE(___CTOR_LIST__ = .);
69+
- PROVIDE(__CTOR_LIST__ = .);
70+
+ /* Note: we always define __CTOR_LIST__ and ___CTOR_LIST__ here,
71+
+ we do not PROVIDE them. This is because the ctors.o startup
72+
+ code in libgcc defines them as common symbols, with the
73+
+ expectation that they will be overridden by the definitions
74+
+ here. If we PROVIDE the symbols then they will not be
75+
+ overridden and global constructors will not be run.
76+
+
77+
+ This does mean that it is not possible for a user to define
78+
+ their own __CTOR_LIST__ and __DTOR_LIST__ symbols. If that
79+
+ ability is needed a custom linker script will have to be
80+
+ used. (The custom script can just be a copy of this script
81+
+ with the PROVIDE() qualifiers added).
82+
+
83+
+ See PR 22762 for more details. */
84+
+ ___CTOR_LIST__ = .;
85+
+ __CTOR_LIST__ = .;
86+
LONG (-1);
87+
KEEP(*(.ctors));
88+
KEEP(*(.ctor));
89+
@@ -107,8 +121,10 @@ SECTIONS
90+
LONG (0);
91+
}
92+
${CONSTRUCTING+
93+
- PROVIDE(___DTOR_LIST__ = .);
94+
- PROVIDE(__DTOR_LIST__ = .);
95+
+ /* See comment about __CTOR_LIST__ above. The same reasoning
96+
+ applies here too. */
97+
+ ___DTOR_LIST__ = .;
98+
+ __DTOR_LIST__ = .;
99+
LONG (-1);
100+
KEEP(*(.dtors));
101+
KEEP(*(.dtor));
102+
diff --git a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc
103+
index 8daacb2..3c6c84d 100644
104+
--- a/ld/scripttempl/pep.sc
105+
+++ b/ld/scripttempl/pep.sc
106+
@@ -99,8 +99,22 @@ SECTIONS
107+
${RELOCATING+*(.glue_7)}
108+
${CONSTRUCTING+. = ALIGN(8);}
109+
${CONSTRUCTING+
110+
- PROVIDE(___CTOR_LIST__ = .);
111+
- PROVIDE(__CTOR_LIST__ = .);
112+
+ /* Note: we always define __CTOR_LIST__ and ___CTOR_LIST__ here,
113+
+ we do not PROVIDE them. This is because the ctors.o startup
114+
+ code in libgcc defines them as common symbols, with the
115+
+ expectation that they will be overridden by the definitions
116+
+ here. If we PROVIDE the symbols then they will not be
117+
+ overridden and global constructors will not be run.
118+
+
119+
+ This does mean that it is not possible for a user to define
120+
+ their own __CTOR_LIST__ and __DTOR_LIST__ symbols. If that
121+
+ ability is needed a custom linker script will have to be
122+
+ used. (The custom script can just be a copy of this script
123+
+ with the PROVIDE() qualifiers added).
124+
+
125+
+ See PR 22762 for more details. */
126+
+ ___CTOR_LIST__ = .;
127+
+ __CTOR_LIST__ = .;
128+
LONG (-1); LONG (-1);
129+
KEEP (*(.ctors));
130+
KEEP (*(.ctor));
131+
@@ -108,8 +122,10 @@ SECTIONS
132+
LONG (0); LONG (0);
133+
}
134+
${CONSTRUCTING+
135+
- PROVIDE(___DTOR_LIST__ = .);
136+
- PROVIDE(__DTOR_LIST__ = .);
137+
+ /* See comment about __CTOR_LIST__ above. The same reasoning
138+
+ applies here too. */
139+
+ ___DTOR_LIST__ = .;
140+
+ __DTOR_LIST__ = .;
141+
LONG (-1); LONG (-1);
142+
KEEP (*(.dtors));
143+
KEEP (*(.dtor));
144+
--
145+
2.9.3
146+

mingw-w64-binutils/PKGBUILD

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ _realname=binutils
66
pkgbase=mingw-w64-${_realname}
77
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
88
pkgver=2.30
9-
pkgrel=1
9+
pkgrel=2
1010
pkgdesc="A set of programs to assemble and manipulate binary and object files (mingw-w64)"
1111
arch=('any')
1212
url="https://www.gnu.org/software/binutils/"
@@ -30,7 +30,8 @@ source=(https://ftp.gnu.org/gnu/binutils/${_realname}-${pkgver}.tar.bz2{,.sig}
3030
0014-dont-link-binutils-to-libiberty.mingw.patch
3131
0015-dont-link-ld-to-libiberty.mingw.patch
3232
0017-fix-iconv-linking.all.patch
33-
0110-binutils-mingw-gnu-print.patch)
33+
0110-binutils-mingw-gnu-print.patch
34+
0200-remove-provide-qualifiers.patch)
3435
sha256sums=('efeade848067e9a03f1918b1da0d37aaffa0b0127a06b5e9236229851d9d0c09'
3536
'SKIP'
3637
'93296b909e1a4f9d8a4bbe2437aafa17ca565ef6642a9812b0360c05be228c9d'
@@ -45,7 +46,8 @@ sha256sums=('efeade848067e9a03f1918b1da0d37aaffa0b0127a06b5e9236229851d9d0c09'
4546
'177426db0ac7f9e9794b1052cbd15c59fa0167ece4cb3ac4f72673403aabc97a'
4647
'376931c0c2f8f5d655458016ac496f93e75c00bf5538e445c29984920a2f5415'
4748
'6b336f218443a95e141d231e4fab726c85d27de7c60ad1ce9fb1a1687943a1ce'
48-
'0f145655d4f2aae3383e0c0269d0c47b8a7176144bf0595425fc38b7ebf53153')
49+
'0f145655d4f2aae3383e0c0269d0c47b8a7176144bf0595425fc38b7ebf53153'
50+
'40f124febb3ee60239988127cf16d6a4d1bd41b156db8ec843a6871492fcca28')
4951
validpgpkeys=('EAF1C276A747E9ED86210CBAC3126D3B4AE55E93')
5052

5153
prepare() {
@@ -65,6 +67,8 @@ prepare() {
6567
patch -p1 -i "${srcdir}"/0110-binutils-mingw-gnu-print.patch
6668

6769
# Upstream patches
70+
# https://sourceware.org/bugzilla/show_bug.cgi?id=22762
71+
patch -p1 -i "${srcdir}"/0200-remove-provide-qualifiers.patch
6872
}
6973

7074
build() {

0 commit comments

Comments
 (0)