Remove the ALLOW_UNALIGNED code in check_scn_group. The fallback
memcpy code does the right thing and generates the same code.
Also replace the two elf32_fsize calls with gelf_fsize calls like the
rest of the code does. Both request the size of a ELF_T_WORD, which is
4 bytes on both 32 and 64 bit ELF, so it works the same, but it was a
little confusing.
* src/elflint.c (check_scn_group): Use gelf_fsize instead of
elf32_fsize. Drop ALLOW_UNALIGNED code.
Signed-off-by: Mark Wielaard <[email protected]>
---
src/elflint.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/src/elflint.c b/src/elflint.c
index 75452c0c8ff7..29489b70fb28 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2723,7 +2723,8 @@ section [%2d] '%s': signature symbol cannot be empty
string\n"),
idx, section_name (ebl, idx));
if (be_strict
- && shdr->sh_entsize != elf32_fsize (ELF_T_WORD, 1, EV_CURRENT))
+ && shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_WORD, 1,
+ EV_CURRENT))
ERROR (_("section [%2d] '%s': sh_flags not set correctly\n"),
idx, section_name (ebl, idx));
}
@@ -2734,7 +2735,7 @@ section [%2d] '%s': signature symbol cannot be empty
string\n"),
idx, section_name (ebl, idx), elf_errmsg (-1));
else
{
- size_t elsize = elf32_fsize (ELF_T_WORD, 1, EV_CURRENT);
+ size_t elsize = gelf_fsize (ebl->elf, ELF_T_WORD, 1, EV_CURRENT);
size_t cnt;
Elf32_Word val;
@@ -2762,22 +2763,14 @@ section [%2d] '%s': section group with only one
member\n"),
idx, section_name (ebl, idx));
}
-#if ALLOW_UNALIGNED
- val = *((Elf32_Word *) data->d_buf);
-#else
memcpy (&val, data->d_buf, elsize);
-#endif
if ((val & ~GRP_COMDAT) != 0)
ERROR (_("section [%2d] '%s': unknown section group flags\n"),
idx, section_name (ebl, idx));
for (cnt = elsize; cnt + elsize <= data->d_size; cnt += elsize)
{
-#if ALLOW_UNALIGNED
- val = *((Elf32_Word *) ((char *) data->d_buf + cnt));
-#else
memcpy (&val, (char *) data->d_buf + cnt, elsize);
-#endif
if (val > shnum)
ERROR (_("\
--
2.56.1