VirtualBox

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

Last change on this file since 26557 was 26337, checked in by vboxsync, 15 years ago

checkUndefined.sh: Use [:blank:].

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1#! /bin/sh
2
3#
4# Copyright (C) 2006-2010 Sun Microsystems, Inc.
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# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
15# Clara, CA 95054 USA or visit http://www.sun.com if you need
16# additional information or have any questions.
17#
18
19#
20# Compare undefined symbols in a shared or static object against a new-line
21# separated list of grep patterns in a text file.
22#
23# Usage: /bin/sh <script name> <object> <allowed undefined symbols> [--static]
24#
25# Currently only works for native objects on Linux platforms
26#
27
28echoerr()
29{
30 echo $* 1>&2
31}
32
33hostos=$1
34target=$2
35symbols=$3
36static=$4
37
38if test $# -lt 3 || test $# -gt 4 || test ! -r "$target" || test ! -r "$symbols"; then
39 if test ! -r "$target"; then
40 echoerr "$0: '$target' not readable"
41 elif test ! -r "$symbols"; then
42 echoerr "$0: '$symbols' not readable"
43 else
44 echoerr "$0: Wrong number of arguments"
45 fi
46 args_ok="no"
47fi
48
49if test $# -eq 4 && test "$static" != "--static"; then
50 args_ok="no"
51fi
52
53if test "$args_ok" = "no"; then
54 echoerr "Usage: $0 <object> <allowed undefined symbols> [--static]"
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 | $grepbin '*UND*' | $grepbin -v -f $symbols | kmk_sed -e 's/^.*[[:blank:]]\(.*\)/\1/'`
80num_undef=`echo $undefined | wc -w`
81
82if test $num_undef -ne 0; then
83 echoerr "$0: following symbols not defined in $symbols:"
84 echoerr "$undefined"
85 exit 1
86fi
87# Return code
88exit 0
89
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