Debian Codegraph @

fullcircle

raw
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright © 2019 Red Hat Inc, Arnaldo Carvalho de Melo <[email protected]>
4 # Use pfunct to produce compilable output from a object, then do a codiff -s
5 # To see if the type information generated from source code generated
6 # from type information in a file compiled from the original source code matches.
7
8 if [ $# -eq 0 ] ; then
9 echo "Usage: fullcircle <filename_with_type_info>"
10 exit 1
11 fi
12
13 file=$1
14
15 nr_cus=$(readelf -wi ${file} | grep DW_TAG_compile_unit | wc -l)
16 if [ $nr_cus -gt 1 ]; then
17 exit 0
18 fi
19
20 c_output=$(mktemp /tmp/fullcircle.XXXXXX.c)
21 o_output=$(mktemp /tmp/fullcircle.XXXXXX.o)
22 pfunct_bin=${PFUNCT-"pfunct"}
23 codiff_bin=${CODIFF-"codiff"}
24
25 # See how your DW_AT_producer looks like and find the
26 # right regexp to get after the GCC version string, this one
27 # seems good enough for Red Hat/Fedora/CentOS that look like:
28 #
29 # DW_AT_producer : (indirect string, offset: 0x3583): GNU C89 8.2.1 20181215 (Red Hat 8.2.1-6) -mno-sse -mno-mmx
30 #
31 # So we need from -mno-sse onwards
32
33 CFLAGS=$(readelf -wi $file | grep -w DW_AT_producer | sed -r 's/.*\)( -[[:alnum:]]+.*)+/\1/g')
34
35 # Check if we managed to do the sed or if this is something like GNU AS
36 [ "${CFLAGS/DW_AT_producer/}" != "${CFLAGS}" ] && exit
37
38 ${pfunct_bin} --compile $file > $c_output
39 gcc $CFLAGS -c -g $c_output -o $o_output
40 ${codiff_bin} -q -s $file $o_output
41
42 rm -f $c_output $o_output
43 exit 0