2.9
[glibc/nacl-glibc.git] / sysdeps / ia64 / fpu / import_check
blob21176f578deaa592078214c1bdcf9c615675087f
1 #!/bin/sh
3 objdir="$1"
5 num_errors=0
7 check_syms() {
8 global_count=0
9 entry_count=0
10 while read value type name; do
11 if [ $value = "U" ]; then
12 name=$type
13 # undefined symbols must start with double-underscore
14 if [ $(expr $name : '\(..\)') != "__" ]; then
15 echo -e "$(basename $file):\tError: undefined reference $name doesn't start with \"__\"."
16 num_errors=$(($num_errors + 1))
18 continue
21 case "$type" in
23 entry_count=$(($entry_count + 1))
26 entry_count=$(($entry_count + 1))
27 if [ "$(expr $name : '\(..\)')" != "__" ]; then
28 global_count=$(($global_count + 1))
31 esac
32 done
33 if [ $entry_count -gt 1 -a $global_count -gt 0 ]; then
34 echo -e "$(basename $file):\tError: detected $global_count strong " \
35 "global and $entry_count entry-points."
36 num_errors=$(($num_errors + 1))
40 check_file() {
41 file=$1
42 size=$(readelf -S $file | \
43 (sz=0; while read line; do
44 if echo $line | fgrep -q " .rodata"; then
45 read sz rest
46 break
48 done;
49 printf "%d" 0x$sz))
51 summands=$(readelf -s $file | fgrep " OBJECT " | tr -s ' ' |
52 cut -f4 -d' ' | sed 's,$,+,')0
53 sum=$(($summands))
54 if [ $sum != $size ]; then
55 echo -e "$(basename $file):\tError: sum of objects=$sum bytes, .rodata size=$size bytes"
56 num_errors=$(($num_errors + 1))
59 tmp=$(tempfile -p syms)
60 nm -g $file > $tmp
61 check_syms < $tmp
64 do_checks() {
65 echo "Note: 1 error expected in w_tgammal.o due to 64-byte alignment-padding."
66 while read func_pattern src_file dst_file; do
67 if [ "$(expr $dst_file : '.*\(S\)$')" = "S" ]; then
68 objfile=$(expr $dst_file : '\(.*\)[.]S$')
69 check_file $objdir/$objfile.o
71 done
74 do_checks < import_file_list
76 if [ $num_errors -gt 0 ]; then
77 echo "FAILURE: Detected $num_errors error(s)."
78 exit 1
80 echo SUCCESS
81 exit 0