diff mbox series

[v2,2/4] elf: Do not define consider_profiling, consider_symbind as macros

Message ID 8a43a5aaaa30585a9dd8f73377ab6fa755ddd1c5.1730374087.git.fweimer@redhat.com
State New
Headers show
Series elf: More careful placement of the main malloc switch | expand

Commit Message

Florian Weimer Oct. 31, 2024, 4:09 p.m. UTC
This avoids surprises when refactoring the code if these identifiers
are re-used later in the file.
---
 elf/dl-reloc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

DJ Delorie Nov. 5, 2024, 8:32 p.m. UTC | #1
(resending with fixed headers just for patchwork - DJ)

Florian Weimer <fweimer@redhat.com> writes:
> -#ifdef SHARED
>    bool consider_symbind = false;
> +#ifdef SHARED

So this symbol is always available, but set to false in the case it's not
used.  Ok.

>  #elif defined PROF
>    /* Never use dynamic linker profiling for gprof profiling code.  */
> -# define consider_profiling 0
> -#else
> -# define consider_symbind 0
> +  consider_profiling = 0;
>  #endif

So we're reusing the passed variable, but setting it to 0.  Ok.

> -#ifndef PROF
>      if ((consider_profiling || consider_symbind)
>       && l->l_info[DT_PLTRELSZ] != NULL)
>        {
> @@ -321,7 +318,6 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
>           _dl_fatal_printf (errstring, RTLD_PROGNAME, l->l_name);
>         }
>        }
> -#endif


So the #ifndef is no longer needed because the condition would always be
false.  Ok.  If the code in question were any bigger I'd worry.

LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
diff mbox series

Patch

diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index 4bf7aec88b..b2c1627ceb 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -220,8 +220,8 @@  _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
   int lazy = reloc_mode & RTLD_LAZY;
   int skip_ifunc = reloc_mode & __RTLD_NOIFUNC;
 
-#ifdef SHARED
   bool consider_symbind = false;
+#ifdef SHARED
   /* If we are auditing, install the same handlers we need for profiling.  */
   if ((reloc_mode & __RTLD_AUDIT) == 0)
     {
@@ -240,9 +240,7 @@  _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
     }
 #elif defined PROF
   /* Never use dynamic linker profiling for gprof profiling code.  */
-# define consider_profiling 0
-#else
-# define consider_symbind 0
+  consider_profiling = 0;
 #endif
 
   /* If DT_BIND_NOW is set relocate all references in this object.  We
@@ -300,7 +298,6 @@  _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
 
     ELF_DYNAMIC_RELOCATE (l, scope, lazy, consider_profiling, skip_ifunc);
 
-#ifndef PROF
     if ((consider_profiling || consider_symbind)
 	&& l->l_info[DT_PLTRELSZ] != NULL)
       {
@@ -321,7 +318,6 @@  _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
 	    _dl_fatal_printf (errstring, RTLD_PROGNAME, l->l_name);
 	  }
       }
-#endif
   }
 
   /* Mark the object so we know this work has been done.  */