about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-11-17 12:20:29 +0100
committerFlorian Weimer <fweimer@redhat.com>2021-11-17 12:20:29 +0100
commitf1d333b5bfdb3561c93feb4b5653d051c3258c59 (patch)
treea7a2e391beed00f8daa4cc826a10d0c6a26240fd /elf
parent8bd336a00a5311bf7a9e99b3b0e9f01ff5faa74b (diff)
downloadglibc-f1d333b5bfdb3561c93feb4b5653d051c3258c59.tar.gz
glibc-f1d333b5bfdb3561c93feb4b5653d051c3258c59.tar.xz
glibc-f1d333b5bfdb3561c93feb4b5653d051c3258c59.zip
elf: Introduce GLRO (dl_libc_freeres), called from __libc_freeres
This will be used to deallocate memory allocated using the non-minimal
malloc.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile2
-rw-r--r--elf/dl-libc_freeres.c24
-rw-r--r--elf/rtld.c1
3 files changed, 26 insertions, 1 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 525f302d1a..2365c0c863 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -68,7 +68,7 @@ elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
 rtld-routines	= rtld $(all-dl-routines) dl-sysdep dl-environ dl-minimal \
   dl-error-minimal dl-conflict dl-hwcaps dl-hwcaps_split dl-hwcaps-subdirs \
   dl-usage dl-diagnostics dl-diagnostics-kernel dl-diagnostics-cpu \
-  dl-mutex
+  dl-mutex dl-libc_freeres
 all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
 
 CFLAGS-dl-runtime.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/elf/dl-libc_freeres.c b/elf/dl-libc_freeres.c
new file mode 100644
index 0000000000..68f305a6f9
--- /dev/null
+++ b/elf/dl-libc_freeres.c
@@ -0,0 +1,24 @@
+/* Deallocating malloc'ed memory from the dynamic loader.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <ldsodefs.h>
+
+void
+__rtld_libc_freeres (void)
+{
+}
diff --git a/elf/rtld.c b/elf/rtld.c
index be2d5d8e74..847141e21d 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -378,6 +378,7 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
     ._dl_catch_error = _rtld_catch_error,
     ._dl_error_free = _dl_error_free,
     ._dl_tls_get_addr_soft = _dl_tls_get_addr_soft,
+    ._dl_libc_freeres = __rtld_libc_freeres,
 #ifdef HAVE_DL_DISCOVER_OSVERSION
     ._dl_discover_osversion = _dl_discover_osversion
 #endif