xref: /openbmc/linux/scripts/makelst (revision f6112ec2)
1*f6112ec2SOleg Verych#!/bin/sh
21da177e4SLinus Torvalds# A script to dump mixed source code & assembly
31da177e4SLinus Torvalds# with correct relocations from System.map
4*f6112ec2SOleg Verych# Requires the following lines in makefile:
51da177e4SLinus Torvalds#%.lst: %.c
61da177e4SLinus Torvalds#	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $<
7*f6112ec2SOleg Verych#	$(srctree)/scripts/makelst $*.o $(objtree)/System.map $(OBJDUMP)
81da177e4SLinus Torvalds#
91da177e4SLinus Torvalds# Copyright (C) 2000 IBM Corporation
101da177e4SLinus Torvalds# Author(s): DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
11*f6112ec2SOleg Verych#            William Stearns <wstearns@pobox.com>
121da177e4SLinus Torvalds#
131da177e4SLinus Torvalds
14*f6112ec2SOleg Verych# awk style field access
15*f6112ec2SOleg Verychfield() {
16*f6112ec2SOleg Verych  shift $1 ; echo $1
17*f6112ec2SOleg Verych}
18*f6112ec2SOleg Verych
19*f6112ec2SOleg Verycht1=`$3 --syms $1 | grep .text | grep -m1 " F "`
201da177e4SLinus Torvaldsif [ -n "$t1" ]; then
21*f6112ec2SOleg Verych  t2=`field 6 $t1`
221da177e4SLinus Torvalds  if [ ! -r $2 ]; then
231da177e4SLinus Torvalds    echo "No System.map" >&2
241da177e4SLinus Torvalds  else
251da177e4SLinus Torvalds    t3=`grep $t2 $2`
26*f6112ec2SOleg Verych    t4=`field 1 $t3`
27*f6112ec2SOleg Verych    t5=`field 1 $t1`
28*f6112ec2SOleg Verych    t6=`printf "%lu" $((0x$t4 - 0x$t5))`
291da177e4SLinus Torvalds  fi
301da177e4SLinus Torvaldsfi
31*f6112ec2SOleg Verych$3 -r --source --adjust-vma=${t6:-0} $1
32