From patchwork Tue May 6 14:04:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 820 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 9661336007B for ; Tue, 6 May 2014 07:04:43 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14307373) id 5791741839EB5; Tue, 6 May 2014 07:04:43 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 2871841839E3E for ; Tue, 6 May 2014 07:04:43 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=hYu7dChWD+jCR+88ik/iWQS6/dzZk6JNJuVwsCjZEKFeDhQXFLRNg bPuEOpaVhy5pWj5NFlnNJ/ZxUMph942YxajpHTk1pAasKuTTEgRR3c2O7wOkOnEd 08OJiC80zhsgVeiyOncOW6Pa862+JZaKZ9CQgg+scrnC2jjXEZcn0U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=k0zAVyNcem5nueF2qwbfEe+MId8=; b=JLLF046yFzLZ0bx6oH5PIzwDZCvT 61ictSsSSS4gvEFF5hahacRwuno72o7rUxGdBxU/x4eRi2Fgnrfe/KtXtwV7h0sj s2FesXQYP/46GVG6/VSnJLwNycZHTT4Bo8y+a3aw00ZJsiN9cgfpH1IHsHfNNkh9 nn25xkmrkxusWxw= Received: (qmail 18688 invoked by alias); 6 May 2014 14:04:40 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 18676 invoked by uid 89); 6 May 2014 14:04:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Aurelien Jarno Subject: [PATCH] fix nl_langinfo with static linking Date: Tue, 6 May 2014 16:04:32 +0200 Message-Id: <1399385072-5600-1-git-send-email-aurelien@aurel32.net> X-DH-Original-To: glibc@patchwork.siddhesh.in For static linking the locale code avoids linking code and data for unused categories. However for nl_langinfo we know only at runtime which categories are used, so direct reference to every nl_current_CATEGORY symbol should be done. This was broken by commit bc3e1c127392da88d0c8bf2ae728147982a3d1bc where nl_langinfo_l and nl_langinfo have been merged and some code has been lost in the process. In order to detect locales issues with static linking, compile a version of tst-langinfo with static linking. Note: this is Debian bug#747103 reported by Raphael --- ChangeLog | 12 ++++++++++++ locale/nl_langinfo_l.c | 14 ++++++++++++++ localedata/Makefile | 13 ++++++++++--- localedata/tst-langinfo-static.c | 1 + localedata/tst-langinfo.sh | 3 +-- 5 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 localedata/tst-langinfo-static.c diff --git a/ChangeLog b/ChangeLog index e7ad09a..db2c1fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2014-05-06 Aurelien Jarno + * locale/nl_langinfo_l.c: Make direct reference to every + _nl_current_CATEGORY symbol. + * localedata/Makefile (test-srcs): Add tst-langinfo-static. + (tests-static): Add tst-langinfo-static. + (tests-special): Add tst-langinfo-static.out. + ($(objpfx)tst-langinfo.out): Redirect output. + ($(objpfx)tst-langinfo-static.out): New. + * localedata/tst-langinfo.sh: Send output to stdout. + * localedata/tst-langinfo-static.c: New file. + +2014-05-06 Aurelien Jarno + * sysdeps/unix/sysv/linux/ptsname.c (__ptsname_internal): return errno if the TIOCGPTN ioctl fails with an error different than EINVAL. diff --git a/locale/nl_langinfo_l.c b/locale/nl_langinfo_l.c index b9d02aa..371df65 100644 --- a/locale/nl_langinfo_l.c +++ b/locale/nl_langinfo_l.c @@ -43,7 +43,21 @@ __nl_langinfo_l (item, l) if (index == _NL_ITEM_INDEX (_NL_LOCALE_NAME (category))) return (char *) l->__names[category]; +#if defined NL_CURRENT_INDIRECT + /* Make direct reference to every _nl_current_CATEGORY symbol, + since we know only at runtime which categories are used. */ + switch (category) + { +# define DEFINE_CATEGORY(category, category_name, items, a) \ + case category: data = *_nl_current_##category; break; +# include "categories.def" +# undef DEFINE_CATEGORY + default: /* Should be impossible. */ + return (char *) ""; + } +#else data = l->__locales[category]; +#endif if (index >= data->nstrings) /* Bogus index for this category: bogus item. */ diff --git a/localedata/Makefile b/localedata/Makefile index 94562be..48ec3de 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -35,7 +35,7 @@ vpath %.h tests-mbwc test-srcs := collate-test xfrm-test tst-fmon tst-rpmatch tst-trans \ tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \ - tst-ctype tst-wctype tst-langinfo tst-numeric + tst-ctype tst-wctype tst-langinfo tst-langinfo-static tst-numeric test-input := de_DE.ISO-8859-1 en_US.ISO-8859-1 da_DK.ISO-8859-1 \ hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 tr_TR.UTF-8 fr_FR.UTF-8 \ si_LK.UTF-8 @@ -95,7 +95,9 @@ tests-special += $(objpfx)sort-test.out $(objpfx)tst-fmon.out \ $(objpfx)tst-locale.out $(objpfx)tst-rpmatch.out \ $(objpfx)tst-trans.out $(objpfx)tst-mbswcs.out \ $(objpfx)tst-ctype.out $(objpfx)tst-wctype.out \ - $(objpfx)tst-langinfo.out $(objpfx)tst-numeric.out + $(objpfx)tst-langinfo.out $(objpfx)tst-langinfo-static.out \ + $(objpfx)tst-numeric.out +tests-static += tst-langinfo-static ifeq ($(run-built-tests),yes) # We have to generate locales @@ -197,7 +199,12 @@ $(objpfx)tst-wctype.out: tst-wctype.sh $(objpfx)tst-wctype \ $(objpfx)tst-langinfo.out: tst-langinfo.sh $(objpfx)tst-langinfo \ $(objpfx)sort-test.out \ $(addprefix $(objpfx),$(CTYPE_FILES)) - $(SHELL) $< $(common-objpfx) '$(test-program-cmd)'; \ + $(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \ + $(evaluate-test) +$(objpfx)tst-langinfo-static.out: tst-langinfo.sh $(objpfx)tst-langinfo-static \ + $(objpfx)sort-test.out \ + $(addprefix $(objpfx),$(CTYPE_FILES)) + $(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \ $(evaluate-test) $(objpfx)tst-digits.out: $(objpfx)tst-locale.out $(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES)) diff --git a/localedata/tst-langinfo-static.c b/localedata/tst-langinfo-static.c new file mode 100644 index 0000000..46856a0 --- /dev/null +++ b/localedata/tst-langinfo-static.c @@ -0,0 +1 @@ +#include "tst-langinfo.c" diff --git a/localedata/tst-langinfo.sh b/localedata/tst-langinfo.sh index e75d22a..bd489d0 100755 --- a/localedata/tst-langinfo.sh +++ b/localedata/tst-langinfo.sh @@ -340,7 +340,6 @@ ja_JP.EUC-JP NOEXPR ^([nN ja_JP.EUC-JP CODESET EUC-JP EOF LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \ -LC_ALL=tt_TT ${tst_langinfo} \ - > ${common_objpfx}localedata/tst-langinfo.out +LC_ALL=tt_TT ${tst_langinfo} exit $?