From: Roland McGrath <roland@hack.frob.com>
To: "GNU C. Library" <libc-alpha@sourceware.org>
Subject: [COMMITTED PATCH] Provide __libc_fatal for rtld.
Date: Thu, 09 Jul 2015 22:40:00 -0000 [thread overview]
Message-ID: <20150709224056.4F4922C39DC@topped-with-meat.com> (raw)
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 <stdio.h>.
(__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 <errno.h>
#include <limits.h>
+#include <stdio.h>
#include <string.h>
#include <tls.h>
#include <unistd.h>
@@ -193,8 +194,22 @@ __strerror_r (int errnum, char *buf, size_t buflen)
return msg;
}
\f
-#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
-
+\f
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)
+\f
/* 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)
reply other threads:[~2015-07-09 22:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150709224056.4F4922C39DC@topped-with-meat.com \
--to=roland@hack.frob.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).