blob: 9dd39f257e6aca992a7bc0daaa9d1b26385adc2e [file] [log] [blame]
mostang.com!davidm3640bb42004-05-05 01:58:44 +00001#!/bin/sh
2verbose=false
3if [ "$1" = "-v" ]; then
4 verbose=true
5 shift
6fi
7
8build_plat=@build_arch@
9plat=@arch@
10os=@target_os@
11num_errors=0
12
13LIBUNWIND=../src/.libs/libunwind.so
14LIBUNWIND_GENERIC=../src/.libs/libunwind-${plat}.so
15
16function fetch_symtab {
17 filename=$1
18
19 if [ ! -r $filename ]; then
20 return
21 fi
22
23 if $verbose; then
24 echo "Checking $filename..."
25 fi
26
27 #
28 # Unfortunately, "nm --defined" is a GNU-extension. For portability,
29 # build the list of defined symbols by hand.
30 #
31 symtab=`nm -g $filename`
32 saved_IFS="$IFS"
33 IFS=""
34 undef=`nm -g -u $filename`
35 for line in $undef; do
36 symtab=`echo "$symtab" | grep -v "^${line}"\$`
37 done;
38 IFS="$saved_IFS"
39}
40
41function ignore {
42 sym=$1
43 symtab=`echo "$symtab" | grep -v " ${sym}\$"`
44}
45
46function match {
47 sym=$1
48 if `echo "$symtab" | grep -q " ${sym}\$"`; then
49 symtab=`echo "$symtab" | grep -v " ${sym}\$"`
50 else
51 echo " ERROR: Symbol \"$sym\" missing."
52 num_errors=`expr $num_errors + 1`
53 fi
54}
55
56#
57# Filter out miscellaneous symbols that get defined by the
58# linker for each shared object.
59#
60function filter_misc {
61 ignore _DYNAMIC
62 ignore _GLOBAL_OFFSET_TABLE_
63 ignore __bss_start
64 ignore _edata
65 ignore _end
66 ignore _Uelf32_get_proc_name
67 ignore _Uelf32_valid_object
68 ignore _Uelf64_get_proc_name
69 ignore _Uelf64_valid_object
70 ignore _U.*debug_level
71 ignore ICRT.INTERNAL # ICC 8.x defines this
72}
73
74function check_local_unw_abi {
75 match _UL${plat}_create_addr_space
76 match _UL${plat}_destroy_addr_space
77 match _UL${plat}_get_fpreg
78 match _UL${plat}_get_proc_info
79 match _UL${plat}_get_proc_info_by_ip
80 match _UL${plat}_get_proc_name
81 match _UL${plat}_get_reg
82 match _UL${plat}_get_save_loc
83 match _UL${plat}_init_local
84 match _UL${plat}_init_remote
85 match _UL${plat}_is_signal_frame
86 match _UL${plat}_local_addr_space
87 match _UL${plat}_resume
88 match _UL${plat}_set_caching_policy
89 match _UL${plat}_set_reg
90 match _UL${plat}_set_fpreg
91 match _UL${plat}_step
92
93 match _U${plat}_flush_cache
94 match _U${plat}_get_accessors
95 match _U${plat}_getcontext
96 match _U${plat}_regname
97
98 match _U_dyn_cancel
99 match _U_dyn_info_list_addr
100 match _U_dyn_register
101
102 match backtrace
103
104 case ${plat} in
105 ia64)
106 match _UL${plat}_search_unwind_table
107 match _U${plat}_get_elf_image
108 ;;
109 *)
110 match _UL${plat}_is_fpreg
111 match _UL${plat}_dwarf_search_unwind_table
112 ;;
113 esac
114}
115
116function check_generic_unw_abi {
117 match _U${plat}_create_addr_space
118 match _U${plat}_destroy_addr_space
119 match _U${plat}_flush_cache
120 match _U${plat}_get_accessors
121 match _U${plat}_get_fpreg
122 match _U${plat}_get_proc_info
123 match _U${plat}_get_proc_info_by_ip
124 match _U${plat}_get_proc_name
125 match _U${plat}_get_reg
126 match _U${plat}_get_save_loc
127 match _U${plat}_init_local
128 match _U${plat}_init_remote
129 match _U${plat}_is_signal_frame
130 match _U${plat}_local_addr_space
131 match _U${plat}_regname
132 match _U${plat}_resume
133 match _U${plat}_set_caching_policy
134 match _U${plat}_set_fpreg
135 match _U${plat}_set_reg
136 match _U${plat}_step
137
138 case ${plat} in
139 ia64)
140 match _U${plat}_search_unwind_table
141 match _U${plat}_find_dyn_list
mostang.com!davidm3640bb42004-05-05 01:58:44 +0000142 match _U${plat}_get_elf_image
mostang.com!davidm74b22fe2004-05-05 05:03:20 +0000143 case $os in
144 linux*)
145 match _U${plat}_get_kernel_table
146 ;;
147 esac
mostang.com!davidm3640bb42004-05-05 01:58:44 +0000148 ;;
149 *)
150 match _U${plat}_is_fpreg
151 match _U${plat}_dwarf_search_unwind_table
152 ;;
153 esac
154}
155
156function check_cxx_abi {
157 match _Unwind_Backtrace
158 match _Unwind_DeleteException
159 match _Unwind_FindEnclosingFunction
160 match _Unwind_ForcedUnwind
161 match _Unwind_GetBSP
162 match _Unwind_GetCFA
163 match _Unwind_GetDataRelBase
164 match _Unwind_GetGR
165 match _Unwind_GetIP
166 match _Unwind_GetLanguageSpecificData
167 match _Unwind_GetRegionStart
168 match _Unwind_GetTextRelBase
169 match _Unwind_RaiseException
170 match _Unwind_Resume
171 match _Unwind_Resume_or_Rethrow
172 match _Unwind_SetGR
173 match _Unwind_SetIP
174 case $os in
175 linux*)
176 # needed only for Intel 8.0 bug-compatibility
177 match _ReadSLEB
178 match _ReadULEB
179 ;;
180 esac
181}
182
183function check_empty {
184 if [ -n "$symtab" ]; then
185 echo -e " ERROR: Extraneous symbols:\n$symtab"
186 num_errors=`expr $num_errors + 1`
187 fi
188}
189
190if [ $plat = $build_plat ]; then
191 fetch_symtab $LIBUNWIND
192 filter_misc
193 check_local_unw_abi
194 check_cxx_abi
195 check_empty
196fi
197
198fetch_symtab $LIBUNWIND_GENERIC
199filter_misc
200check_generic_unw_abi
201check_empty
202
203if [ $num_errors -gt 0 ]; then
204 echo "FAILURE: Detected $num_errors errors"
205 exit -1
206fi
207
208if $verbose; then
209 echo " SUCCESS: all checks passed"
210fi
211exit 0