diff mbox series

[1/3] elf: In _dl_relocate_object, skip processing if object is relocated

Message ID 765fa8fd1d282964cf158d425b7e2cba28f79cb8.1700829130.git.fweimer@redhat.com
State New
Headers show
Series Compatibility improvement for underlinked objects | expand

Commit Message

Florian Weimer Nov. 24, 2023, 12:56 p.m. UTC
This is just a minor optimization.  It also makes it more obvious that
_dl_relocate_object can be called multiple times.
---
 elf/dl-reloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Carlos O'Donell Nov. 24, 2023, 5:04 p.m. UTC | #1
On 11/24/23 07:56, Florian Weimer wrote:
> This is just a minor optimization.  It also makes it more obvious that
> _dl_relocate_object can be called multiple times.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  elf/dl-reloc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
> index e5c555d82c..72c8586d29 100644
> --- a/elf/dl-reloc.c
> +++ b/elf/dl-reloc.c
> @@ -205,6 +205,9 @@ void
>  _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
>  		     int reloc_mode, int consider_profiling)
>  {
> +  if (l->l_relocated)
> +    return;

OK. Stop earlier. All we did between here and the previous location was
preparatory work to consider profiling or symbol binding in the auditors.

> +
>    struct textrels
>    {
>      caddr_t start;
> @@ -242,9 +245,6 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
>  # define consider_symbind 0
>  #endif
>  
> -  if (l->l_relocated)
> -    return;
> -
>    /* If DT_BIND_NOW is set relocate all references in this object.  We
>       do not do this if we are profiling, of course.  */
>    // XXX Correct for auditing?
diff mbox series

Patch

diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index e5c555d82c..72c8586d29 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -205,6 +205,9 @@  void
 _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
 		     int reloc_mode, int consider_profiling)
 {
+  if (l->l_relocated)
+    return;
+
   struct textrels
   {
     caddr_t start;
@@ -242,9 +245,6 @@  _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
 # define consider_symbind 0
 #endif
 
-  if (l->l_relocated)
-    return;
-
   /* If DT_BIND_NOW is set relocate all references in this object.  We
      do not do this if we are profiling, of course.  */
   // XXX Correct for auditing?