summaryrefslogtreecommitdiff
path: root/libdwfl
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2020-11-12 16:03:59 +0100
committerMark Wielaard <mark@klomp.org>2020-11-19 00:05:31 +0100
commit4d5fd1909f89b0db7d2f00e6a0f7e91fabc94f8a (patch)
tree00afdc72b5017bf27d95de7f1e2a34c740c6f974 /libdwfl
parent00a25cf38d56bacae6b82c79cf226c22d12295a5 (diff)
downloadelfutils-4d5fd1909f89b0db7d2f00e6a0f7e91fabc94f8a.tar.gz
segment_report_module: Get rid of variable-length arrays
This prevents a jump which is needed in a later patch. Signed-off-by: Timm Bäder <tbaeder@redhat.com>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/dwfl_segment_report_module.c36
2 files changed, 23 insertions, 18 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 344db7c1..791cb870 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-12 Timm Bäder <tbaeder@redhat.com>
+
+ * dwfl_segment_report_module.c (dwfl_segment_report_module): Declare
+ p32 and p64 as pointers instead of arrays.
+
2020-09-18 Mark Wielaard <mark@klomp.org>
* zstd.c: New file.
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 430e13d5..dd3fdb9e 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -606,18 +606,18 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
}
}
- Elf32_Phdr (*p32)[phnum] = phdrsp;
- Elf64_Phdr (*p64)[phnum] = phdrsp;
+ Elf32_Phdr *p32 = phdrsp;
+ Elf64_Phdr *p64 = phdrsp;
if (ei_class == ELFCLASS32)
{
if (elf32_xlatetom (&xlateto, &xlatefrom, ei_data) == NULL)
found_bias = false; /* Trigger error check. */
else
for (uint_fast16_t i = 0; i < phnum; ++i)
- consider_phdr ((*p32)[i].p_type,
- (*p32)[i].p_vaddr, (*p32)[i].p_memsz,
- (*p32)[i].p_offset, (*p32)[i].p_filesz,
- (*p32)[i].p_align);
+ consider_phdr (p32[i].p_type,
+ p32[i].p_vaddr, p32[i].p_memsz,
+ p32[i].p_offset, p32[i].p_filesz,
+ p32[i].p_align);
}
else
{
@@ -625,10 +625,10 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
found_bias = false; /* Trigger error check. */
else
for (uint_fast16_t i = 0; i < phnum; ++i)
- consider_phdr ((*p64)[i].p_type,
- (*p64)[i].p_vaddr, (*p64)[i].p_memsz,
- (*p64)[i].p_offset, (*p64)[i].p_filesz,
- (*p64)[i].p_align);
+ consider_phdr (p64[i].p_type,
+ p64[i].p_vaddr, p64[i].p_memsz,
+ p64[i].p_offset, p64[i].p_filesz,
+ p64[i].p_align);
}
finish_portion (&ph_buffer, &ph_buffer_size);
@@ -796,8 +796,8 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
dyn_filesz = dyn_data_size;
void *dyns = malloc (dyn_filesz);
- Elf32_Dyn (*d32)[dyn_filesz / sizeof (Elf32_Dyn)] = dyns;
- Elf64_Dyn (*d64)[dyn_filesz / sizeof (Elf64_Dyn)] = dyns;
+ Elf32_Dyn *d32 = dyns;
+ Elf64_Dyn *d64 = dyns;
if (unlikely (dyns == NULL))
return finish ();
@@ -811,14 +811,14 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
{
if (elf32_xlatetom (&xlateto, &xlatefrom, ei_data) != NULL)
for (size_t i = 0; i < dyn_filesz / sizeof (Elf32_Dyn); ++i)
- if (consider_dyn ((*d32)[i].d_tag, (*d32)[i].d_un.d_val))
+ if (consider_dyn (d32[i].d_tag, d32[i].d_un.d_val))
break;
}
else
{
if (elf64_xlatetom (&xlateto, &xlatefrom, ei_data) != NULL)
for (size_t i = 0; i < dyn_filesz / sizeof (Elf64_Dyn); ++i)
- if (consider_dyn ((*d64)[i].d_tag, (*d64)[i].d_un.d_val))
+ if (consider_dyn (d64[i].d_tag, d64[i].d_un.d_val))
break;
}
free (dyns);
@@ -937,12 +937,12 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
if (ei_class == ELFCLASS32)
for (uint_fast16_t i = 0; i < phnum; ++i)
- read_phdr ((*p32)[i].p_type, (*p32)[i].p_vaddr,
- (*p32)[i].p_offset, (*p32)[i].p_filesz);
+ read_phdr (p32[i].p_type, p32[i].p_vaddr,
+ p32[i].p_offset, p32[i].p_filesz);
else
for (uint_fast16_t i = 0; i < phnum; ++i)
- read_phdr ((*p64)[i].p_type, (*p64)[i].p_vaddr,
- (*p64)[i].p_offset, (*p64)[i].p_filesz);
+ read_phdr (p64[i].p_type, p64[i].p_vaddr,
+ p64[i].p_offset, p64[i].p_filesz);
}
else
{