^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) # A script to dump mixed source code & assembly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # with correct relocations from System.map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # Requires the following lines in makefile:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #%.lst: %.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # $(CC) $(c_flags) -g -c -o $*.o $< &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # $(srctree)/scripts/makelst $*.o System.map $(OBJDUMP) > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # Copyright (C) 2000 IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # Author(s): DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # William Stearns <wstearns@pobox.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) # awk style field access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) field() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) shift $1 ; echo $1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) t1=`$3 --syms $1 | grep .text | grep -m1 " F "`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) if [ -n "$t1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) t2=`field 6 $t1`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if [ ! -r $2 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) echo "No System.map" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) t3=`grep $t2 $2`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) t4=`field 1 $t3`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) t5=`field 1 $t1`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) t6=`printf "%lu" $((0x$t4 - 0x$t5))`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) $3 -r --source --adjust-vma=${t6:-0} $1