]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
strip: Replace nested check_preserved function with loop
authorTimm Bäder <tbaeder@redhat.com>
Fri, 8 Jan 2021 08:04:46 +0000 (09:04 +0100)
committerMark Wielaard <mark@klomp.org>
Thu, 28 Jan 2021 12:14:13 +0000 (13:14 +0100)
Signed-off-by: Timm Bäder <tbaeder@redhat.com>
src/ChangeLog
src/strip.c

index bd76256e2fcd53af6570946b34bce50a9ea8b89f..382a8f47deb609fc6023d2848eb6899f8a2b201c 100644 (file)
@@ -1,3 +1,7 @@
+2021-01-08  Timm Bäder  <tbaeder@redhat.com>
+
+       * strip.c (handle_elf): Expand inlined function check_preserved.
+
 2021-01-12  Mark Wielaard  <mark@klomp.org>
 
        * elflint.c (EXTRA_SHFLAGS): New define.
index 7ce14ab863afd2044f2215a9b5be035735bf24f1..c971b6c2418c3f9a4b6c3b16cbbc050bcb0275e6 100644 (file)
@@ -1535,25 +1535,30 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
                 files by setting the .debug_data pointer to the original
                 file's .data pointer.  Below, we'll copy the section
                 contents.  */
+             size_t shdr_indices[2] = { shdr_info[cnt].shdr.sh_link, 0 };
+             int n = 1;
 
-             inline void check_preserved (size_t i)
-             {
-               if (i != 0 && i < shnum + 2 && shdr_info[i].idx != 0
-                   && shdr_info[i].debug_data == NULL)
-                 {
-                   if (shdr_info[i].data == NULL)
-                     shdr_info[i].data = elf_getdata (shdr_info[i].scn, NULL);
-                   if (shdr_info[i].data == NULL)
-                     INTERNAL_ERROR (fname);
+             if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
+               {
+                 shdr_indices[1] = shdr_info[cnt].shdr.sh_info;
+                 n++;
+               }
 
-                   shdr_info[i].debug_data = shdr_info[i].data;
-                   changes |= i < cnt;
-                 }
-             }
+             for (int j = 0; j < n; j++)
+               {
+                 size_t i = shdr_indices[j];
+                 if (i != 0 && i < shnum + 2 && shdr_info[i].idx != 0
+                     && shdr_info[i].debug_data == NULL)
+                   {
+                     if (shdr_info[i].data == NULL)
+                       shdr_info[i].data = elf_getdata (shdr_info[i].scn, NULL);
+                     if (shdr_info[i].data == NULL)
+                       INTERNAL_ERROR (fname);
 
-             check_preserved (shdr_info[cnt].shdr.sh_link);
-             if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
-               check_preserved (shdr_info[cnt].shdr.sh_info);
+                     shdr_info[i].debug_data = shdr_info[i].data;
+                     changes |= i < cnt;
+                   }
+               }
            }
        }
     }