[BACK]Return to ctfstrip CVS log [TXT][DIR] Up to [local] / src / usr.bin / ctfconv

File: [local] / src / usr.bin / ctfconv / ctfstrip (download)

Revision 1.1, Fri Aug 11 14:21:24 2017 UTC (6 years, 10 months ago) by mpi
Branch: MAIN

Import a tool for generating CTF data section (SUNW_ctf) based on DWARF
information.

ctfconv(1) support multiple CUs in order to work on binaries.  ctfstrip(1)
works like strip(1) but also insert a .SUNW_ctf section inside a binary.

ok deraadt@, kettenis@, jasper@

#!/bin/sh

# Turn off Strict Bourne shell mode.
set +o sh

USAGE="usage: ${0##*/} [-S] [-o outfile] file"

while getopts "o:S" opt; do
	case $opt in
	S)	STRIPFLAG=-g;;
	o)	OUTFILE="${OPTARG}";;
	*)	print -u2 "${USAGE}"; exit 1;;
	esac
done
shift $((OPTIND-1))

if [[ $# == 0 ]]; then
	print -u2 "${USAGE}";
	exit 1
fi

LABEL="unknown"
TMPFILE=$1.rawctf

# Extract kernel verison
if [[ "$1" == bsd* ]]; then
	LABEL=`what $1 |tr -d '\n'|awk -F"$1	" '{ print $2 '\n' }'`
fi

ctfconv -o ${TMPFILE} -l "${LABEL}" $1 || exit 2

objcopy --add-section .SUNW_ctf=${TMPFILE} ${STRIPFLAG} $1 ${OUTFILE}

rm -f ${TMPFILE}