• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/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
16fetch_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
41ignore () {
42    sym=$1
43    symtab=`echo "$symtab" | grep -v " ${sym}\$"`
44}
45
46match () {
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#
60filter_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    # Ignore symbols generated by the ARM Linux default linker script.
74    # For details see the binutils sources (src/ld/emulparams/armelf_linux.sh).
75    if [ ${plat} = "arm" ]; then
76	ignore __bss_start__
77	ignore __bss_end__
78	ignore __end__
79	ignore _bss_end__
80    fi
81
82    if [ ${plat} = "mips" ]; then
83	ignore _fbss
84	ignore _fdata
85	ignore _ftext
86	ignore _gp
87    fi
88
89    if [ ${os} == "solaris2.11" ]; then
90        ignore _PROCEDURE_LINKAGE_TABLE_
91        ignore _etext
92    fi
93}
94
95check_local_unw_abi () {
96    match _UL${plat}_apply_reg_state
97    match _UL${plat}_reg_states_iterate
98    match _UL${plat}_create_addr_space
99    match _UL${plat}_destroy_addr_space
100    match _UL${plat}_get_fpreg
101    match _UL${plat}_get_proc_info
102    match _UL${plat}_get_proc_info_by_ip
103    match _UL${plat}_get_proc_name
104    match _UL${plat}_get_reg
105    match _UL${plat}_get_save_loc
106    match _UL${plat}_init_local
107    match _UL${plat}_init_local2
108    match _UL${plat}_init_remote
109    match _UL${plat}_is_signal_frame
110    match _UL${plat}_local_addr_space
111    match _UL${plat}_resume
112    match _UL${plat}_set_caching_policy
113    match _UL${plat}_set_cache_size
114    match _UL${plat}_set_reg
115    match _UL${plat}_set_fpreg
116    match _UL${plat}_step
117
118    match _U${plat}_flush_cache
119    match _U${plat}_get_accessors
120    match _U${plat}_get_elf_image
121    match _U${plat}_get_exe_image_path
122    match _U${plat}_regname
123    match _U${plat}_strerror
124
125    match _U_dyn_cancel
126    match _U_dyn_info_list_addr
127    match _U_dyn_register
128
129    match unw_backtrace
130    @CONFIG_WEAK_BACKTRACE_TRUE@match backtrace
131
132    case ${plat} in
133	arm)
134	    match _U${plat}_getcontext
135	    match _U${plat}_is_fpreg
136	    match _UL${plat}_search_unwind_table
137	    match _UL${plat}_dwarf_search_unwind_table
138	    match _UL${plat}_dwarf_find_unwind_table
139	    ;;
140	hppa)
141	    match _U${plat}_getcontext
142	    match _UL${plat}_dwarf_search_unwind_table
143	    match _UL${plat}_dwarf_find_unwind_table
144	    match _U${plat}_setcontext
145	    ;;
146	ia64)
147	    match _U${plat}_getcontext
148	    match _UL${plat}_search_unwind_table
149	    ;;
150	x86)
151	    match _U${plat}_getcontext
152	    match _U${plat}_is_fpreg
153	    match _UL${plat}_dwarf_search_unwind_table
154	    match _UL${plat}_dwarf_find_unwind_table
155	    ;;
156	x86_64)
157	    match _U${plat}_getcontext
158	    match _U${plat}_is_fpreg
159	    match _UL${plat}_dwarf_search_unwind_table
160	    match _UL${plat}_dwarf_find_unwind_table
161	    match _U${plat}_setcontext
162	    ;;
163	ppc*)
164	    match _U${plat}_getcontext
165	    match _U${plat}_get_func_addr
166	    match _U${plat}_is_fpreg
167	    match _UL${plat}_dwarf_search_unwind_table
168	    match _UL${plat}_dwarf_find_unwind_table
169	    ;;
170        tilegx)
171	    match _U${plat}_getcontext
172            match _U${plat}_is_fpreg
173	    match _UL${plat}_dwarf_search_unwind_table
174	    match _UL${plat}_dwarf_find_unwind_table
175            match _UL${plat}_local_addr_space_init
176            match ${plat}_lock
177            ;;
178	s390x)
179	    match _U${plat}_getcontext
180	    match _U${plat}_is_fpreg
181	    match _UL${plat}_dwarf_search_unwind_table
182	    match _UL${plat}_dwarf_find_unwind_table
183	    match _U${plat}_setcontext
184	    ;;
185	riscv)
186	    match _U${plat}_getcontext
187	    match _U${plat}_is_fpreg
188	    match _UL${plat}_dwarf_search_unwind_table
189	    match _UL${plat}_dwarf_find_unwind_table
190	    match _U${plat}_setcontext
191	    ;;
192
193	*)
194	    match _U${plat}_is_fpreg
195	    match _UL${plat}_dwarf_search_unwind_table
196	    match _UL${plat}_dwarf_find_unwind_table
197	    ;;
198    esac
199
200    if [ x@enable_debug_frame@ = xyes ]; then
201	match _UL${plat}_dwarf_find_debug_frame
202    fi
203
204}
205
206check_generic_unw_abi () {
207    match _U${plat}_apply_reg_state
208    match _U${plat}_reg_states_iterate
209    match _U${plat}_create_addr_space
210    match _U${plat}_destroy_addr_space
211    match _U${plat}_flush_cache
212    match _U${plat}_get_accessors
213    match _U${plat}_get_fpreg
214    match _U${plat}_get_proc_info
215    match _U${plat}_get_proc_info_by_ip
216    match _U${plat}_get_proc_name
217    match _U${plat}_get_reg
218    match _U${plat}_get_save_loc
219    match _U${plat}_init_local
220    match _U${plat}_init_local2
221    match _U${plat}_init_remote
222    match _U${plat}_is_signal_frame
223    match _U${plat}_local_addr_space
224    match _U${plat}_regname
225    match _U${plat}_resume
226    match _U${plat}_set_caching_policy
227    match _U${plat}_set_cache_size
228    match _U${plat}_set_fpreg
229    match _U${plat}_set_reg
230    match _U${plat}_step
231    match _U${plat}_strerror
232
233    case ${plat} in
234	arm)
235	    match _U${plat}_is_fpreg
236	    match _U${plat}_get_elf_image
237	    match _U${plat}_get_exe_image_path
238	    match _U${plat}_search_unwind_table
239	    match _U${plat}_dwarf_search_unwind_table
240	    match _U${plat}_dwarf_find_unwind_table
241	    ;;
242	hppa)
243	    match _U${plat}_dwarf_search_unwind_table
244	    match _U${plat}_dwarf_find_unwind_table
245	    match _U${plat}_get_elf_image
246	    match _U${plat}_get_exe_image_path
247	    ;;
248	ia64)
249	    match _U${plat}_search_unwind_table
250	    match _U${plat}_find_dyn_list
251	    if [ $plat = $build_plat ]; then
252		match _U${plat}_get_elf_image
253		match _U${plat}_get_exe_image_path
254		case $os in
255		    linux*)
256			match _U${plat}_get_kernel_table
257			;;
258		esac
259	    fi
260	    ;;
261	x86)
262	    match _U${plat}_get_elf_image
263	    match _U${plat}_get_exe_image_path
264	    match _U${plat}_is_fpreg
265	    match _U${plat}_dwarf_search_unwind_table
266	    match _U${plat}_dwarf_find_unwind_table
267	    ;;
268	x86_64)
269	    match _U${plat}_get_elf_image
270	    match _U${plat}_get_exe_image_path
271	    match _U${plat}_is_fpreg
272	    match _U${plat}_dwarf_search_unwind_table
273	    match _U${plat}_dwarf_find_unwind_table
274	    ;;
275	ppc*)
276	    match _U${plat}_get_elf_image
277	    match _U${plat}_get_exe_image_path
278	    match _U${plat}_get_func_addr
279	    match _U${plat}_is_fpreg
280	    match _U${plat}_dwarf_search_unwind_table
281	    match _U${plat}_dwarf_find_unwind_table
282	    ;;
283	tilegx)
284	    match _U${plat}_dwarf_search_unwind_table
285	    match _U${plat}_dwarf_find_unwind_table
286	    match _U${plat}_get_elf_image
287	    match _U${plat}_get_exe_image_path
288	    match _U${plat}_is_fpreg
289	    match _U${plat}_local_addr_space_init
290	    match ${plat}_lock
291	    ;;
292	s390x)
293	    match _U${plat}_is_fpreg
294	    match _U${plat}_get_elf_image
295	    match _U${plat}_get_exe_image_path
296	    match _U${plat}_dwarf_search_unwind_table
297	    match _U${plat}_dwarf_find_unwind_table
298	    ;;
299	riscv)
300	    match _U${plat}_get_elf_image
301	    match _U${plat}_get_exe_image_path
302	    match _U${plat}_is_fpreg
303	    match _U${plat}_dwarf_search_unwind_table
304	    match _U${plat}_dwarf_find_unwind_table
305	    ;;
306	*)
307	    match _U${plat}_is_fpreg
308	    match _U${plat}_dwarf_search_unwind_table
309	    match _U${plat}_dwarf_find_unwind_table
310	    match _U${plat}_get_elf_image
311	    match _U${plat}_get_exe_image_path
312	    ;;
313    esac
314
315    if [ x@enable_debug_frame@ = xyes ]; then
316	match _U${plat}_dwarf_find_debug_frame
317    fi
318}
319
320check_cxx_abi () {
321    match _Unwind_Backtrace
322    match _Unwind_DeleteException
323    match _Unwind_FindEnclosingFunction
324    match _Unwind_ForcedUnwind
325    match _Unwind_GetBSP
326    match _Unwind_GetCFA
327    match _Unwind_GetDataRelBase
328    match _Unwind_GetGR
329    match _Unwind_GetIP
330    match _Unwind_GetIPInfo
331    match _Unwind_GetLanguageSpecificData
332    match _Unwind_GetRegionStart
333    match _Unwind_GetTextRelBase
334    match _Unwind_RaiseException
335    match _Unwind_Resume
336    match _Unwind_Resume_or_Rethrow
337    match _Unwind_SetGR
338    match _Unwind_SetIP
339    match __libunwind_Unwind_Backtrace
340    match __libunwind_Unwind_DeleteException
341    match __libunwind_Unwind_FindEnclosingFunction
342    match __libunwind_Unwind_ForcedUnwind
343    match __libunwind_Unwind_GetBSP
344    match __libunwind_Unwind_GetCFA
345    match __libunwind_Unwind_GetDataRelBase
346    match __libunwind_Unwind_GetGR
347    match __libunwind_Unwind_GetIP
348    match __libunwind_Unwind_GetIPInfo
349    match __libunwind_Unwind_GetLanguageSpecificData
350    match __libunwind_Unwind_GetRegionStart
351    match __libunwind_Unwind_GetTextRelBase
352    match __libunwind_Unwind_RaiseException
353    match __libunwind_Unwind_Resume
354    match __libunwind_Unwind_Resume_or_Rethrow
355    match __libunwind_Unwind_SetGR
356    match __libunwind_Unwind_SetIP
357    case $os in
358	linux*)
359	    # needed only for Intel 8.0 bug-compatibility
360	    match _ReadSLEB
361	    match _ReadULEB
362	    ;;
363    esac
364}
365
366check_empty () {
367    if [ -n "$symtab" ]; then
368	printf "  ERROR: Extraneous symbols:\n$symtab\n"
369	num_errors=`expr $num_errors + 1`
370    fi
371}
372
373if [ $plat = $build_plat ]; then
374    fetch_symtab $LIBUNWIND
375    filter_misc
376    check_local_unw_abi
377    if [ x@enable_cxx_exceptions@ = xyes ]; then
378      check_cxx_abi
379    fi
380    check_empty
381fi
382
383fetch_symtab $LIBUNWIND_GENERIC
384filter_misc
385check_generic_unw_abi
386check_empty
387
388if [ $num_errors -gt 0 ]; then
389    echo "FAILURE: Detected $num_errors errors"
390    exit 1
391fi
392
393if $verbose; then
394    echo "  SUCCESS: all checks passed"
395fi
396exit 0
397