Prep 1.29
[dwarves.git] / fullcircle
blobe5e6a1b3e1900b4b038394ab9abf1f926cb7a210
1 #!/bin/bash
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.
8 if [ $# -eq 0 ] ; then
9 echo "Usage: fullcircle <filename_with_type_info>"
10 exit 1
13 file=$1
15 nr_cus=$(readelf -wi ${file} | grep DW_TAG_compile_unit | wc -l)
16 if [ $nr_cus -gt 1 ]; then
17 exit 0
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
43 exit 0