1#!/usr/local/bin/bash
2# Copyright (C) 2019 Red Hat, Inc.
3# This file is part of elfutils.
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# elfutils is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18. $srcdir/test-subr.sh
19
20test_reverse_self ()
21{
22  in_file="$1"
23  base_name="$(basename ${in_file})"
24  out_file="${base_name}.rev"
25  out_file_mmap="${out_file}.mmap"
26
27  tempfiles ${out_file} ${out_file_mmap}
28
29  # Reverse the offsets (the files should still be the same otherwise)
30  testrun ${abs_builddir}/elfcopy --reverse-offs ${in_file} ${out_file}
31  testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file}
32  testrun ${abs_top_builddir}/src/elflint --gnu ${out_file}
33  # An in-place nop will likely revert them back
34  testrun ${abs_builddir}/elfrdwrnop ${out_file}
35  testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file}
36  testrun ${abs_top_builddir}/src/elflint --gnu ${out_file}
37}
38
39# Only really makes sense for ET_REL files, but try all, just to check
40# it also works if we keep the order for the allocated sections.
41for file in $self_test_files; do
42  test_reverse_self $file
43done
44
45exit 0
46