1da0c48c4Sopenharmony_ci#! /bin/sh 2da0c48c4Sopenharmony_ci# Copyright (C) 1999, 2000, 2002, 2003, 2005, 2007, 2008 Red Hat, Inc. 3da0c48c4Sopenharmony_ci# This file is part of elfutils. 4da0c48c4Sopenharmony_ci# Written by Ulrich Drepper <drepper@redhat.com>, 1999. 5da0c48c4Sopenharmony_ci# 6da0c48c4Sopenharmony_ci# This file is free software; you can redistribute it and/or modify 7da0c48c4Sopenharmony_ci# it under the terms of the GNU General Public License as published by 8da0c48c4Sopenharmony_ci# the Free Software Foundation; either version 3 of the License, or 9da0c48c4Sopenharmony_ci# (at your option) any later version. 10da0c48c4Sopenharmony_ci# 11da0c48c4Sopenharmony_ci# elfutils is distributed in the hope that it will be useful, but 12da0c48c4Sopenharmony_ci# WITHOUT ANY WARRANTY; without even the implied warranty of 13da0c48c4Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14da0c48c4Sopenharmony_ci# GNU General Public License for more details. 15da0c48c4Sopenharmony_ci# 16da0c48c4Sopenharmony_ci# You should have received a copy of the GNU General Public License 17da0c48c4Sopenharmony_ci# along with this program. If not, see <http://www.gnu.org/licenses/>. 18da0c48c4Sopenharmony_ci 19da0c48c4Sopenharmony_ci. $srcdir/test-subr.sh 20da0c48c4Sopenharmony_ci 21da0c48c4Sopenharmony_cioriginal=${original:-testfile11} 22da0c48c4Sopenharmony_cistripped=${stripped:-testfile7} 23da0c48c4Sopenharmony_cidebugout=${debugfile:+-f testfile.debug.temp -F $debugfile} 24da0c48c4Sopenharmony_ci 25da0c48c4Sopenharmony_citestfiles $original 26da0c48c4Sopenharmony_citest x$stripped = xtestfile.temp || testfiles $stripped $debugfile 27da0c48c4Sopenharmony_ci 28da0c48c4Sopenharmony_citempfiles testfile.temp testfile.debug.temp testfile.unstrip 29da0c48c4Sopenharmony_ci 30da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip -o testfile.temp $debugout $original 31da0c48c4Sopenharmony_ci 32da0c48c4Sopenharmony_cistatus=0 33da0c48c4Sopenharmony_ci 34da0c48c4Sopenharmony_cicmp $stripped testfile.temp || status=$? 35da0c48c4Sopenharmony_ci 36da0c48c4Sopenharmony_ci# Check elflint and the expected result. 37da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elflint --gnu -q testfile.temp || status=$? 38da0c48c4Sopenharmony_ci 39da0c48c4Sopenharmony_citest -z "$debugfile" || { 40da0c48c4Sopenharmony_cicmp $debugfile testfile.debug.temp || status=$? 41da0c48c4Sopenharmony_ci 42da0c48c4Sopenharmony_ci# Check elflint and the expected result. 43da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile.debug.temp || status=$? 44da0c48c4Sopenharmony_ci 45da0c48c4Sopenharmony_ci# Now test unstrip recombining those files. 46da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile.temp testfile.debug.temp 47da0c48c4Sopenharmony_ci 48da0c48c4Sopenharmony_ci# Check that it came back whole. 49da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip 50da0c48c4Sopenharmony_ci} 51da0c48c4Sopenharmony_ci 52da0c48c4Sopenharmony_ci# test strip -g 53da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip -g -o testfile.temp $original 54da0c48c4Sopenharmony_ci 55da0c48c4Sopenharmony_ci# Buggy eu-strip created multiple .shstrtab sections 56da0c48c4Sopenharmony_cishstrtab_SECS=$(testrun ${abs_top_builddir}/src/readelf -S testfile.temp | grep '.shstrtab' | wc --lines) 57da0c48c4Sopenharmony_citest $shstrtab_SECS -eq 1 || 58da0c48c4Sopenharmony_ci { echo "*** failure not just one '.shstrtab' testfile.temp ($shstrtab_SECS)"; status=1; } 59da0c48c4Sopenharmony_ci 60da0c48c4Sopenharmony_ci# Now strip in-place and make sure it is smaller. 61da0c48c4Sopenharmony_ciSIZE_original=$(stat -c%s $original) 62da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip $original 63da0c48c4Sopenharmony_ciSIZE_stripped=$(stat -c%s $original) 64da0c48c4Sopenharmony_citest $SIZE_stripped -lt $SIZE_original || 65da0c48c4Sopenharmony_ci { echo "*** failure in-place strip file not smaller $original"; status=1; } 66da0c48c4Sopenharmony_ci 67da0c48c4Sopenharmony_citempfiles testfile.sections 68da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/readelf -S testfile.temp > testfile.sections || status=$? 69da0c48c4Sopenharmony_cigrep -F ' .debug_' testfile.sections && status=1 70da0c48c4Sopenharmony_ci 71da0c48c4Sopenharmony_ciexit $status 72