1da0c48c4Sopenharmony_ci#! /bin/sh 2da0c48c4Sopenharmony_ci# Copyright (C) 2017 Red Hat, Inc. 3da0c48c4Sopenharmony_ci# This file is part of elfutils. 4da0c48c4Sopenharmony_ci# 5da0c48c4Sopenharmony_ci# This file is free software; you can redistribute it and/or modify 6da0c48c4Sopenharmony_ci# it under the terms of the GNU General Public License as published by 7da0c48c4Sopenharmony_ci# the Free Software Foundation; either version 3 of the License, or 8da0c48c4Sopenharmony_ci# (at your option) any later version. 9da0c48c4Sopenharmony_ci# 10da0c48c4Sopenharmony_ci# elfutils is distributed in the hope that it will be useful, but 11da0c48c4Sopenharmony_ci# WITHOUT ANY WARRANTY; without even the implied warranty of 12da0c48c4Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13da0c48c4Sopenharmony_ci# GNU General Public License for more details. 14da0c48c4Sopenharmony_ci# 15da0c48c4Sopenharmony_ci# You should have received a copy of the GNU General Public License 16da0c48c4Sopenharmony_ci# along with this program. If not, see <http://www.gnu.org/licenses/>. 17da0c48c4Sopenharmony_ci 18da0c48c4Sopenharmony_ci. $srcdir/test-subr.sh 19da0c48c4Sopenharmony_ci 20da0c48c4Sopenharmony_ci# When stripping just the debug sections/symbols we keep the symtab 21da0c48c4Sopenharmony_ci# in the main ELF file. There should be no symbols pointing into the 22da0c48c4Sopenharmony_ci# debug sections and so there should not be a copy in the debug file 23da0c48c4Sopenharmony_ci# except for a NOBITS one. 24da0c48c4Sopenharmony_ci 25da0c48c4Sopenharmony_citempfiles a.out strip.out debug.out readelf.out 26da0c48c4Sopenharmony_ci 27da0c48c4Sopenharmony_ciecho Create debug a.out. 28da0c48c4Sopenharmony_ciecho "int main() { return 1; }" | ${CC} -g -xc - 29da0c48c4Sopenharmony_ci 30da0c48c4Sopenharmony_ciecho strip -g to file with debug file 31da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out || 32da0c48c4Sopenharmony_ci { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } 33da0c48c4Sopenharmony_ci 34da0c48c4Sopenharmony_cistatus=0 35da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out 36da0c48c4Sopenharmony_cigrep SYMTAB readelf.out || status=$? 37da0c48c4Sopenharmony_ciecho $status 38da0c48c4Sopenharmony_ciif test $status -ne 0; then 39da0c48c4Sopenharmony_ci echo no symtab found in strip.out 40da0c48c4Sopenharmony_ci exit 1 41da0c48c4Sopenharmony_cifi 42da0c48c4Sopenharmony_ci 43da0c48c4Sopenharmony_cistatus=0 44da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out 45da0c48c4Sopenharmony_cigrep SYMTAB readelf.out || status=$? 46da0c48c4Sopenharmony_ciecho $status 47da0c48c4Sopenharmony_ciif test $status -ne 1; then 48da0c48c4Sopenharmony_ci echo symtab found in debug.out 49da0c48c4Sopenharmony_ci exit 1 50da0c48c4Sopenharmony_cifi 51da0c48c4Sopenharmony_ci 52da0c48c4Sopenharmony_ci# arm (with data marker in .debug_frame). See tests/run-addrcfi.sh 53da0c48c4Sopenharmony_citestfiles testfilearm 54da0c48c4Sopenharmony_ci 55da0c48c4Sopenharmony_ciecho arm strip -g to file with debug file 56da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfilearm || 57da0c48c4Sopenharmony_ci { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } 58da0c48c4Sopenharmony_ci 59da0c48c4Sopenharmony_cistatus=0 60da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out 61da0c48c4Sopenharmony_cigrep SYMTAB readelf.out || status=$? 62da0c48c4Sopenharmony_ciecho $status 63da0c48c4Sopenharmony_ciif test $status -ne 0; then 64da0c48c4Sopenharmony_ci echo no symtab found in strip.out 65da0c48c4Sopenharmony_ci exit 1 66da0c48c4Sopenharmony_cifi 67da0c48c4Sopenharmony_ci 68da0c48c4Sopenharmony_cistatus=0 69da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out 70da0c48c4Sopenharmony_cigrep SYMTAB readelf.out || status=$? 71da0c48c4Sopenharmony_ciecho $status 72da0c48c4Sopenharmony_ciif test $status -ne 1; then 73da0c48c4Sopenharmony_ci echo symtab found in debug.out 74da0c48c4Sopenharmony_ci exit 1 75da0c48c4Sopenharmony_cifi 76da0c48c4Sopenharmony_ci 77da0c48c4Sopenharmony_ci# aarch64 (with data marker in .debug_frame). See tests/run-addrcfi.sh 78da0c48c4Sopenharmony_citestfiles testfileaarch64 79da0c48c4Sopenharmony_ci 80da0c48c4Sopenharmony_ciecho aarch64 strip -g to file with debug file 81da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfileaarch64 || 82da0c48c4Sopenharmony_ci { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } 83da0c48c4Sopenharmony_ci 84da0c48c4Sopenharmony_cistatus=0 85da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out 86da0c48c4Sopenharmony_cigrep SYMTAB readelf.out || status=$? 87da0c48c4Sopenharmony_ciecho $status 88da0c48c4Sopenharmony_ciif test $status -ne 0; then 89da0c48c4Sopenharmony_ci echo no symtab found in strip.out 90da0c48c4Sopenharmony_ci exit 1 91da0c48c4Sopenharmony_cifi 92da0c48c4Sopenharmony_ci 93da0c48c4Sopenharmony_cistatus=0 94da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out 95da0c48c4Sopenharmony_cigrep SYMTAB readelf.out || status=$? 96da0c48c4Sopenharmony_ciecho $status 97da0c48c4Sopenharmony_ciif test $status -ne 1; then 98da0c48c4Sopenharmony_ci echo symtab found in debug.out 99da0c48c4Sopenharmony_ci exit 1 100da0c48c4Sopenharmony_cifi 101da0c48c4Sopenharmony_ci 102da0c48c4Sopenharmony_ciexit 0 103