1f6112ec2SOleg Verych#!/bin/sh 2b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 31da177e4SLinus Torvalds# A script to dump mixed source code & assembly 41da177e4SLinus Torvalds# with correct relocations from System.map 5f6112ec2SOleg Verych# Requires the following lines in makefile: 61da177e4SLinus Torvalds#%.lst: %.c 7f77bf014SSam Ravnborg# $(CC) $(c_flags) -g -c -o $*.o $< && 8f77bf014SSam Ravnborg# $(srctree)/scripts/makelst $*.o System.map $(OBJDUMP) > $@ 91da177e4SLinus Torvalds# 101da177e4SLinus Torvalds# Copyright (C) 2000 IBM Corporation 111da177e4SLinus Torvalds# Author(s): DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 12f6112ec2SOleg Verych# William Stearns <wstearns@pobox.com> 131da177e4SLinus Torvalds# 141da177e4SLinus Torvalds 15f6112ec2SOleg Verych# awk style field access 16f6112ec2SOleg Verychfield() { 17f6112ec2SOleg Verych shift $1 ; echo $1 18f6112ec2SOleg Verych} 19f6112ec2SOleg Verych 20f6112ec2SOleg Verycht1=`$3 --syms $1 | grep .text | grep -m1 " F "` 211da177e4SLinus Torvaldsif [ -n "$t1" ]; then 22f6112ec2SOleg Verych t2=`field 6 $t1` 231da177e4SLinus Torvalds if [ ! -r $2 ]; then 241da177e4SLinus Torvalds echo "No System.map" >&2 251da177e4SLinus Torvalds else 261da177e4SLinus Torvalds t3=`grep $t2 $2` 27f6112ec2SOleg Verych t4=`field 1 $t3` 28f6112ec2SOleg Verych t5=`field 1 $t1` 29f6112ec2SOleg Verych t6=`printf "%lu" $((0x$t4 - 0x$t5))` 301da177e4SLinus Torvalds fi 311da177e4SLinus Torvaldsfi 32f6112ec2SOleg Verych$3 -r --source --adjust-vma=${t6:-0} $1 33