1#! /bin/sh
2# Copyright (C) 2015 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
20# Generate a file with merged .shstrtab/.strtab table.
21# strip and unstrip it. Check all files with elflint.
22
23# A random ET_EXEC file
24input=${abs_top_builddir}/tests/elfstrmerge
25merged=merged.elf
26stripped=${merged}.stripped
27debugfile=${merged}.debug
28remerged=remerged.elf
29
30tempfiles $merged $stripped $debugfile $remerged
31
32echo elflint $input
33testrun ${abs_top_builddir}/src/elflint --gnu $input
34echo elfstrmerge
35testrun ${abs_top_builddir}/tests/elfstrmerge -o $merged $input
36echo elflint $merged
37testrun ${abs_top_builddir}/src/elflint --gnu $merged
38echo strip
39testrun ${abs_top_builddir}/src/strip -o $stripped -f $debugfile $merged
40echo elflint $stripped
41testrun ${abs_top_builddir}/src/elflint --gnu $stripped
42echo elflint $debugfile
43testrun ${abs_top_builddir}/src/elflint --gnu -d $debugfile
44echo unstrip
45testrun ${abs_top_builddir}/src/unstrip -o $remerged $stripped $debugfile
46echo elflint $remerged
47testrun ${abs_top_builddir}/src/elflint --gnu $remerged
48echo elfcmp
49testrun ${abs_top_builddir}/src/elfcmp $merged $remerged
50
51# A random ET_REL file
52input=${abs_top_builddir}/tests/elfstrmerge.o
53merged=merged.elf
54stripped=${merged}.stripped
55debugfile=${merged}.debug
56remerged=remerged.elf
57
58tempfiles $merged $stripped $debugfile $remerged
59
60echo elflint $input
61testrun ${abs_top_builddir}/src/elflint --gnu $input
62echo elfstrmerge
63testrun ${abs_top_builddir}/tests/elfstrmerge -o $merged $input
64echo elflint $merged
65testrun ${abs_top_builddir}/src/elflint --gnu $merged
66echo strip
67testrun ${abs_top_builddir}/src/strip -o $stripped -f $debugfile $merged
68echo elflint $stripped
69testrun ${abs_top_builddir}/src/elflint --gnu $stripped
70echo elflint $debugfile
71testrun ${abs_top_builddir}/src/elflint --gnu -d $debugfile
72echo unstrip
73testrun ${abs_top_builddir}/src/unstrip -o $remerged $stripped $debugfile
74echo elflint $remerged
75testrun ${abs_top_builddir}/src/elflint --gnu $remerged
76echo elfcmp
77testrun ${abs_top_builddir}/src/elfcmp $merged $remerged
78
79exit 0
80