VirtualBox

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

Last change on this file since 44355 was 43257, checked in by vboxsync, 12 years ago

4.2.0 RC4

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