From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [COMMITTED] tests: elfcopy --reverse-offs should only swap sections next to each other.
Date: Mon, 03 Jun 2019 17:25:00 -0000 [thread overview]
Message-ID: <1559582736-12204-1-git-send-email-mark@klomp.org> (raw)
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 <mark@klomp.org>
---
tests/ChangeLog | 5 +++++
tests/elfcopy.c | 1 +
2 files changed, 6 insertions(+)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index b4877db..e038793 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2019-06-03 Mark Wielaard <mark@klomp.org>
+
+ * 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 <mark@klomp.org>
* Makefile.am (check_PROGRAMS): Add elfrdwrnop.
diff --git a/tests/elfcopy.c b/tests/elfcopy.c
index d457bad..4542222 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)))
--
1.8.3.1
reply other threads:[~2019-06-03 17:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1559582736-12204-1-git-send-email-mark@klomp.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).