2 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright © 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
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.
9 echo "Usage: fullcircle <filename_with_type_info>"
15 nr_cus
=$
(readelf
-wi ${file} |
grep DW_TAG_compile_unit |
wc -l)
16 if [ $nr_cus -gt 1 ]; then
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"}
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:
29 # DW_AT_producer : (indirect string, offset: 0x3583): GNU C89 8.2.1 20181215 (Red Hat 8.2.1-6) -mno-sse -mno-mmx
31 # So we need from -mno-sse onwards
33 CFLAGS
=$
(readelf
-wi $file |
grep -w DW_AT_producer |
sed -r 's/.*\)( -[[:alnum:]]+.*)+/\1/g')
35 # Check if we managed to do the sed or if this is something like GNU AS
36 [ "${CFLAGS/DW_AT_producer/}" != "${CFLAGS}" ] && exit
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
42 rm -f $c_output $o_output