|
|
e354a5 |
commit de42613540de8d3d70b5f14a14923cab7bd694d0
|
|
|
e354a5 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
e354a5 |
Date: Mon May 25 18:17:27 2020 +0200
|
|
|
e354a5 |
|
|
|
e354a5 |
elf: Turn _dl_printf, _dl_error_printf, _dl_fatal_printf into functions
|
|
|
e354a5 |
|
|
|
e354a5 |
This change makes it easier to set a breakpoint on these calls.
|
|
|
e354a5 |
|
|
|
e354a5 |
This also addresses the issue that including <ldsodefs.h> without
|
|
|
e354a5 |
<unistd.h> does not result usable _dl_*printf macros because of the
|
|
|
e354a5 |
use of the STD*_FILENO macros there.
|
|
|
e354a5 |
|
|
|
e354a5 |
(The private symbol for _dl_fatal_printf will go away again
|
|
|
e354a5 |
once the exception handling implementation is unified between
|
|
|
e354a5 |
libc and ld.so.)
|
|
|
e354a5 |
|
|
|
e354a5 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/elf/Versions b/elf/Versions
|
|
|
e354a5 |
index 3be879c4adfa74c7..be88c48e6d45a937 100644
|
|
|
e354a5 |
--- a/elf/Versions
|
|
|
e354a5 |
+++ b/elf/Versions
|
|
|
e354a5 |
@@ -58,7 +58,7 @@ ld {
|
|
|
e354a5 |
_dl_allocate_tls; _dl_allocate_tls_init;
|
|
|
e354a5 |
_dl_argv; _dl_find_dso_for_object; _dl_get_tls_static_info;
|
|
|
e354a5 |
_dl_deallocate_tls; _dl_make_stack_executable;
|
|
|
e354a5 |
- _dl_rtld_di_serinfo; _dl_starting_up;
|
|
|
e354a5 |
+ _dl_rtld_di_serinfo; _dl_starting_up; _dl_fatal_printf;
|
|
|
e354a5 |
_rtld_global; _rtld_global_ro;
|
|
|
e354a5 |
|
|
|
e354a5 |
# Only here for gdb while a better method is developed.
|
|
|
e354a5 |
diff --git a/elf/dl-misc.c b/elf/dl-misc.c
|
|
|
e354a5 |
index 3f28de3ee9d68368..508630e444d2a00c 100644
|
|
|
e354a5 |
--- a/elf/dl-misc.c
|
|
|
e354a5 |
+++ b/elf/dl-misc.c
|
|
|
e354a5 |
@@ -302,6 +302,37 @@ _dl_dprintf (int fd, const char *fmt, ...)
|
|
|
e354a5 |
va_end (arg);
|
|
|
e354a5 |
}
|
|
|
e354a5 |
|
|
|
e354a5 |
+void
|
|
|
e354a5 |
+_dl_printf (const char *fmt, ...)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ va_list arg;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ va_start (arg, fmt);
|
|
|
e354a5 |
+ _dl_debug_vdprintf (STDOUT_FILENO, 0, fmt, arg);
|
|
|
e354a5 |
+ va_end (arg);
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+void
|
|
|
e354a5 |
+_dl_error_printf (const char *fmt, ...)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ va_list arg;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ va_start (arg, fmt);
|
|
|
e354a5 |
+ _dl_debug_vdprintf (STDERR_FILENO, 0, fmt, arg);
|
|
|
e354a5 |
+ va_end (arg);
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+void
|
|
|
e354a5 |
+_dl_fatal_printf (const char *fmt, ...)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ va_list arg;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ va_start (arg, fmt);
|
|
|
e354a5 |
+ _dl_debug_vdprintf (STDERR_FILENO, 0, fmt, arg);
|
|
|
e354a5 |
+ va_end (arg);
|
|
|
e354a5 |
+ _exit (127);
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
+rtld_hidden_def (_dl_fatal_printf)
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Test whether given NAME matches any of the names of the given object. */
|
|
|
e354a5 |
int
|
|
|
e354a5 |
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
|
|
e354a5 |
index 77923499d3de4366..6cbbaa808a596f77 100644
|
|
|
e354a5 |
--- a/sysdeps/generic/ldsodefs.h
|
|
|
e354a5 |
+++ b/sysdeps/generic/ldsodefs.h
|
|
|
e354a5 |
@@ -762,24 +762,19 @@ ssize_t _dl_write (int fd, const void *buffer, size_t length)
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Write a message on the specified descriptor standard output. The
|
|
|
e354a5 |
parameters are interpreted as for a `printf' call. */
|
|
|
e354a5 |
-#define _dl_printf(fmt, args...) \
|
|
|
e354a5 |
- _dl_dprintf (STDOUT_FILENO, fmt, ##args)
|
|
|
e354a5 |
+void _dl_printf (const char *fmt, ...)
|
|
|
e354a5 |
+ attribute_hidden __attribute__ ((__format__ (__printf__, 1, 2)));
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Write a message on the specified descriptor standard error. The
|
|
|
e354a5 |
parameters are interpreted as for a `printf' call. */
|
|
|
e354a5 |
-#define _dl_error_printf(fmt, args...) \
|
|
|
e354a5 |
- _dl_dprintf (STDERR_FILENO, fmt, ##args)
|
|
|
e354a5 |
+void _dl_error_printf (const char *fmt, ...)
|
|
|
e354a5 |
+ attribute_hidden __attribute__ ((__format__ (__printf__, 1, 2)));
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Write a message on the specified descriptor standard error and exit
|
|
|
e354a5 |
the program. The parameters are interpreted as for a `printf' call. */
|
|
|
e354a5 |
-#define _dl_fatal_printf(fmt, args...) \
|
|
|
e354a5 |
- do \
|
|
|
e354a5 |
- { \
|
|
|
e354a5 |
- _dl_dprintf (STDERR_FILENO, fmt, ##args); \
|
|
|
e354a5 |
- _exit (127); \
|
|
|
e354a5 |
- } \
|
|
|
e354a5 |
- while (1)
|
|
|
e354a5 |
-
|
|
|
e354a5 |
+void _dl_fatal_printf (const char *fmt, ...)
|
|
|
e354a5 |
+ __attribute__ ((__format__ (__printf__, 1, 2), __noreturn__));
|
|
|
e354a5 |
+rtld_hidden_proto (_dl_fatal_printf)
|
|
|
e354a5 |
|
|
|
e354a5 |
/* An exception raised by the _dl_signal_error function family and
|
|
|
e354a5 |
caught by _dl_catch_error function family. Exceptions themselves
|
|
|
e354a5 |
diff --git a/sysdeps/mach/hurd/i386/localplt.data b/sysdeps/mach/hurd/i386/localplt.data
|
|
|
e354a5 |
index 4b9dbf5acc088cff..eb79216e3b494486 100644
|
|
|
e354a5 |
--- a/sysdeps/mach/hurd/i386/localplt.data
|
|
|
e354a5 |
+++ b/sysdeps/mach/hurd/i386/localplt.data
|
|
|
e354a5 |
@@ -43,6 +43,7 @@ ld.so: _dl_allocate_tls_init
|
|
|
e354a5 |
ld.so: _dl_exception_create
|
|
|
e354a5 |
ld.so: _dl_exception_create_format
|
|
|
e354a5 |
ld.so: _dl_exception_free
|
|
|
e354a5 |
+ld.so: _dl_fatal_printf
|
|
|
e354a5 |
ld.so: _dl_find_dso_for_object
|
|
|
e354a5 |
ld.so: _dl_init_first
|
|
|
e354a5 |
ld.so: _dl_mcount
|