• 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}_getcontext
121    match _U${plat}_regname
122    match _U${plat}_strerror
123
124    match _U_dyn_cancel
125    match _U_dyn_info_list_addr
126    match _U_dyn_register
127
128    match unw_backtrace
129    @CONFIG_WEAK_BACKTRACE_TRUE@match backtrace
130
131    case ${plat} in
132	arm)
133	    match _U${plat}_get_elf_image
134	    match _U${plat}_get_exe_image_path
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 _UL${plat}_dwarf_search_unwind_table
142	    match _UL${plat}_dwarf_find_unwind_table
143	    match _U${plat}_get_elf_image
144	    match _U${plat}_get_exe_image_path
145	    match _U${plat}_setcontext
146	    ;;
147	ia64)
148	    match _UL${plat}_search_unwind_table
149	    match _U${plat}_get_elf_image
150	    match _U${plat}_get_exe_image_path
151	    ;;
152	x86)
153	    match _U${plat}_get_elf_image
154	    match _U${plat}_get_exe_image_path
155	    match _U${plat}_is_fpreg
156	    match _UL${plat}_dwarf_search_unwind_table
157	    match _UL${plat}_dwarf_find_unwind_table
158	    ;;
159	x86_64)
160	    match _U${plat}_get_elf_image
161	    match _U${plat}_get_exe_image_path
162	    match _U${plat}_is_fpreg
163	    match _UL${plat}_dwarf_search_unwind_table
164	    match _UL${plat}_dwarf_find_unwind_table
165	    match _U${plat}_setcontext
166	    ;;
167	ppc*)
168	    match _U${plat}_get_func_addr
169	    match _U${plat}_get_elf_image
170	    match _U${plat}_get_exe_image_path
171	    match _U${plat}_is_fpreg
172	    match _UL${plat}_dwarf_search_unwind_table
173	    match _UL${plat}_dwarf_find_unwind_table
174	    ;;
175        tilegx)
176            match _U${plat}_is_fpreg
177	    match _UL${plat}_dwarf_search_unwind_table
178	    match _UL${plat}_dwarf_find_unwind_table
179            match _UL${plat}_local_addr_space_init
180            match _U${plat}_get_elf_image
181	    match _U${plat}_get_exe_image_path
182            match ${plat}_lock
183            ;;
184	s390x)
185	    match _U${plat}_get_elf_image
186	    match _U${plat}_get_exe_image_path
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	riscv)
193	    match _U${plat}_get_elf_image
194	    match _U${plat}_get_exe_image_path
195	    match _U${plat}_is_fpreg
196	    match _UL${plat}_dwarf_search_unwind_table
197	    match _UL${plat}_dwarf_find_unwind_table
198	    match _U${plat}_setcontext
199	    ;;
200
201	*)
202	    match _U${plat}_is_fpreg
203	    match _UL${plat}_dwarf_search_unwind_table
204	    match _UL${plat}_dwarf_find_unwind_table
205	    ;;
206    esac
207
208    if [ x@enable_debug_frame@ = xyes ]; then
209	match _UL${plat}_dwarf_find_debug_frame
210    fi
211
212}
213
214check_generic_unw_abi () {
215    match _U${plat}_apply_reg_state
216    match _U${plat}_reg_states_iterate
217    match _U${plat}_create_addr_space
218    match _U${plat}_destroy_addr_space
219    match _U${plat}_flush_cache
220    match _U${plat}_get_accessors
221    match _U${plat}_get_fpreg
222    match _U${plat}_get_proc_info
223    match _U${plat}_get_proc_info_by_ip
224    match _U${plat}_get_proc_name
225    match _U${plat}_get_reg
226    match _U${plat}_get_save_loc
227    match _U${plat}_init_local
228    match _U${plat}_init_local2
229    match _U${plat}_init_remote
230    match _U${plat}_is_signal_frame
231    match _U${plat}_local_addr_space
232    match _U${plat}_regname
233    match _U${plat}_resume
234    match _U${plat}_set_caching_policy
235    match _U${plat}_set_cache_size
236    match _U${plat}_set_fpreg
237    match _U${plat}_set_reg
238    match _U${plat}_step
239    match _U${plat}_strerror
240
241    case ${plat} in
242	arm)
243	    match _U${plat}_is_fpreg
244	    match _U${plat}_get_elf_image
245	    match _U${plat}_get_exe_image_path
246	    match _U${plat}_search_unwind_table
247	    match _U${plat}_dwarf_search_unwind_table
248	    match _U${plat}_dwarf_find_unwind_table
249	    ;;
250	hppa)
251	    match _U${plat}_dwarf_search_unwind_table
252	    match _U${plat}_dwarf_find_unwind_table
253	    match _U${plat}_get_elf_image
254	    match _U${plat}_get_exe_image_path
255	    ;;
256	ia64)
257	    match _U${plat}_search_unwind_table
258	    match _U${plat}_find_dyn_list
259	    if [ $plat = $build_plat ]; then
260		match _U${plat}_get_elf_image
261		match _U${plat}_get_exe_image_path
262		case $os in
263		    linux*)
264			match _U${plat}_get_kernel_table
265			;;
266		esac
267	    fi
268	    ;;
269	x86)
270	    match _U${plat}_get_elf_image
271	    match _U${plat}_get_exe_image_path
272	    match _U${plat}_is_fpreg
273	    match _U${plat}_dwarf_search_unwind_table
274	    match _U${plat}_dwarf_find_unwind_table
275	    ;;
276	x86_64)
277	    match _U${plat}_get_elf_image
278	    match _U${plat}_get_exe_image_path
279	    match _U${plat}_is_fpreg
280	    match _U${plat}_dwarf_search_unwind_table
281	    match _U${plat}_dwarf_find_unwind_table
282	    ;;
283	ppc*)
284	    match _U${plat}_get_elf_image
285	    match _U${plat}_get_exe_image_path
286	    match _U${plat}_get_func_addr
287	    match _U${plat}_is_fpreg
288	    match _U${plat}_dwarf_search_unwind_table
289	    match _U${plat}_dwarf_find_unwind_table
290	    ;;
291        tilegx)
292            match _U${plat}_dwarf_search_unwind_table
293	    match _U${plat}_dwarf_find_unwind_table
294            match _U${plat}_get_elf_image
295	    match _U${plat}_get_exe_image_path
296            match _U${plat}_is_fpreg
297            match _U${plat}_local_addr_space_init
298            match ${plat}_lock
299            ;;
300	s390x)
301	    match _U${plat}_is_fpreg
302	    match _U${plat}_get_elf_image
303	    match _U${plat}_get_exe_image_path
304	    match _U${plat}_dwarf_search_unwind_table
305	    match _U${plat}_dwarf_find_unwind_table
306	    ;;
307	riscv)
308	    match _U${plat}_get_elf_image
309	    match _U${plat}_get_exe_image_path
310	    match _U${plat}_is_fpreg
311	    match _U${plat}_dwarf_search_unwind_table
312	    match _U${plat}_dwarf_find_unwind_table
313	    ;;
314	*)
315	    match _U${plat}_is_fpreg
316	    match _U${plat}_dwarf_search_unwind_table
317	    match _U${plat}_dwarf_find_unwind_table
318	    ;;
319    esac
320
321    if [ x@enable_debug_frame@ = xyes ]; then
322	match _U${plat}_dwarf_find_debug_frame
323    fi
324}
325
326check_cxx_abi () {
327    match _Unwind_Backtrace
328    match _Unwind_DeleteException
329    match _Unwind_FindEnclosingFunction
330    match _Unwind_ForcedUnwind
331    match _Unwind_GetBSP
332    match _Unwind_GetCFA
333    match _Unwind_GetDataRelBase
334    match _Unwind_GetGR
335    match _Unwind_GetIP
336    match _Unwind_GetIPInfo
337    match _Unwind_GetLanguageSpecificData
338    match _Unwind_GetRegionStart
339    match _Unwind_GetTextRelBase
340    match _Unwind_RaiseException
341    match _Unwind_Resume
342    match _Unwind_Resume_or_Rethrow
343    match _Unwind_SetGR
344    match _Unwind_SetIP
345    match __libunwind_Unwind_Backtrace
346    match __libunwind_Unwind_DeleteException
347    match __libunwind_Unwind_FindEnclosingFunction
348    match __libunwind_Unwind_ForcedUnwind
349    match __libunwind_Unwind_GetBSP
350    match __libunwind_Unwind_GetCFA
351    match __libunwind_Unwind_GetDataRelBase
352    match __libunwind_Unwind_GetGR
353    match __libunwind_Unwind_GetIP
354    match __libunwind_Unwind_GetIPInfo
355    match __libunwind_Unwind_GetLanguageSpecificData
356    match __libunwind_Unwind_GetRegionStart
357    match __libunwind_Unwind_GetTextRelBase
358    match __libunwind_Unwind_RaiseException
359    match __libunwind_Unwind_Resume
360    match __libunwind_Unwind_Resume_or_Rethrow
361    match __libunwind_Unwind_SetGR
362    match __libunwind_Unwind_SetIP
363    case $os in
364	linux*)
365	    # needed only for Intel 8.0 bug-compatibility
366	    match _ReadSLEB
367	    match _ReadULEB
368	    ;;
369    esac
370}
371
372check_empty () {
373    if [ -n "$symtab" ]; then
374	printf "  ERROR: Extraneous symbols:\n$symtab\n"
375	num_errors=`expr $num_errors + 1`
376    fi
377}
378
379if [ $plat = $build_plat ]; then
380    fetch_symtab $LIBUNWIND
381    filter_misc
382    check_local_unw_abi
383    if [ x@enable_cxx_exceptions@ = xyes ]; then
384      check_cxx_abi
385    fi
386    check_empty
387fi
388
389fetch_symtab $LIBUNWIND_GENERIC
390filter_misc
391check_generic_unw_abi
392check_empty
393
394if [ $num_errors -gt 0 ]; then
395    echo "FAILURE: Detected $num_errors errors"
396    exit 1
397fi
398
399if $verbose; then
400    echo "  SUCCESS: all checks passed"
401fi
402exit 0
403