From d08c68fec94b26663257d24dbb8d94f2ed8935cd Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 3 Jun 2019 18:00:20 +0200 Subject: tests: elfcopy --reverse-offs should only swap sections next to each other. The run-reverse-sections-self.sh (which really should have been called "swap-sections") could fail if the ELF file had sections that were not directly next to each other swapped. Add a check to make sure the swapped sections are actually directly next to each other. Signed-off-by: Mark Wielaard --- tests/ChangeLog | 5 +++++ tests/elfcopy.c | 1 + 2 files changed, 6 insertions(+) diff --git a/tests/ChangeLog b/tests/ChangeLog index b4877db5..e0387939 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2019-06-03 Mark Wielaard + + * elfcopy.c (copy_elf): When swapping the sh_offsets of two sections, + make sure they are actually next to each other. + 2019-05-12 Mark Wielaard * Makefile.am (check_PROGRAMS): Add elfrdwrnop. diff --git a/tests/elfcopy.c b/tests/elfcopy.c index d457badb..4542222e 100644 --- a/tests/elfcopy.c +++ b/tests/elfcopy.c @@ -225,6 +225,7 @@ copy_elf (const char *in, const char *out, bool use_mmap, bool reverse_offs) && shdr.sh_addralign == 1 && last_shdr.sh_type != SHT_NOBITS && shdr.sh_type != SHT_NOBITS + && last_shdr.sh_offset + last_shdr.sh_size == shdr.sh_offset && (phnum == 0 || ((shdr.sh_flags & SHF_ALLOC) == 0 && (last_shdr.sh_flags & SHF_ALLOC) == 0))) -- cgit v1.2.1