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 |
|
---|
28 | echoerr()
|
---|
29 | {
|
---|
30 | echo $* 1>&2
|
---|
31 | }
|
---|
32 |
|
---|
33 | hostos=$1
|
---|
34 | target=$2
|
---|
35 | symbols=$3
|
---|
36 | static=$4
|
---|
37 |
|
---|
38 | if 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"
|
---|
47 | fi
|
---|
48 |
|
---|
49 | if test $# -eq 4 && test "$static" != "--static"; then
|
---|
50 | args_ok="no"
|
---|
51 | fi
|
---|
52 |
|
---|
53 | if test "$args_ok" = "no"; then
|
---|
54 | echoerr "Usage: $0 <object> <allowed undefined symbols> [--static]"
|
---|
55 | exit 1
|
---|
56 | fi
|
---|
57 |
|
---|
58 | if test "$hostos" = "solaris"; then
|
---|
59 | objdumpbin=/usr/sfw/bin/gobjdump
|
---|
60 | grepbin=/usr/sfw/bin/ggrep
|
---|
61 | elif test "$hostos" = "linux"; then
|
---|
62 | objdumpbin=`which objdump`
|
---|
63 | grepbin=`which grep`
|
---|
64 | else
|
---|
65 | echoerr "$0: '$hostos' not a valid hostos string. supported 'linux' 'solaris'"
|
---|
66 | exit 1
|
---|
67 | fi
|
---|
68 |
|
---|
69 | command="-T"
|
---|
70 | if test "$static" = "--static"; then
|
---|
71 | command="-t"
|
---|
72 | fi
|
---|
73 |
|
---|
74 | if test ! -x "$objdumpbin"; then
|
---|
75 | echoerr "$0: '$objdumpbin' not found or not executable."
|
---|
76 | exit 1
|
---|
77 | fi
|
---|
78 |
|
---|
79 | undefined=`$objdumpbin $command $target | $grepbin '*UND*' | $grepbin -v -f $symbols | kmk_sed -e 's/^.*[[:blank:]]\(.*\)/\1/'`
|
---|
80 | num_undef=`echo $undefined | wc -w`
|
---|
81 |
|
---|
82 | if test $num_undef -ne 0; then
|
---|
83 | echoerr "$0: following symbols not defined in $symbols:"
|
---|
84 | echoerr "$undefined"
|
---|
85 | exit 1
|
---|
86 | fi
|
---|
87 | # Return code
|
---|
88 | exit 0
|
---|
89 |
|
---|