1 | #!/bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Copyright (C) 2006-2010 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 text file.
|
---|
18 | #
|
---|
19 | # Usage: /bin/sh <script name> <object> <allowed undefined symbols> [--static]
|
---|
20 | #
|
---|
21 | # Currently only works for native objects on Linux platforms
|
---|
22 | #
|
---|
23 |
|
---|
24 | echoerr()
|
---|
25 | {
|
---|
26 | echo $* 1>&2
|
---|
27 | }
|
---|
28 |
|
---|
29 | hostos=$1
|
---|
30 | target=$2
|
---|
31 | symbols=$3
|
---|
32 | static=$4
|
---|
33 |
|
---|
34 | if test $# -lt 3 || test $# -gt 4 || test ! -r "$target" || test ! -r "$symbols"; then
|
---|
35 | if test ! -r "$target"; then
|
---|
36 | echoerr "$0: '$target' not readable"
|
---|
37 | elif test ! -r "$symbols"; then
|
---|
38 | echoerr "$0: '$symbols' not readable"
|
---|
39 | else
|
---|
40 | echoerr "$0: Wrong number of arguments"
|
---|
41 | fi
|
---|
42 | args_ok="no"
|
---|
43 | fi
|
---|
44 |
|
---|
45 | if test $# -eq 4 && test "$static" != "--static"; then
|
---|
46 | args_ok="no"
|
---|
47 | fi
|
---|
48 |
|
---|
49 | if test "$args_ok" = "no"; then
|
---|
50 | echoerr "Usage: $0 <object> <allowed undefined symbols> [--static]"
|
---|
51 | exit 1
|
---|
52 | fi
|
---|
53 |
|
---|
54 | if test "$hostos" = "solaris"; then
|
---|
55 | objdumpbin=/usr/sfw/bin/gobjdump
|
---|
56 | grepbin=/usr/sfw/bin/ggrep
|
---|
57 | elif test "$hostos" = "linux"; then
|
---|
58 | objdumpbin=`which objdump`
|
---|
59 | grepbin=`which grep`
|
---|
60 | else
|
---|
61 | echoerr "$0: '$hostos' not a valid hostos string. supported 'linux' 'solaris'"
|
---|
62 | exit 1
|
---|
63 | fi
|
---|
64 |
|
---|
65 | command="-T"
|
---|
66 | if test "$static" = "--static"; then
|
---|
67 | command="-t"
|
---|
68 | fi
|
---|
69 |
|
---|
70 | if test ! -x "$objdumpbin"; then
|
---|
71 | echoerr "$0: '$objdumpbin' not found or not executable."
|
---|
72 | exit 1
|
---|
73 | fi
|
---|
74 |
|
---|
75 | undefined=`$objdumpbin $command $target | $grepbin '*UND*' | $grepbin -v -f $symbols | kmk_sed -e 's/^.*[[:blank:]]\(.*\)/\1/'`
|
---|
76 | num_undef=`echo $undefined | wc -w`
|
---|
77 |
|
---|
78 | if test $num_undef -ne 0; then
|
---|
79 | echoerr "$0: following symbols not defined in $symbols:"
|
---|
80 | echoerr "$undefined"
|
---|
81 | exit 1
|
---|
82 | fi
|
---|
83 | # Return code
|
---|
84 | exit 0
|
---|
85 |
|
---|