VirtualBox

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

Last change on this file since 47908 was 44528, checked in by vboxsync, 12 years ago

header (C) fixes

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