1#!/bin/ksh 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# Copyright 2023, Richard Lowe. 14 15TESTDIR=$(dirname $0) 16 17tmpdir=/tmp/test.$$ 18mkdir $tmpdir 19cd $tmpdir 20 21cleanup() { 22 cd / 23 rm -fr $tmpdir 24} 25 26trap 'cleanup' EXIT 27 28if [[ $PWD != $tmpdir ]]; then 29 print -u2 "Failed to create temporary directory: $tmpdir" 30 exit 1; 31fi 32 33if [[ -n $PROTO ]]; then 34 export LD_ALTEXEC=$PROTO/bin/ld 35fi 36 37gas -c ${TESTDIR}/strip-all-sections.s -o strip-all-obj1.o 38if (( $? != 0 )); then 39 print -u2 "Couldn't assemble ${TESTDIR}/strip-all-section.s (obj1)" 40 exit 1; 41fi 42 43/bin/ld -s strip-all-obj1.o -o strip-all 44if (( $? != 0 )); then 45 print -u2 "Couldn't link ${TESTDIR}/strip-all" 46 exit 1; 47fi 48 49if [[ $(elfdump -cN.debug_stuff strip-all) != "" || 50 $(elfdump -cN.debug_data strip-all) != "" || 51 $(elfdump -cN.debug_code strip-all) != "" ]]; then 52 print -u2 ".debug sections not stripped" 53 exit 1 54fi 55 56# Test that the group, which is now empty, doesn't make it through ld -r 57# and that we don't crash 58/bin/ld -r -s strip-all-obj1.o -o strip-all.o 59if (( $? != 0 )); then 60 print -u2 "Couldn't link ${TESTDIR}/strip-all.o" 61 exit 1; 62fi 63 64if [[ $(elfdump -cN.group strip-all.o) != "" ]]; then 65 print -u2 "A group section survived despite all members getting stripped" 66 exit 1 67fi 68