From patchwork Mon Feb 19 18:08:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 25971 Received: (qmail 28276 invoked by alias); 19 Feb 2018 18:08:28 -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 28266 invoked by uid 89); 19 Feb 2018 18:08:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Mon, 19 Feb 2018 18:08:20 +0000 From: Joseph Myers To: Subject: Fix -Os putc_unlocked, fputc_unlocked linknamespace, localplt issues (bug 15105, bug 19463) Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for putc_unlocked and fputc_unlocked. This is relative to a tree with (pending review) applied, but has only trivial textual dependence on that patch. libc_hidden_* are used for both functions, while namespace issues are addressed by making putc_unlocked a weak alias of hidden __putc_unlocked, which is called in the one place where namespace issues arise (and defined as an inline function in include/stdio.h). Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). This completes fixing the -Os linknamespace failures (at least for x86_64); localplt failures remain after this patch. 2018-02-19 Joseph Myers [BZ #15105] [BZ #19463] * libio/fputc_u.c (fputc_unlocked): Use libc_hidden_def. * libio/putc_u.c (putc_unlocked): Rename to __putc_unlocked and define as weak alias of __putc_unlocked. Use libc_hidden_weak. * include/stdio.h [!_ISOMAC] (fputc_unlocked): Use libc_hidden_proto. [!_ISOMAC] (putc_unlocked): Likewise. [!_ISOMAC] (__putc_unlocked): Declare as hidden function, and define inline if [__USE_EXTERN_INLINES]. * misc/syslog.c (__vsyslog_chk): Call __putc_unlocked instead of putc_unlocked. Reviewed-by: Adhemerval Zanella diff --git a/include/stdio.h b/include/stdio.h index 937235f..aac5acd 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -188,6 +188,9 @@ extern __typeof (feof_unlocked) __feof_unlocked attribute_hidden; libc_hidden_proto (ferror_unlocked) extern __typeof (ferror_unlocked) __ferror_unlocked attribute_hidden; libc_hidden_proto (getc_unlocked) +libc_hidden_proto (fputc_unlocked) +libc_hidden_proto (putc_unlocked) +extern __typeof (putc_unlocked) __putc_unlocked attribute_hidden; libc_hidden_proto (fmemopen) /* The prototype needs repeating instead of using __typeof to use __THROW in C++ tests. */ @@ -226,6 +229,12 @@ __getc_unlocked (FILE *__fp) { return __getc_unlocked_body (__fp); } + +__extern_inline int +__putc_unlocked (int __c, FILE *__stream) +{ + return __putc_unlocked_body (__c, __stream); +} # endif # endif /* not _ISOMAC */ diff --git a/libio/fputc_u.c b/libio/fputc_u.c index abe07f3..25e2035 100644 --- a/libio/fputc_u.c +++ b/libio/fputc_u.c @@ -35,3 +35,4 @@ fputc_unlocked (int c, _IO_FILE *fp) CHECK_FILE (fp, EOF); return _IO_putc_unlocked (c, fp); } +libc_hidden_def (fputc_unlocked) diff --git a/libio/putc_u.c b/libio/putc_u.c index 61ca95b..2d122a6 100644 --- a/libio/putc_u.c +++ b/libio/putc_u.c @@ -21,8 +21,10 @@ #undef putc_unlocked int -putc_unlocked (int c, _IO_FILE *fp) +__putc_unlocked (int c, _IO_FILE *fp) { CHECK_FILE (fp, EOF); return _IO_putc_unlocked (c, fp); } +weak_alias (__putc_unlocked, putc_unlocked) +libc_hidden_weak (putc_unlocked) diff --git a/misc/syslog.c b/misc/syslog.c index 2b6bd37..644dbe8 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -207,8 +207,8 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap) fprintf (f, "[%d]", (int) __getpid ()); if (LogTag != NULL) { - putc_unlocked (':', f); - putc_unlocked (' ', f); + __putc_unlocked (':', f); + __putc_unlocked (' ', f); } /* Restore errno for %m format. */