]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
segment_report_module: Inline read_phdr() into only caller
authorTimm Bäder <tbaeder@redhat.com>
Mon, 23 Nov 2020 12:27:09 +0000 (13:27 +0100)
committerMark Wielaard <mark@klomp.org>
Wed, 25 Nov 2020 15:32:57 +0000 (16:32 +0100)
There is now only one caller for this nested function, so get rid of it
by just inlining it there.

Signed-off-by: Timm Bäder <tbaeder@redhat.com>
libdwfl/ChangeLog
libdwfl/dwfl_segment_report_module.c

index 7e28036c6f2fc02ba146ee5b6186f6f4e0adffa8..dd0d2817e9bc302255e9575c54ce7068369f29f1 100644 (file)
@@ -1,3 +1,8 @@
+2020-11-23  Timm Bäder  <tbaeder@redhat.com>
+
+       * segment_report_module.c (dwfl_segment_report_module): Remove
+       read_phdr, do check and call memory_callback directly.
+
 2020-11-23  Timm Bäder  <tbaeder@redhat.com>
 
        * segment_report_module.c (dwfl_segment_report_module): Do one
index 514f40cc6fc0f263d4e5d70d75799fae1d06289d..0729a8f8ef991b3ba1b4becbc4d38cc083f70fbe 100644 (file)
@@ -904,31 +904,24 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
        {
          /* We can't use the memory image verbatim as the file image.
             So we'll be reading into a local image of the virtual file.  */
-
-         inline void read_phdr (GElf_Word type, GElf_Addr vaddr,
-                                GElf_Off offset, GElf_Xword filesz)
-         {
-           if (type == PT_LOAD)
-              {
-               void *into = contents + offset;
-               size_t read_size = filesz;
-               (*memory_callback) (dwfl,
-                                   addr_segndx (dwfl, segment,
-                                                vaddr + bias, false),
-                                    &into, &read_size, vaddr + bias,
-                                   read_size, memory_callback_arg);
-              }
-         }
-
           for (uint_fast16_t i = 0; i < phnum; ++i)
             {
               bool is32 = (ei_class == ELFCLASS32);
               GElf_Word type = is32 ? p32[i].p_type : p64[i].p_type;
+
+              if (type != PT_LOAD)
+                continue;
+
               GElf_Addr vaddr = is32 ? p32[i].p_vaddr : p64[i].p_vaddr;
               GElf_Off offset = is32 ? p32[i].p_offset : p64[i].p_offset;
               GElf_Xword filesz = is32 ? p32[i].p_filesz : p64[i].p_filesz;
 
-              read_phdr (type, vaddr, offset, filesz);
+              void *into = contents + offset;
+              size_t read_size = filesz;
+              (*memory_callback) (dwfl, addr_segndx (dwfl, segment,
+                                                     vaddr + bias, false),
+                                  &into, &read_size, vaddr + bias, read_size,
+                                  memory_callback_arg);
             }
        }
       else