183bc517a9dca5a54ba6701581066363e78de360vboxsync#!/bin/sh
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
41afa0fe1d4d91d48502f164a70c92549adde3e5vboxsync#
c58f1213e628a545081c70e26c6b67a841cff880vboxsync# Copyright (C) 2006-2013 Oracle Corporation
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync#
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# available from http://www.virtualbox.org. This file is free software;
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# you can redistribute it and/or modify it under the terms of the GNU
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# General Public License (GPL) as published by the Free Software
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync#
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
41afa0fe1d4d91d48502f164a70c92549adde3e5vboxsync#
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# Compare undefined symbols in a shared or static object against a new-line
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync# separated list of grep patterns in a set of text files and complain if
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync# symbols are found which aren't in the files.
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync#
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync# Usage: /bin/sh <script name> <object> [--static] <undefined symbol file...>
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync#
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync# Currently only works for native objects on Linux (and Solaris?) platforms.
41afa0fe1d4d91d48502f164a70c92549adde3e5vboxsync#
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsyncechoerr()
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync{
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync echo $* 1>&2
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync}
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
71b3e8496ade32ed607650332283df431cd2ef9cvboxsynchostos="${1}"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsynctarget="${2}"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncshift 2
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncif test "${1}" = "--static"; then
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync static="${1}"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync shift
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsyncfi
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncif test $# -lt 1; then
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync echoerr "${0}: Wrong number of arguments"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync args_ok="no"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncfi
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncif test ! -r "${target}"; then
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync echoerr "${0}: '${target}' not readable"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync args_ok="no"
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsyncfi
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncfor i in "${@}"; do
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync if test ! -r "${i}"; then
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync echoerr "${0}: '${i}' not readable"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync args_ok="no"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync fi
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncdone
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncif test "$args_ok" = "no"; then
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync echoerr "Usage: $0 <object> [--static] <undefined symbol file...>"
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync exit 1
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsyncfi
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncif test "$hostos" = "solaris"; then
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync objdumpbin=/usr/sfw/bin/gobjdump
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync grepbin=/usr/sfw/bin/ggrep
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncelif test "$hostos" = "linux"; then
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync objdumpbin=`which objdump`
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync grepbin=`which grep`
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncelse
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync echoerr "$0: '$hostos' not a valid hostos string. supported 'linux' 'solaris'"
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync exit 1
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncfi
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsynccommand="-T"
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncif test "$static" = "--static"; then
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync command="-t"
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsyncfi
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncif test ! -x "${objdumpbin}"; then
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync echoerr "${0}: '${objdumpbin}' not found or not executable."
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync exit 1
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncfi
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncundefined=`"${objdumpbin}" ${command} "${target}" | kmk_sed -n 's/.*\*UND\*.*\s\([:graph:]*\)/\1/p'`
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncfor i in "${@}"; do
f5a06c01933ba6df7cc373dcf5330e3a9d59a865vboxsync undefined=`echo "${undefined}" | "${grepbin}" -w -v -f "${i}"`
71b3e8496ade32ed607650332283df431cd2ef9cvboxsyncdone
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsyncnum_undef=`echo $undefined | wc -w`
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncif test $num_undef -ne 0; then
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync echoerr "${0}: following symbols not defined in the files ${@}:"
71b3e8496ade32ed607650332283df431cd2ef9cvboxsync echoerr "${undefined}"
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync exit 1
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsyncfi
d604c03c7ae485c94bccd5629e96f5c10da81467vboxsync# Return code
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsyncexit 0
5fc54c9e295f53c39c7712ae45b17a0d77cb2a87vboxsync