fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libjava / addr2name.awk
blobf31befd526dc94a5afd49b3ed83cebbd3a149cdc
1 #!/bin/awk -f
3 # Copyright (C) 2000 Free Software Foundation
5 # This file is part of libgcj.
7 # This software is copyrighted work licensed under the terms of the
8 # Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 # details.
11 # This script emulates a little of the functionality of addr2line for
12 # those systems that don't have it. The only command line argument is
13 # an executable name. The script reads hexadecimal addresses from
14 # stdin and prints the corresponding symbol names to stdout. The
15 # addresses must begin with "0x" and be fully zero filled or this
16 # won't work.
18 BEGIN {
19 object = ARGV[1];
20 ARGV[1] = "";
22 while ("nm " object "| sort" | getline) {
23 if ($2 == "t" || $2 == "T") {
24 address[i] = "0x" $1; name[i] = $3;
25 i++;
28 syms = i;
32 lo = 0;
33 hi = syms - 1;
35 while ((hi-1) > lo)
37 try = int ((hi + lo) / 2);
38 if ($0 < address[try])
39 hi = try;
40 else if ($0 >= address[try])
41 lo = try;
43 print name[lo] "\n"; fflush();