18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
38c2ecf20Sopenharmony_ci# A script to dump mixed source code & assembly
48c2ecf20Sopenharmony_ci# with correct relocations from System.map
58c2ecf20Sopenharmony_ci# Requires the following lines in makefile:
68c2ecf20Sopenharmony_ci#%.lst: %.c
78c2ecf20Sopenharmony_ci#	$(CC) $(c_flags) -g -c -o $*.o $< &&
88c2ecf20Sopenharmony_ci#	$(srctree)/scripts/makelst $*.o System.map $(OBJDUMP) > $@
98c2ecf20Sopenharmony_ci#
108c2ecf20Sopenharmony_ci# Copyright (C) 2000 IBM Corporation
118c2ecf20Sopenharmony_ci# Author(s): DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
128c2ecf20Sopenharmony_ci#            William Stearns <wstearns@pobox.com>
138c2ecf20Sopenharmony_ci#
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci# awk style field access
168c2ecf20Sopenharmony_cifield() {
178c2ecf20Sopenharmony_ci  shift $1 ; echo $1
188c2ecf20Sopenharmony_ci}
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cit1=`$3 --syms $1 | grep .text | grep -m1 " F "`
218c2ecf20Sopenharmony_ciif [ -n "$t1" ]; then
228c2ecf20Sopenharmony_ci  t2=`field 6 $t1`
238c2ecf20Sopenharmony_ci  if [ ! -r $2 ]; then
248c2ecf20Sopenharmony_ci    echo "No System.map" >&2
258c2ecf20Sopenharmony_ci  else
268c2ecf20Sopenharmony_ci    t3=`grep $t2 $2`
278c2ecf20Sopenharmony_ci    t4=`field 1 $t3`
288c2ecf20Sopenharmony_ci    t5=`field 1 $t1`
298c2ecf20Sopenharmony_ci    t6=`printf "%lu" $((0x$t4 - 0x$t5))`
308c2ecf20Sopenharmony_ci  fi
318c2ecf20Sopenharmony_cifi
328c2ecf20Sopenharmony_ci$3 -r --source --adjust-vma=${t6:-0} $1
33