about summary refs log tree commit diff
path: root/include/libc-symbols.h
diff options
context:
space:
mode:
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>2022-12-27 18:11:42 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-03-27 13:57:55 -0300
commit88677348b4de73874ca7d5a47451f42880f65f07 (patch)
tree9ebe22b88c2487331521737dfdf089f9e3e2439f /include/libc-symbols.h
parente4d336f1ace7c7ca535f7f85485373752bc76ed5 (diff)
downloadglibc-88677348b4de73874ca7d5a47451f42880f65f07.tar.gz
glibc-88677348b4de73874ca7d5a47451f42880f65f07.tar.xz
glibc-88677348b4de73874ca7d5a47451f42880f65f07.zip
Move libc_freeres_ptrs and libc_subfreeres to hidden/weak functions
They are both used by __libc_freeres to free all library malloc
allocated resources to help tooling like mtrace or valgrind with
memory leak tracking.

The current scheme uses assembly markers and linker script entries
to consolidate the free routine function pointers in the RELRO segment
and to be freed buffers in BSS.

This patch changes it to use specific free functions for
libc_freeres_ptrs buffers and call the function pointer array directly
with call_function_static_weak.

It allows the removal of both the internal macros and the linker
script sections.

Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'include/libc-symbols.h')
-rw-r--r--include/libc-symbols.h73
1 files changed, 0 insertions, 73 deletions
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 404169ce78..155781d448 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -237,79 +237,6 @@ requires at runtime the shared libraries from the glibc version used \
 for linking")
 #endif
 
-/* Resource Freeing Hooks:
-
-   Normally a process exits and the OS cleans up any allocated
-   memory.  However, when tooling like mtrace or valgrind is monitoring
-   the process we need to free all resources that are part of the
-   process in order to provide the consistency required to track
-   memory leaks.
-
-   A single public API exists and is __libc_freeres(), and this is used
-   by applications like valgrind to freee resouces.
-
-   There are 3 cases:
-
-   (a) __libc_freeres
-
-	In this case all you need to do is define the freeing routine:
-
-	foo.c:
-	libfoo_freeres_fn (foo_freeres)
-	{
-	  complex_free (mem);
-	}
-
-	This ensures the function is called at the right point to free
-	resources.
-
-   (b) __libc_freeres_ptr
-
-	The framework for (a) iterates over the list of pointers-to-free
-	in (b) and frees them.
-
-	foo.c:
-	libc_freeres_ptr (static char *foo_buffer);
-
-	Freeing these resources alaways happens last and is equivalent
-	to registering a function that does 'free (foo_buffer)'.
-
-   (c) Explicit lists of free routines to call or objects to free.
-
-	It is the intended goal to remove (a) and (b) which have some
-	non-determinism based on link order, and instead use explicit
-	lists of functions and frees to resolve cleanup ordering issues
-	and make it easy to debug and maintain.
-
-	As of today the following subsystems use (c):
-
-	Per-thread cleanup:
-	* malloc/thread-freeres.c
-
-	libdl cleanup:
-	* dlfcn/dlfreeres.c
-
-	libpthread cleanup:
-	* nptl/nptlfreeres.c
-
-	So if you need any shutdown routines to run you should add them
-	directly to the appropriate subsystem's shutdown list.  */
-
-/* Resource pointers to free in libc.so.  */
-#define libc_freeres_ptr(decl) \
-  __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
-  decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
-
-/* Resource freeing functions from libc.so go in this section.  */
-#define __libc_freeres_fn_section \
-  __attribute__ ((__used__, section ("__libc_freeres_fn")))
-
-/* Resource freeing functions for libc.so.  */
-#define libc_freeres_fn(name) \
-  static void name (void) __attribute_used__ __libc_freeres_fn_section;	\
-  text_set_element (__libc_subfreeres, name);				\
-  static void name (void)
-
 /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
    alias to ORIGINAL, when the assembler supports such declarations
    (such as in ELF).