2 # Copyright (C) 2011 Red Hat, Inc.
3 # This file is part of elfutils.
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.
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.
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/>.
18 . $srcdir/test-subr.sh
20 testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko
26 outfile1=out.stripped1
28 outfile2=out.stripped2
31 testrun ../src/strip -o $outfile1 -f $debugfile1 $infile ||
32 { echo "*** failure strip $infile"; status=1; }
34 testrun ../src/strip --reloc-debug-sections -o $outfile2 \
35 -f $debugfile2 $infile ||
36 { echo "*** failure strip --reloc-debug-sections $infile"; status=1; }
38 # shouldn't make any difference for stripped files.
39 testrun ../src/readelf -a $outfile1 > readelf.out ||
40 { echo "*** failure readelf -a outfile1 $infile"; status=1; }
42 testrun_compare ../src/readelf -a $outfile2 < readelf.out ||
43 { echo "*** failure compare stripped files $infile"; status=1; }
45 # debug files however should be smaller, when ET_REL.
46 SIZE1=$(stat -c%s $debugfile1)
47 SIZE2=$(stat -c%s $debugfile2)
48 test \( \( $is_ET_REL -eq 1 \) -a \( $SIZE1 -gt $SIZE2 \) \) \
49 -o \( \( $is_ET_REL -eq 0 \) -a \( $SIZE1 -eq $SIZE2 \) \) ||
50 { echo "*** failure --reloc-debug-sections not smaller $infile"; status=1; }
52 # Strip of DWARF section lines, offset will not match.
53 # Everything else should match.
54 testrun ../src/readelf -w $debugfile1 \
55 | grep -v ^DWARF\ section > readelf.out1 ||
56 { echo "*** failure readelf -w debugfile1 $infile"; status=1; }
58 testrun ../src/readelf -w $debugfile2 \
59 | grep -v ^DWARF\ section > readelf.out2 ||
60 { echo "*** failure readelf -w debugfile2 $infile"; status=1; }
62 testrun_compare cat readelf.out1 < readelf.out2 ||
63 { echo "*** failure readelf -w compare $infile"; status=1; }
65 rm -f $outfile1 $debugfile1 $outfile2 $debugfile2 readelf.out*
68 # Most simple hello world kernel module for various architectures.
73 # hello-y := init.o exit.o
76 # make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
80 # #include <linux/kernel.h>
81 # #include <linux/module.h>
83 # int init_module(void)
85 # printk(KERN_INFO "Hello, world!\n");
91 # #include <linux/kernel.h>
92 # #include <linux/module.h>
94 # void cleanup_module()
96 # printk(KERN_INFO "Goodbye, World!\n");
98 runtest hello_i386.ko 1
99 runtest hello_x86_64.ko 1
100 runtest hello_ppc64.ko 1
101 runtest hello_s390.ko 1
103 # self test, shouldn't impact non-ET_REL files at all.
104 runtest ../src/strip 0
105 runtest ../src/strip.o 1