2 # Copyright (C) 2011 Red Hat, Inc.
3 # This file is part of Red Hat elfutils.
5 # Red Hat elfutils is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; version 2 of the License.
9 # Red Hat elfutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Red Hat elfutils; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
18 # Red Hat elfutils is an included package of the Open Invention Network.
19 # An included package of the Open Invention Network is a package for which
20 # Open Invention Network licensees cross-license their patents. No patent
21 # license is granted, either expressly or impliedly, by designation as an
22 # included package. Should you wish to participate in the Open Invention
23 # Network licensing program, please visit www.openinventionnetwork.com
24 # <http://www.openinventionnetwork.com>.
26 . $srcdir/test-subr.sh
28 testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko
34 outfile1=out.stripped1
36 outfile2=out.stripped2
39 testrun ../src/strip -o $outfile1 -f $debugfile1 $infile ||
40 { echo "*** failure strip $infile"; status=1; }
42 testrun ../src/strip --reloc-debug-sections -o $outfile2 \
43 -f $debugfile2 $infile ||
44 { echo "*** failure strip --reloc-debug-sections $infile"; status=1; }
46 # shouldn't make any difference for stripped files.
47 testrun ../src/readelf -a $outfile1 > readelf.out ||
48 { echo "*** failure readelf -a outfile1 $infile"; status=1; }
50 testrun_compare ../src/readelf -a $outfile2 < readelf.out ||
51 { echo "*** failure compare stripped files $infile"; status=1; }
53 # debug files however should be smaller, when ET_REL.
54 SIZE1=$(stat -c%s $debugfile1)
55 SIZE2=$(stat -c%s $debugfile2)
56 test \( \( $is_ET_REL -eq 1 \) -a \( $SIZE1 -gt $SIZE2 \) \) \
57 -o \( \( $is_ET_REL -eq 0 \) -a \( $SIZE1 -eq $SIZE2 \) \) ||
58 { echo "*** failure --reloc-debug-sections not smaller $infile"; status=1; }
60 # Strip of DWARF section lines, offset will not match.
61 # Everything else should match.
62 testrun ../src/readelf -w $debugfile1 \
63 | grep -v ^DWARF\ section > readelf.out1 ||
64 { echo "*** failure readelf -w debugfile1 $infile"; status=1; }
66 testrun ../src/readelf -w $debugfile2 \
67 | grep -v ^DWARF\ section > readelf.out2 ||
68 { echo "*** failure readelf -w debugfile2 $infile"; status=1; }
70 testrun_compare cat readelf.out1 < readelf.out2 ||
71 { echo "*** failure readelf -w compare $infile"; status=1; }
73 rm -f $outfile1 $debugfile1 $outfile2 $debugfile2 readelf.out*
76 # Most simple hello world kernel module for various architectures.
81 # hello-y := init.o exit.o
84 # make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
88 # #include <linux/kernel.h>
89 # #include <linux/module.h>
91 # int init_module(void)
93 # printk(KERN_INFO "Hello, world!\n");
99 # #include <linux/kernel.h>
100 # #include <linux/module.h>
102 # void cleanup_module()
104 # printk(KERN_INFO "Goodbye, World!\n");
106 runtest hello_i386.ko 1
107 runtest hello_x86_64.ko 1
108 runtest hello_ppc64.ko 1
109 runtest hello_s390.ko 1
111 # self test, shouldn't impact non-ET_REL files at all.
112 runtest ../src/strip 0
113 runtest ../src/strip.o 1