diff options
| author | Mark Wielaard <[email protected]> | 2011-05-16 11:33:11 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2011-05-23 21:34:01 +0200 |
| commit | 1662bc3880ae5acae6aa2a3013d193223c36f189 (patch) | |
| tree | a753f581ab934007e6285db98abde372b2d0ccfe /tests | |
| parent | 7a125b9306c4743eaee062bdab301f890e3c6309 (diff) | |
strip: Add --reloc-debug-sections option.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ChangeLog | 10 | ||||
| -rw-r--r-- | tests/Makefile.am | 5 | ||||
| -rw-r--r-- | tests/hello_i386.ko.bz2 | bin | 0 -> 47401 bytes | |||
| -rw-r--r-- | tests/hello_ppc64.ko.bz2 | bin | 0 -> 68189 bytes | |||
| -rw-r--r-- | tests/hello_x86_64.ko.bz2 | bin | 0 -> 35106 bytes | |||
| -rwxr-xr-x | tests/run-strip-reloc.sh | 114 |
6 files changed, 128 insertions, 1 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 2599b0ca..7cf816ed 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,13 @@ +2011-05-23 Mark Wielaard <[email protected]> + + * Makefile.am (TESTS): Add run-strip-reloc.sh. + (EXTRA_DIST): Add run-strip-reloc.sh, hello_i386.ko.bz2 + hello_x86_64.ko.bz2 and hello_ppc64.ko.bz2 + * run-strip-reloc.sh: New test. + * hello_i386.ko.bz2: New test file. + * hello_x86_64.ko.bz2: Likewise. + * hello_ppc64.ko.bz2: Likewise. + 2011-05-18 Mark Wielaard <[email protected]> * run-strip-groups.sh: New test. diff --git a/tests/Makefile.am b/tests/Makefile.am index 16a47e2e..07ae929d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -70,7 +70,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ newscn run-strip-test.sh run-strip-test2.sh \ run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \ run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \ - run-strip-groups.sh run-unstrip-test.sh run-unstrip-test2.sh \ + run-strip-groups.sh run-strip-reloc.sh \ + run-unstrip-test.sh run-unstrip-test2.sh \ run-ecp-test.sh run-ecp-test2.sh run-alldts.sh \ run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \ run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ @@ -111,6 +112,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-line2addr.sh run-elflint-test.sh testfile14.bz2 \ run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \ run-strip-test7.sh run-strip-test8.sh run-strip-groups.sh \ + run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \ + hello_ppc64.ko.bz2 \ run-unstrip-test.sh run-unstrip-test2.sh \ run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \ run-ranlib-test3.sh run-ranlib-test4.sh \ diff --git a/tests/hello_i386.ko.bz2 b/tests/hello_i386.ko.bz2 Binary files differnew file mode 100644 index 00000000..f89b292c --- /dev/null +++ b/tests/hello_i386.ko.bz2 diff --git a/tests/hello_ppc64.ko.bz2 b/tests/hello_ppc64.ko.bz2 Binary files differnew file mode 100644 index 00000000..f4d3ff20 --- /dev/null +++ b/tests/hello_ppc64.ko.bz2 diff --git a/tests/hello_x86_64.ko.bz2 b/tests/hello_x86_64.ko.bz2 Binary files differnew file mode 100644 index 00000000..ba06f91e --- /dev/null +++ b/tests/hello_x86_64.ko.bz2 diff --git a/tests/run-strip-reloc.sh b/tests/run-strip-reloc.sh new file mode 100755 index 00000000..1c6a8bd0 --- /dev/null +++ b/tests/run-strip-reloc.sh @@ -0,0 +1,114 @@ +#! /bin/sh +# Copyright (C) 2011 Red Hat, Inc. +# This file is part of Red Hat elfutils. +# +# Red Hat elfutils is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# Red Hat elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Red Hat elfutils; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. +# +# Red Hat elfutils is an included package of the Open Invention Network. +# An included package of the Open Invention Network is a package for which +# Open Invention Network licensees cross-license their patents. No patent +# license is granted, either expressly or impliedly, by designation as an +# included package. Should you wish to participate in the Open Invention +# Network licensing program, please visit www.openinventionnetwork.com +# <http://www.openinventionnetwork.com>. + +. $srcdir/test-subr.sh + +testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko + +status=0 +runtest() { + infile=$1 + is_ET_REL=$2 + outfile1=out.stripped1 + debugfile1=out.debug1 + outfile2=out.stripped2 + debugfile2=out.debug2 + + testrun ../src/strip -o $outfile1 -f $debugfile1 $infile || + { echo "*** failure strip $infile"; status=1; } + + testrun ../src/strip --reloc-debug-sections -o $outfile2 \ + -f $debugfile2 $infile || + { echo "*** failure strip --reloc-debug-sections $infile"; status=1; } + + # shouldn't make any difference for stripped files. + testrun ../src/readelf -a $outfile1 > readelf.out || + { echo "*** failure readelf -a outfile1 $infile"; status=1; } + + testrun_compare ../src/readelf -a $outfile2 < readelf.out || + { echo "*** failure compare stripped files $infile"; status=1; } + + # debug files however should be smaller, when ET_REL. + SIZE1=$(stat -c%s $debugfile1) + SIZE2=$(stat -c%s $debugfile2) + test \( \( $is_ET_REL -eq 1 \) -a \( $SIZE1 -gt $SIZE2 \) \) \ + -o \( \( $is_ET_REL -eq 0 \) -a \( $SIZE1 -eq $SIZE2 \) \) || + { echo "*** failure --reloc-debug-sections not smaller $infile"; status=1; } + + # Strip of DWARF section lines, offset will not match. + # Everything else should match. + testrun ../src/readelf -w $debugfile1 \ + | grep -v ^DWARF\ section > readelf.out1 || + { echo "*** failure readelf -w debugfile1 $infile"; status=1; } + + testrun ../src/readelf -w $debugfile2 \ + | grep -v ^DWARF\ section > readelf.out2 || + { echo "*** failure readelf -w debugfile2 $infile"; status=1; } + + testrun_compare cat readelf.out1 < readelf.out2 || + { echo "*** failure readelf -w compare $infile"; status=1; } + + rm -f $outfile1 $debugfile1 $outfile2 $debugfile2 readelf.out* +} + +# Most simple hello world kernel module for various architectures. +# :::::::::::::: +# Makefile +# :::::::::::::: +# obj-m := hello.o +# hello-y := init.o exit.o +# +# all: +# make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules +# :::::::::::::: +# init.c +# :::::::::::::: +# #include <linux/kernel.h> +# #include <linux/module.h> +# +# int init_module(void) +# { +# printk(KERN_INFO "Hello, world!\n"); +# return 0; +# } +# :::::::::::::: +# exit.c +# :::::::::::::: +# #include <linux/kernel.h> +# #include <linux/module.h> +# +# void cleanup_module() +# { +# printk(KERN_INFO "Goodbye, World!\n"); +# } +runtest hello_i386.ko 1 +runtest hello_x86_64.ko 1 +runtest hello_ppc64.ko 1 + +# self test, shouldn't impact non-ET_REL files at all. +runtest ../src/strip 0 +runtest ../src/strip.o 1 + +exit $status |
