]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Remove _dl_process_pt_note
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 10 Apr 2026 04:14:39 +0000 (12:14 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 15 Apr 2026 21:36:51 +0000 (05:36 +0800)
_dl_map_object_from_fd and rtld_setup_main_map have

  for (ph = &l->l_phdr[l->l_phnum]; ph != l->l_phdr; --ph)
    switch (ph[-1].p_type)
      {
      case PT_NOTE:
        _dl_process_pt_note (l, fd, &ph[-1]);
        break;
      case PT_GNU_PROPERTY:
        _dl_process_pt_gnu_property (l, fd, &ph[-1]);
        break;
      }

_dl_process_pt_note is empty, except for sysdeps/x86/dl-prop.h:

static inline void __attribute__ ((unused))
_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
{
  const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
  _dl_process_property_note (l, note, ph->p_memsz, ph->p_align);
}

Since all current CET enabled binaries have PT_GNU_PROPERTY, we can drop
_dl_process_pt_note.  This fixes BZ #34064.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
elf/dl-load.c
elf/rtld.c
sysdeps/aarch64/dl-prop.h
sysdeps/generic/dl-prop.h
sysdeps/x86/dl-prop.h

index 7355eef8e760ee9a2d07b2c8e166d91d72f578e2..a5693a3a66f9ec26c8418a03f58d046688aecdcb 100644 (file)
@@ -1332,15 +1332,11 @@ cannot enable executable stack as shared object requires");
 
   /* Process program headers again after load segments are mapped in
      case processing requires accessing those segments.  Scan program
-     headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY
-     exits.  */
+     headers backward since PT_GNU_PROPERTY is close to the end of
+     program headers.  */
   for (ph = &l->l_phdr[l->l_phnum]; ph != l->l_phdr; --ph)
-    switch (ph[-1].p_type)
+    if (ph[-1].p_type == PT_GNU_PROPERTY)
       {
-      case PT_NOTE:
-       _dl_process_pt_note (l, fd, &ph[-1]);
-       break;
-      case PT_GNU_PROPERTY:
        _dl_process_pt_gnu_property (l, fd, &ph[-1]);
        break;
       }
index 0eac823749babded8812afec1cba759de09b7c88..e926ec73e497b190c040c3a7f237c4b315cae076 100644 (file)
@@ -1209,15 +1209,11 @@ rtld_setup_main_map (struct link_map *main_map)
        main_map->l_relro_size = ph->p_memsz;
        break;
       }
-  /* Process program headers again, but scan them backwards so
-     that PT_NOTE can be skipped if PT_GNU_PROPERTY exits.  */
+  /* Process program headers again, but scan them backwards since
+     PT_GNU_PROPERTY is close to the end of program headers.   */
   for (const ElfW(Phdr) *ph = &phdr[phnum]; ph != phdr; --ph)
-    switch (ph[-1].p_type)
+    if (ph[-1].p_type == PT_GNU_PROPERTY)
       {
-      case PT_NOTE:
-       _dl_process_pt_note (main_map, -1, &ph[-1]);
-       break;
-      case PT_GNU_PROPERTY:
        _dl_process_pt_gnu_property (main_map, -1, &ph[-1]);
        break;
       }
index cf236df59bb43519e6e244053e060cb4d63c9fe5..0d2672d32d297ca924cf3e4b515843ecfef9b471 100644 (file)
@@ -41,11 +41,6 @@ _dl_open_check (struct link_map *m, int dlopen_mode)
   _dl_gcs_check (m, NULL, dlopen_mode);
 }
 
-static inline void __attribute__ ((always_inline))
-_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
-{
-}
-
 static inline int
 _dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
                          uint32_t datasz, void *data)
index 0e65c51b8cf6ff10148837561ef5e922673c0a76..6a1e1eeff88a86fa986a056f68d293ff20c7b98e 100644 (file)
@@ -36,11 +36,6 @@ _dl_open_check (struct link_map *m, int dlopen_mode)
 {
 }
 
-static inline void __attribute__ ((always_inline))
-_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
-{
-}
-
 /* Called for each property in the NT_GNU_PROPERTY_TYPE_0 note of L,
    processing of the properties continues until this returns 0.  */
 static inline int __attribute__ ((always_inline))
index 19ae873927600468956288e004c430ab3668e073..a466eba3311c0324ff2c05537eba937c0a1c6d45 100644 (file)
@@ -229,13 +229,6 @@ _dl_process_property_note (struct link_map *l, const ElfW(Nhdr) *note,
     l->l_property = lc_property_none;
 }
 
-static inline void __attribute__ ((unused))
-_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
-{
-  const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
-  _dl_process_property_note (l, note, ph->p_memsz, ph->p_align);
-}
-
 static inline int __attribute__ ((always_inline))
 _dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
                          uint32_t datasz, void *data)