]> git.pld-linux.org Git - packages/gcc.git/blame - gcc32-libstdc++-glibc.patch
- GCC extension for protecting applications from stack-smashing attacks
[packages/gcc.git] / gcc32-libstdc++-glibc.patch
CommitLineData
c8970db5
AM
1From gcc-patches-return-67062-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org Fri Aug 30 10:39:38 2002
2Return-Path: <gcc-patches-return-67062-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org>
3Delivered-To: listarch-gcc-patches at gcc dot gnu dot org
4Received: (qmail 32272 invoked by alias); 30 Aug 2002 10:39:36 -0000
5Mailing-List: contact gcc-patches-help at gcc dot gnu dot org; run by ezmlm
6Precedence: bulk
7List-Archive: <http://gcc.gnu.org/ml/gcc-patches/>
8List-Post: <mailto:gcc-patches at gcc dot gnu dot org>
9List-Help: <mailto:gcc-patches-help at gcc dot gnu dot org>
10Sender: gcc-patches-owner at gcc dot gnu dot org
11Delivered-To: mailing list gcc-patches at gcc dot gnu dot org
12Received: (qmail 32195 invoked from network); 30 Aug 2002 10:39:32 -0000
13Received: from unknown (HELO sunsite.mff.cuni.cz) (195.113.19.66)
14 by sources dot redhat dot com with SMTP; 30 Aug 2002 10:39:32 -0000
15Received: (from jakub@localhost)
16 by sunsite dot mff dot cuni dot cz (8 dot 11 dot 6/8 dot 11 dot 6) id g7UAcS700895;
17 Fri, 30 Aug 2002 12:38:28 +0200
18Date: Fri, 30 Aug 2002 12:38:28 +0200
19From: Jakub Jelinek <jakub at redhat dot com>
20To: bkoz at redhat dot com, mark at codesourcery dot com
21Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, drepper at redhat dot com,
22 roland at redhat dot com
23Subject: [PATCH] Fix libstdc++-v3 on GLIBC 2.3+
24Message-ID: <20020830123828.Y1013@sunsite.ms.mff.cuni.cz>
25Reply-To: Jakub Jelinek <jakub at redhat dot com>
26Mime-Version: 1.0
27Content-Type: text/plain; charset=iso-8859-1
28Content-Disposition: inline
29Content-Transfer-Encoding: 8bit
30User-Agent: Mutt/1.2.5.1i
31
32Hi!
33
34The following patch fixes libstdc++-v3 compilation and use on GLIBC 2.2.9x+.
35It passed libstdc++-v3 make check with 24 XPASSes and 1 FAIL - the remaining
362 missing XPASSes (ie. the only 2 XFAILs) are:
37XFAIL: 22_locale/messages_byname.cc execution test
38XFAIL: 22_locale/messages_members_char.cc execution test
39which fail because of a glibc bug Roland is working on.
40
41The only difference on libstdc++.so symbols this has is that
42_ZNKSt8messagesIwE6do_getEiiiRKSbIwSt11char_traitsIwESaIwEE
43symbol is no longer weak (ie. T instead of W in nm output),
44which doesn't change anything for binary compatibility IMHO.
45
46Ok to commit? 3.2 branch too?
47
482002-08-30 Jakub Jelinek <jakub@redhat.com>
49
50 * config/locale/generic/c++locale_internal.h: New header.
51 * config/locale/gnu/c++locale_internal.h: New header.
52 * config/locale/gnu/c_locale.cc: Include it.
53 * config/locale/gnu/collate_members.cc: Include it.
54 * config/locale/gnu/ctype_members.cc: Include it.
55 * config/locale/gnu/messages_members.cc: Include it.
56 * config/locale/gnu/monetary_members.cc: Include it.
57 * config/locale/gnu/numeric_members.cc: Include it.
58 * config/locale/gnu/time_members.cc: Include it.
59 (_M_put): Reorder __strftime_l and __wcsftime_l arguments to match
60 glibc.
61 (_M_initialize_timepunct): Initialize _M_c_locale_timepunct for
62 C locale.
63 * acinclude.m4: Include string.h when testing strcoll_l.
64 For glibc 2.3 provide __-prefixed prototypes.
65 (CLOCALE_INTERNAL_H): Set, add AC_LINK_FILES line.
66 * aclocal.m4, configure: Rebuilt.
67
682002-08-29 Benjamin Kosnik <bkoz@redhat.com>
69
70 * include/bits/locale_facets.h: Add declaration of specialization
71 here.
72 * config/locale/gnu/messages_members.cc: Add specialization for
73 messages<wchar_t>.
74 * config/locale/gnu/messages_members.h: Remove generic definition
75 of do_get.
76
77--- libstdc++-v3/config/locale/generic/c++locale_internal.h.jj 2002-08-29 14:57:21.000000000 +0200
78+++ libstdc++-v3/config/locale/generic/c++locale_internal.h 2002-08-30 12:05:10.000000000 +0200
79@@ -0,0 +1,30 @@
80+// Locale internal implementation header -*- C++ -*-
81+
82+// Copyright (C) 2002 Free Software Foundation, Inc.
83+//
84+// This file is part of the GNU ISO C++ Library. This library is free
85+// software; you can redistribute it and/or modify it under the
86+// terms of the GNU General Public License as published by the
87+// Free Software Foundation; either version 2, or (at your option)
88+// any later version.
89+
90+// This library is distributed in the hope that it will be useful,
91+// but WITHOUT ANY WARRANTY; without even the implied warranty of
92+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93+// GNU General Public License for more details.
94+
95+// You should have received a copy of the GNU General Public License along
96+// with this library; see the file COPYING. If not, write to the Free
97+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
98+// USA.
99+
100+// As a special exception, you may use this file as part of a free software
101+// library without restriction. Specifically, if other files instantiate
102+// templates or use macros or inline functions from this file, or you compile
103+// this file and link it with other files to produce an executable, this
104+// file does not by itself cause the resulting executable to be covered by
105+// the GNU General Public License. This exception does not however
106+// invalidate any other reasons why the executable file might be covered by
107+// the GNU General Public License.
108+
109+// The generic locale code doesn't need to do anything here (yet)
110--- libstdc++-v3/config/locale/gnu/c_locale.cc.jj 2002-04-23 20:30:31.000000000 +0200
111+++ libstdc++-v3/config/locale/gnu/c_locale.cc 2002-08-30 12:09:12.000000000 +0200
112@@ -36,6 +36,7 @@
113 #include <locale>
114 #include <stdexcept>
115 #include <langinfo.h>
116+#include "c++locale_internal.h"
117
118 namespace std
119 {
120--- libstdc++-v3/config/locale/gnu/collate_members.cc.jj 2002-04-23 20:30:31.000000000 +0200
121+++ libstdc++-v3/config/locale/gnu/collate_members.cc 2002-08-30 12:09:12.000000000 +0200
122@@ -1,6 +1,6 @@
123 // std::collate implementation details, GNU version -*- C++ -*-
124
125-// Copyright (C) 2001 Free Software Foundation, Inc.
126+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
127 //
128 // This file is part of the GNU ISO C++ Library. This library is free
129 // software; you can redistribute it and/or modify it under the
130@@ -34,6 +34,7 @@
131 // Written by Benjamin Kosnik <bkoz@redhat.com>
132
133 #include <locale>
134+#include "c++locale_internal.h"
135
136 namespace std
137 {
138--- libstdc++-v3/config/locale/gnu/ctype_members.cc.jj 2002-05-25 00:18:17.000000000 +0200
139+++ libstdc++-v3/config/locale/gnu/ctype_members.cc 2002-08-30 12:09:12.000000000 +0200
140@@ -34,6 +34,7 @@
141 // Written by Benjamin Kosnik <bkoz@redhat.com>
142
143 #include <locale>
144+#include "c++locale_internal.h"
145
146 namespace std
147 {
148--- libstdc++-v3/config/locale/gnu/messages_members.cc.jj 2002-05-22 15:38:28.000000000 +0200
149+++ libstdc++-v3/config/locale/gnu/messages_members.cc 2002-08-30 12:09:12.000000000 +0200
150@@ -34,6 +34,7 @@
151 // Written by Benjamin Kosnik <bkoz@redhat.com>
152
153 #include <locale>
154+#include "c++locale_internal.h"
155
156 namespace std
157 {
158@@ -56,4 +57,25 @@ namespace std
159 return string(__msg);
160 #endif
161 }
162+
163+#ifdef _GLIBCPP_USE_WCHAR_T
164+ template<>
165+ wstring
166+ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
167+ {
168+# if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
169+ __c_locale __old = __uselocale(_M_c_locale_messages);
170+ char* __msg = gettext(_M_convert_to_char(__dfault));
171+ __uselocale(__old);
172+ return _M_convert_from_char(__msg);
173+# else
174+ char* __old = strdup(setlocale(LC_ALL, NULL));
175+ setlocale(LC_ALL, _M_name_messages);
176+ char* __msg = gettext(_M_convert_to_char(__dfault));
177+ setlocale(LC_ALL, __old);
178+ free(__old);
179+ return _M_convert_from_char(__msg);
180+# endif
181+ }
182+#endif
183 }
184--- libstdc++-v3/config/locale/gnu/monetary_members.cc.jj 2002-07-27 01:31:05.000000000 +0200
185+++ libstdc++-v3/config/locale/gnu/monetary_members.cc 2002-08-30 12:09:12.000000000 +0200
186@@ -34,6 +34,7 @@
187 // Written by Benjamin Kosnik <bkoz@redhat.com>
188
189 #include <locale>
190+#include "c++locale_internal.h"
191
192 namespace std
193 {
194--- libstdc++-v3/config/locale/gnu/numeric_members.cc.jj 2002-04-23 20:30:31.000000000 +0200
195+++ libstdc++-v3/config/locale/gnu/numeric_members.cc 2002-08-30 12:09:12.000000000 +0200
196@@ -34,6 +34,7 @@
197 // Written by Benjamin Kosnik <bkoz@redhat.com>
198
199 #include <locale>
200+#include "c++locale_internal.h"
201
202 namespace std
203 {
204--- libstdc++-v3/config/locale/gnu/time_members.cc.jj 2002-05-22 15:38:30.000000000 +0200
205+++ libstdc++-v3/config/locale/gnu/time_members.cc 2002-08-30 12:09:12.000000000 +0200
206@@ -35,6 +35,7 @@
207 // Written by Benjamin Kosnik <bkoz@redhat.com>
208
209 #include <locale>
210+#include "c++locale_internal.h"
211
212 namespace std
213 {
214@@ -52,7 +53,7 @@ namespace std
215 const tm* __tm) const
216 {
217 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
218- __strftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm);
219+ __strftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
220 #else
221 char* __old = strdup(setlocale(LC_ALL, NULL));
222 setlocale(LC_ALL, _M_name_timepunct);
223@@ -69,6 +70,9 @@ namespace std
224 if (__cloc == _S_c_locale)
225 {
226 // "C" locale
227+
228+ _M_c_locale_timepunct = _S_c_locale;
229+
230 _M_date_format = "%m/%d/%y";
231 _M_date_era_format = "%m/%d/%y";
232 _M_time_format = "%H:%M:%S";
233@@ -202,7 +206,7 @@ namespace std
234 const tm* __tm) const
235 {
236 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
237- __wcsftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm);
238+ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
239 #else
240 char* __old = strdup(setlocale(LC_ALL, NULL));
241 setlocale(LC_ALL, _M_name_timepunct);
242@@ -219,6 +223,9 @@ namespace std
243 if (__cloc == _S_c_locale)
244 {
245 // "C" locale
246+
247+ _M_c_locale_timepunct = _S_c_locale;
248+
249 _M_date_format = L"%m/%d/%y";
250 _M_date_era_format = L"%m/%d/%y";
251 _M_time_format = L"%H:%M:%S";
252--- libstdc++-v3/config/locale/gnu/messages_members.h.jj 2002-05-22 15:38:28.000000000 +0200
253+++ libstdc++-v3/config/locale/gnu/messages_members.h 2002-08-29 17:50:14.000000000 +0200
254@@ -55,26 +55,6 @@
255 }
256
257 template<typename _CharT>
258- typename messages<_CharT>::string_type
259- messages<_CharT>::do_get(catalog, int, int,
260- const string_type& __dfault) const
261- {
262-#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
263- __c_locale __old = __uselocale(_M_c_locale_messages);
264- char* __msg = gettext(_M_convert_to_char(__dfault));
265- __uselocale(__old);
266- return _M_convert_from_char(__msg);
267-#else
268- char* __old = strdup(setlocale(LC_ALL, NULL));
269- setlocale(LC_ALL, _M_name_messages);
270- char* __msg = gettext(_M_convert_to_char(__dfault));
271- setlocale(LC_ALL, __old);
272- free(__old);
273- return _M_convert_from_char(__msg);
274-#endif
275- }
276-
277- template<typename _CharT>
278 void
279 messages<_CharT>::do_close(catalog) const
280 { }
281--- libstdc++-v3/config/locale/gnu/c++locale_internal.h.jj 2002-08-29 14:57:21.000000000 +0200
282+++ libstdc++-v3/config/locale/gnu/c++locale_internal.h 2002-08-29 15:21:59.000000000 +0200
283@@ -0,0 +1,59 @@
284+// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
285+
286+// Copyright (C) 2002 Free Software Foundation, Inc.
287+//
288+// This file is part of the GNU ISO C++ Library. This library is free
289+// software; you can redistribute it and/or modify it under the
290+// terms of the GNU General Public License as published by the
291+// Free Software Foundation; either version 2, or (at your option)
292+// any later version.
293+
294+// This library is distributed in the hope that it will be useful,
295+// but WITHOUT ANY WARRANTY; without even the implied warranty of
296+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
297+// GNU General Public License for more details.
298+
299+// You should have received a copy of the GNU General Public License along
300+// with this library; see the file COPYING. If not, write to the Free
301+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
302+// USA.
303+
304+// As a special exception, you may use this file as part of a free software
305+// library without restriction. Specifically, if other files instantiate
306+// templates or use macros or inline functions from this file, or you compile
307+// this file and link it with other files to produce an executable, this
308+// file does not by itself cause the resulting executable to be covered by
309+// the GNU General Public License. This exception does not however
310+// invalidate any other reasons why the executable file might be covered by
311+// the GNU General Public License.
312+
313+// Written by Jakub Jelinek <jakub@redhat.com>
314+
315+#include <clocale>
316+
317+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
318+
319+extern "C" __typeof(iswctype_l) __iswctype_l;
320+extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
321+extern "C" __typeof(strcoll_l) __strcoll_l;
322+extern "C" __typeof(strftime_l) __strftime_l;
323+extern "C" __typeof(strtod_l) __strtod_l;
324+extern "C" __typeof(strtof_l) __strtof_l;
325+extern "C" __typeof(strtold_l) __strtold_l;
326+extern "C" __typeof(strtol_l) __strtol_l;
327+extern "C" __typeof(strtoll_l) __strtoll_l;
328+extern "C" __typeof(strtoul_l) __strtoul_l;
329+extern "C" __typeof(strtoull_l) __strtoull_l;
330+extern "C" __typeof(strxfrm_l) __strxfrm_l;
331+extern "C" __typeof(towlower_l) __towlower_l;
332+extern "C" __typeof(towupper_l) __towupper_l;
333+extern "C" __typeof(wcscoll_l) __wcscoll_l;
334+extern "C" __typeof(wcsftime_l) __wcsftime_l;
335+extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
336+extern "C" __typeof(wctype_l) __wctype_l;
337+extern "C" __typeof(newlocale) __newlocale;
338+extern "C" __typeof(freelocale) __freelocale;
339+extern "C" __typeof(duplocale) __duplocale;
340+extern "C" __typeof(uselocale) __uselocale;
341+
342+#endif // GLIBC 2.3 and later
343--- libstdc++-v3/include/bits/locale_facets.h.jj 2002-08-01 23:43:48.000000000 +0200
344+++ libstdc++-v3/include/bits/locale_facets.h 2002-08-29 17:49:53.000000000 +0200
345@@ -1739,6 +1739,12 @@ namespace std
346 string
347 messages<char>::do_get(catalog, int, int, const string&) const;
348
349+#ifdef _GLIBCPP_USE_WCHAR_T
350+ template<>
351+ wstring
352+ messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
353+#endif
354+
355 // Include host and configuration specific messages virtual functions.
356 #include <bits/messages_members.h>
357
358--- libstdc++-v3/acinclude.m4.jj 2002-08-29 13:51:58.000000000 +0200
359+++ libstdc++-v3/acinclude.m4 2002-08-30 11:58:42.000000000 +0200
360@@ -1131,6 +1131,12 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
361 AC_TRY_RUN([
362 #define _GNU_SOURCE 1
363 #include <locale.h>
364+ #include <string.h>
365+ #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
366+ extern __typeof(newlocale) __newlocale;
367+ extern __typeof(duplocale) __duplocale;
368+ extern __typeof(strcoll_l) __strcoll_l;
369+ #endif
370 int main()
371 {
372