From patchwork Thu Jul 9 22:40:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 493596 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 843C51402B8 for ; Fri, 10 Jul 2015 08:41:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=YaD5R7AK; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=Kgp//T6NUmUdaRaPtjSOSEK/6yEzqIeNaHOw7A6pAjfbQS BhwcuQa/u9uzIWxfZrvywjSRdEwC9j4YT2hej4SxPH89KjvKGTSMjwz+rODsmUVQ Rhw5eBPM/XbU3FjyjXFOs+Ov4cGU2MnRNjnHgHFZe4TdDNjw0uN1fGJLigw8g= 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:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=/6bc7wOw+7AKXXHoaCrIKyAeG7k=; b=YaD5R7AKtVkr7UyTWruC WpGSMR3ROmkULLBB/Kd7H6doCPdZWGLpWb6mhxujdb3tGc44M2dkgF8y3fgWMc8N aepdfkvlto1nkHM39qpsPpVgLaQQNx3UuFFY9rLUGQF9z+V9CSCjPCNoB4SWEiPE Q3jTkOThtHB+1yEjnYRORxk= Received: (qmail 2280 invoked by alias); 9 Jul 2015 22:40:59 -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 2271 invoked by uid 89); 9 Jul 2015 22:40:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] Provide __libc_fatal for rtld. Message-Id: <20150709224056.4F4922C39DC@topped-with-meat.com> Date: Thu, 9 Jul 2015 15:40:56 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=hOe2yjtxAAAA:8 a=kj9zAlcOel0A:10 a=llVSyR3KrXDi1iulYCoA:9 a=CjuIK1q_8ugA:10 This makes it possible to use __libc_fatal in rtld code. Thanks, Roland * include/stdio.h: Add rtld_hidden_proto (__libc_fatal). * elf/dl-minimal.c: For readability, reorder some definitions and introduce more page breaks. Include . (__libc_fatal): New function. diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c index 04f416d..ec7fe88 100644 --- a/elf/dl-minimal.c +++ b/elf/dl-minimal.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -193,8 +194,22 @@ __strerror_r (int errnum, char *buf, size_t buflen) return msg; } -#ifndef NDEBUG +void +__libc_fatal (const char *message) +{ + _dl_fatal_printf ("%s", message); +} +rtld_hidden_def (__libc_fatal) +void +__attribute__ ((noreturn)) +__chk_fail (void) +{ + _exit (127); +} +rtld_hidden_def (__chk_fail) + +#ifndef NDEBUG /* Define (weakly) our own assert failure function which doesn't use stdio. If we are linked into the user program (-ldl), the normal __assert_fail defn can override this one. */ @@ -209,7 +224,7 @@ Inconsistency detected by ld.so: %s: %u: %s%sAssertion `%s' failed!\n", assertion); } -rtld_hidden_weak(__assert_fail) +rtld_hidden_weak (__assert_fail) void weak_function __assert_perror_fail (int errnum, @@ -225,7 +240,7 @@ Inconsistency detected by ld.so: %s: %u: %s%sUnexpected error: %s.\n", } rtld_hidden_weak (__assert_perror_fail) #endif - + unsigned long int weak_function __strtoul_internal (const char *nptr, char **endptr, int base, int group) { @@ -324,7 +339,11 @@ _itoa (value, buflim, base, upper_case) return buflim; } - +/* The '_itoa_lower_digits' variable in libc.so is able to handle bases + up to 36. We don't need this here. */ +const char _itoa_lower_digits[16] = "0123456789abcdef"; +rtld_hidden_data_def (_itoa_lower_digits) + /* The following is not a complete strsep implementation. It cannot handle empty delimiter strings. But this isn't necessary for the execution of ld.so. */ @@ -367,16 +386,3 @@ __strsep (char **stringp, const char *delim) } weak_alias (__strsep, strsep) strong_alias (__strsep, __strsep_g) - -void -__attribute__ ((noreturn)) -__chk_fail (void) -{ - _exit (127); -} -rtld_hidden_def (__chk_fail) - -/* The '_itoa_lower_digits' variable in libc.so is able to handle bases - up to 36. We don't need this here. */ -const char _itoa_lower_digits[16] = "0123456789abcdef"; -rtld_hidden_data_def (_itoa_lower_digits) diff --git a/include/stdio.h b/include/stdio.h index 31718f9..1ffbc40 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -172,6 +172,7 @@ libc_hidden_proto (fmemopen) extern FILE *__open_memstream (char **, size_t *) __THROW __wur; libc_hidden_proto (__open_memstream) libc_hidden_proto (__libc_fatal) +rtld_hidden_proto (__libc_fatal) libc_hidden_proto (__vsprintf_chk) libc_hidden_proto (__vsnprintf_chk) libc_hidden_proto (__vfprintf_chk)