diff mbox series

linux: Annotate mode anonymous allocated maps

Message ID 20240731150452.532026-1-adhemerval.zanella@linaro.org
State New
Headers show
Series linux: Annotate mode anonymous allocated maps | expand

Commit Message

Adhemerval Zanella Netto July 31, 2024, 3:04 p.m. UTC
For VMAs that are supposed to be long lasting.
---
 elf/dl-fptr.c            | 3 +++
 elf/dl-map-segments.h    | 3 +++
 sysdeps/arm/dl-machine.h | 2 ++
 sysdeps/hppa/dl-fptr.c   | 3 +++
 4 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/elf/dl-fptr.c b/elf/dl-fptr.c
index 575406ae44..5eebd4e1f6 100644
--- a/elf/dl-fptr.c
+++ b/elf/dl-fptr.c
@@ -27,6 +27,7 @@ 
 #include <dl-fptr.h>
 #include <dl-unmap-segments.h>
 #include <atomic.h>
+#include <setvmaname.h>
 
 #ifndef ELF_MACHINE_BOOT_FPTR_TABLE_LEN
 /* ELF_MACHINE_BOOT_FPTR_TABLE_LEN should be greater than the number of
@@ -86,6 +87,7 @@  new_fdesc_table (struct local *l, size_t *size)
   if (new_table == MAP_FAILED)
     _dl_signal_error (errno, NULL, NULL,
 		      N_("cannot map pages for fdesc table"));
+  __set_vma_name (new_table, *size, " glibc: fdesc table");
 
   new_table->len
     = (*size - sizeof (*new_table)) / sizeof (struct fdesc);
@@ -190,6 +192,7 @@  make_fptr_table (struct link_map *map)
   if (fptr_table == MAP_FAILED)
     _dl_signal_error (errno, NULL, NULL,
 		      N_("cannot map pages for fptr table"));
+  __set_vma_name (new_table, *size, " glibc: fdesc table");
 
   if (COMPARE_AND_SWAP ((ElfW(Addr) *) &map->l_mach.fptr_table,
 			(ElfW(Addr)) NULL, (ElfW(Addr)) fptr_table))
diff --git a/elf/dl-map-segments.h b/elf/dl-map-segments.h
index 30977cf800..be3ad41a9a 100644
--- a/elf/dl-map-segments.h
+++ b/elf/dl-map-segments.h
@@ -18,6 +18,7 @@ 
    <https://www.gnu.org/licenses/>.  */
 
 #include <dl-load.h>
+#include <setvmaname.h>
 
 /* Map a segment and align it properly.  */
 
@@ -188,6 +189,8 @@  _dl_map_segments (struct link_map *l, int fd,
                               -1, 0);
               if (__glibc_unlikely (mapat == MAP_FAILED))
                 return DL_MAP_SEGMENTS_ERROR_MAP_ZERO_FILL;
+	      __set_vma_name (mapat, zeroend - zeropage,
+			      " glibc: zero padding");
             }
         }
 
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
index 9186831be3..7cb38c9726 100644
--- a/sysdeps/arm/dl-machine.h
+++ b/sysdeps/arm/dl-machine.h
@@ -28,6 +28,7 @@ 
 #include <dl-irel.h>
 #include <dl-static-tls.h>
 #include <dl-machine-rel.h>
+#include <setvmaname.h>
 
 #ifndef CLEAR_CACHE
 # error CLEAR_CACHE definition required to handle TEXTREL
@@ -259,6 +260,7 @@  relocate_pc24 (struct link_map *map, Elf32_Addr value,
           if (new_page == MAP_FAILED)
             _dl_signal_error (0, map->l_name, NULL,
                               "could not map page for fixup");
+	  __set_vma_name (new_page, GLRO(dl_pagesize), " glibc: arm fixup");
           fix_page = new_page;
           assert (fix_offset == 0);
         }
diff --git a/sysdeps/hppa/dl-fptr.c b/sysdeps/hppa/dl-fptr.c
index e24a522998..be3096db44 100644
--- a/sysdeps/hppa/dl-fptr.c
+++ b/sysdeps/hppa/dl-fptr.c
@@ -30,6 +30,7 @@ 
 #include <dl-unmap-segments.h>
 #include <atomic.h>
 #include <libc-pointer-arith.h>
+#include <setvmaname.h>
 
 #ifndef ELF_MACHINE_BOOT_FPTR_TABLE_LEN
 /* ELF_MACHINE_BOOT_FPTR_TABLE_LEN should be greater than the number of
@@ -94,6 +95,7 @@  new_fdesc_table (struct local *l, size_t *size)
   if (new_table == MAP_FAILED)
     _dl_signal_error (errno, NULL, NULL,
 		      N_("cannot map pages for fdesc table"));
+  __set_vma_name (new_table, *size, " glibc: fdesc table");
 
   new_table->len
     = (*size - sizeof (*new_table)) / sizeof (struct fdesc);
@@ -212,6 +214,7 @@  make_fptr_table (struct link_map *map)
   if (fptr_table == MAP_FAILED)
     _dl_signal_error (errno, NULL, NULL,
 		      N_("cannot map pages for fptr table"));
+  __set_vma_name (fptr_table, size, " glibc: fdesc table");
 
   if (COMPARE_AND_SWAP ((ElfW(Addr) *) &map->l_mach.fptr_table,
 			(ElfW(Addr)) NULL, (ElfW(Addr)) fptr_table))