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