From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60251 invoked by alias); 3 Jun 2019 17:25:46 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 60236 invoked by uid 89); 3 Jun 2019 17:25:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-18.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:mark X-Spam-Status: No, score=-18.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Jun 2019 17:25:41 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 118C33000415; Mon, 3 Jun 2019 19:25:38 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 5043A413CC18; Mon, 3 Jun 2019 19:25:38 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [COMMITTED] tests: elfcopy --reverse-offs should only swap sections next to each other. Date: Mon, 03 Jun 2019 17:25:00 -0000 Message-Id: <1559582736-12204-1-git-send-email-mark@klomp.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2019-q2/txt/msg00112.txt.bz2 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 b4877db..e038793 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 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