xref: /kernel/linux/linux-6.6/scripts/makelst (revision 62306a36)
162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
362306a36Sopenharmony_ci# A script to dump mixed source code & assembly
462306a36Sopenharmony_ci# with correct relocations from System.map
562306a36Sopenharmony_ci# Requires the following lines in makefile:
662306a36Sopenharmony_ci#%.lst: %.c
762306a36Sopenharmony_ci#	$(CC) $(c_flags) -g -c -o $*.o $< &&
862306a36Sopenharmony_ci#	$(srctree)/scripts/makelst $*.o System.map $(OBJDUMP) > $@
962306a36Sopenharmony_ci#
1062306a36Sopenharmony_ci# Copyright (C) 2000 IBM Corporation
1162306a36Sopenharmony_ci# Author(s): DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
1262306a36Sopenharmony_ci#            William Stearns <wstearns@pobox.com>
1362306a36Sopenharmony_ci#
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci# awk style field access
1662306a36Sopenharmony_cifield() {
1762306a36Sopenharmony_ci  shift $1 ; echo $1
1862306a36Sopenharmony_ci}
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_cit1=`$3 --syms $1 | grep .text | grep -m1 " F "`
2162306a36Sopenharmony_ciif [ -n "$t1" ]; then
2262306a36Sopenharmony_ci  t2=`field 6 $t1`
2362306a36Sopenharmony_ci  if [ ! -r $2 ]; then
2462306a36Sopenharmony_ci    echo "No System.map" >&2
2562306a36Sopenharmony_ci  else
2662306a36Sopenharmony_ci    t3=`grep $t2 $2`
2762306a36Sopenharmony_ci    t4=`field 1 $t3`
2862306a36Sopenharmony_ci    t5=`field 1 $t1`
2962306a36Sopenharmony_ci    t6=`printf "%lu" $((0x$t4 - 0x$t5))`
3062306a36Sopenharmony_ci  fi
3162306a36Sopenharmony_cifi
3262306a36Sopenharmony_ci$3 -r --source --adjust-vma=${t6:-0} $1
33