VirtualBox

source: vbox/trunk/src/bldprogs/checkUndefined.sh@ 104448

Last change on this file since 104448 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1#!/bin/sh
2
3#
4# Copyright (C) 2006-2023 Oracle and/or its affiliates.
5#
6# This file is part of VirtualBox base platform packages, as
7# available from https://www.virtualbox.org.
8#
9# This program is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public License
11# as published by the Free Software Foundation, in version 3 of the
12# License.
13#
14# This program is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17# General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, see <https://www.gnu.org/licenses>.
21#
22# SPDX-License-Identifier: GPL-3.0-only
23#
24
25#
26# Compare undefined symbols in a shared or static object against a new-line
27# separated list of grep patterns in a set of text files and complain if
28# symbols are found which aren't in the files.
29#
30# Usage: /bin/sh <script name> <object> [--static] <undefined symbol file...>
31#
32# Currently only works for native objects on Linux (and Solaris?) platforms.
33#
34
35echoerr()
36{
37 echo $* 1>&2
38}
39
40hostos="${1}"
41target="${2}"
42shift 2
43if test "${1}" = "--static"; then
44 static="${1}"
45 shift
46fi
47
48if test $# -lt 1; then
49 echoerr "${0}: Wrong number of arguments"
50 args_ok="no"
51fi
52if test ! -r "${target}"; then
53 echoerr "${0}: '${target}' not readable"
54 args_ok="no"
55fi
56for i in "${@}"; do
57 if test ! -r "${i}"; then
58 echoerr "${0}: '${i}' not readable"
59 args_ok="no"
60 fi
61done
62
63if test "$args_ok" = "no"; then
64 echoerr "Usage: $0 <object> [--static] <undefined symbol file...>"
65 exit 1
66fi
67
68if test "$hostos" = "solaris"; then
69 objdumpbin=/usr/sfw/bin/gobjdump
70 grepbin=/usr/sfw/bin/ggrep
71elif test "$hostos" = "linux"; then
72 objdumpbin=`which objdump`
73 grepbin=`which grep`
74else
75 echoerr "$0: '$hostos' not a valid hostos string. supported 'linux' 'solaris'"
76 exit 1
77fi
78
79command="-T"
80if test "$static" = "--static"; then
81 command="-t"
82fi
83
84if test ! -x "${objdumpbin}"; then
85 echoerr "${0}: '${objdumpbin}' not found or not executable."
86 exit 1
87fi
88
89undefined=`"${objdumpbin}" ${command} "${target}" | kmk_sed -n 's/.*\*UND\*.*\s\([:graph:]*\)/\1/p'`
90for i in "${@}"; do
91 undefined=`echo "${undefined}" | "${grepbin}" -w -v -f "${i}"`
92done
93num_undef=`echo $undefined | wc -w`
94
95if test $num_undef -ne 0; then
96 echoerr "${0}: following symbols not defined in the files ${@}:"
97 echoerr "${undefined}"
98 exit 1
99fi
100# Return code
101exit 0
102
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette