|
|
b1dca6 |
commit 72d36ffd7db55ae599f4c77feb0eae25a0f3714e
|
|
|
b1dca6 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
b1dca6 |
Date: Thu Oct 8 10:57:09 2020 +0200
|
|
|
b1dca6 |
|
|
|
b1dca6 |
elf: Implement __rtld_malloc_is_complete
|
|
|
b1dca6 |
|
|
|
b1dca6 |
In some cases, it is difficult to determine the kind of malloc
|
|
|
b1dca6 |
based on the execution context, so a function to determine that
|
|
|
b1dca6 |
is helpful.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
b1dca6 |
|
|
|
b1dca6 |
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
|
|
|
b1dca6 |
index 4335f1bd24289b01..cf7df8a8d5eabe9d 100644
|
|
|
b1dca6 |
--- a/elf/dl-minimal.c
|
|
|
b1dca6 |
+++ b/elf/dl-minimal.c
|
|
|
b1dca6 |
@@ -59,6 +59,14 @@ __rtld_malloc_init_stubs (void)
|
|
|
b1dca6 |
__rtld_realloc = &rtld_realloc;
|
|
|
b1dca6 |
}
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+bool
|
|
|
b1dca6 |
+__rtld_malloc_is_complete (void)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ /* The caller assumes that there is an active malloc. */
|
|
|
b1dca6 |
+ assert (__rtld_malloc != NULL);
|
|
|
b1dca6 |
+ return __rtld_malloc != &rtld_malloc;
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
/* Lookup NAME at VERSION in the scope of MATCH. */
|
|
|
b1dca6 |
static void *
|
|
|
b1dca6 |
lookup_malloc_symbol (struct link_map *main_map, const char *name,
|
|
|
b1dca6 |
diff --git a/include/rtld-malloc.h b/include/rtld-malloc.h
|
|
|
b1dca6 |
index b026a3270cd24819..9266ec532f3f3376 100644
|
|
|
b1dca6 |
--- a/include/rtld-malloc.h
|
|
|
b1dca6 |
+++ b/include/rtld-malloc.h
|
|
|
b1dca6 |
@@ -66,6 +66,10 @@ realloc (void *ptr, size_t size)
|
|
|
b1dca6 |
implementation. */
|
|
|
b1dca6 |
void __rtld_malloc_init_stubs (void) attribute_hidden;
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+/* Return false if the active malloc is the ld.so minimal malloc, true
|
|
|
b1dca6 |
+ if it is the full implementation from libc.so. */
|
|
|
b1dca6 |
+_Bool __rtld_malloc_is_complete (void) attribute_hidden;
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
/* Called shortly before the final self-relocation (when RELRO
|
|
|
b1dca6 |
variables are still writable) to activate the real malloc
|
|
|
b1dca6 |
implementation. MAIN_MAP is the link map of the executable. */
|