xref: /openbmc/linux/scripts/makelst (revision f77bf014)
1f6112ec2SOleg Verych#!/bin/sh
21da177e4SLinus Torvalds# A script to dump mixed source code & assembly
31da177e4SLinus Torvalds# with correct relocations from System.map
4f6112ec2SOleg Verych# Requires the following lines in makefile:
51da177e4SLinus Torvalds#%.lst: %.c
6*f77bf014SSam Ravnborg#	$(CC) $(c_flags) -g -c -o $*.o $< &&
7*f77bf014SSam Ravnborg#	$(srctree)/scripts/makelst $*.o 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)
11f6112ec2SOleg Verych#            William Stearns <wstearns@pobox.com>
121da177e4SLinus Torvalds#
131da177e4SLinus Torvalds
14f6112ec2SOleg Verych# awk style field access
15f6112ec2SOleg Verychfield() {
16f6112ec2SOleg Verych  shift $1 ; echo $1
17f6112ec2SOleg Verych}
18f6112ec2SOleg Verych
19f6112ec2SOleg Verycht1=`$3 --syms $1 | grep .text | grep -m1 " F "`
201da177e4SLinus Torvaldsif [ -n "$t1" ]; then
21f6112ec2SOleg 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`
26f6112ec2SOleg Verych    t4=`field 1 $t3`
27f6112ec2SOleg Verych    t5=`field 1 $t1`
28f6112ec2SOleg Verych    t6=`printf "%lu" $((0x$t4 - 0x$t5))`
291da177e4SLinus Torvalds  fi
301da177e4SLinus Torvaldsfi
31f6112ec2SOleg Verych$3 -r --source --adjust-vma=${t6:-0} $1
32