Commit 4a2fa6ce authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Fix 'make some/dir/foo.lst'

Just use 'make some/dir/foo.lst' to produce mixed source code and
assembly for debugging. (If the object gets linked in and you have
a System.map, it'll relocate appropriately)

Apart from the needed Makefile bits, also clean up the script
"makelst".
parent 00b454db
...@@ -255,6 +255,8 @@ prepare: .hdepend include/config/MARKER ...@@ -255,6 +255,8 @@ prepare: .hdepend include/config/MARKER
@$(MAKE) -C $(@D) $(@F) @$(MAKE) -C $(@D) $(@F)
%.o: %.c FORCE %.o: %.c FORCE
@$(MAKE) -C $(@D) $(@F) @$(MAKE) -C $(@D) $(@F)
%.lst: %.c FORCE
@$(MAKE) -C $(@D) $(@F)
%.s: %.S FORCE %.s: %.S FORCE
@$(MAKE) -C $(@D) $(@F) @$(MAKE) -C $(@D) $(@F)
%.o: %.S FORCE %.o: %.S FORCE
......
...@@ -100,17 +100,19 @@ first_rule: vmlinux $(if $(BUILD_MODULES),$(obj-m)) ...@@ -100,17 +100,19 @@ first_rule: vmlinux $(if $(BUILD_MODULES),$(obj-m))
# Only happens in Makefiles which override the default first_rule: # Only happens in Makefiles which override the default first_rule:
modkern_cflags := $(CFLAGS_KERNEL) modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-y) : modkern_cflags := $(CFLAGS_KERNEL) $(real-objs-y) : modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-y:.o=.i): modkern_cflags := $(CFLAGS_KERNEL) $(real-objs-y:.o=.i) : modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-y:.o=.s): modkern_cflags := $(CFLAGS_KERNEL) $(real-objs-y:.o=.s) : modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-y:.o=.lst): modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE) $(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE)
$(real-objs-m:.o=.i): modkern_cflags := $(CFLAGS_MODULE) $(real-objs-m:.o=.i) : modkern_cflags := $(CFLAGS_MODULE)
$(real-objs-m:.o=.s): modkern_cflags := $(CFLAGS_MODULE) $(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE)
$(export-objs) : export_flags := $(EXPORT_FLAGS) $(export-objs) : export_flags := $(EXPORT_FLAGS)
$(export-objs:.o=.i): export_flags := $(EXPORT_FLAGS) $(export-objs:.o=.i) : export_flags := $(EXPORT_FLAGS)
$(export-objs:.o=.s): export_flags := $(EXPORT_FLAGS) $(export-objs:.o=.s) : export_flags := $(EXPORT_FLAGS)
$(export-objs:.o=.lst): export_flags := $(EXPORT_FLAGS)
c_flags = $(CFLAGS) $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(export_flags) c_flags = $(CFLAGS) $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(export_flags)
...@@ -132,6 +134,12 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< ...@@ -132,6 +134,12 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
%.o: %.c FORCE %.o: %.c FORCE
$(call if_changed,cmd_cc_o_c) $(call if_changed,cmd_cc_o_c)
quiet_cmd_cc_lst_c = Generating $(RELDIR)/$@
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && $(TOPDIR)/scripts/makelst $*.o $(TOPDIR)/System.map $(OBJDUMP) > $@
%.lst: %.c FORCE
$(call if_changed,cmd_cc_lst_c)
# Compile assembler sources (.S) # Compile assembler sources (.S)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -158,13 +166,6 @@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< ...@@ -158,13 +166,6 @@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
%.o: %.S FORCE %.o: %.S FORCE
$(call if_changed,cmd_as_o_S) $(call if_changed,cmd_as_o_S)
# FIXME
%.lst: %.c
$(CC) $(c_flags) -g -c -o $*.o $<
$(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP)
# If a Makefile does define neither O_TARGET nor L_TARGET, # If a Makefile does define neither O_TARGET nor L_TARGET,
# use a standard O_TARGET named "built-in.o" # use a standard O_TARGET named "built-in.o"
......
...@@ -6,17 +6,26 @@ ...@@ -6,17 +6,26 @@
# William Stearns <wstearns@pobox.com> # William Stearns <wstearns@pobox.com>
#%.lst: %.c #%.lst: %.c
# $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $< # $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $<
# $(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP) # $(TOPDIR)/scripts/makelst $*.o $(TOPDIR)/System.map $(OBJDUMP)
# #
# Copyright (C) 2000 IBM Corporation # Copyright (C) 2000 IBM Corporation
# Author(s): DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) # Author(s): DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
# #
t1=`$3 --syms $2/$1.o | grep .text | grep " F " | head -n 1` t1=`$3 --syms $1 | grep .text | grep " F " | head -n 1`
t2=`echo $t1 | gawk '{ print $6 }'` if [ -n "$t1" ]; then
t3=`grep $t2 $2/System.map` t2=`echo $t1 | gawk '{ print $6 }'`
t4=`echo $t3 | gawk '{ print $1 }'` if [ ! -r $2 ]; then
t5=`echo $t1 | gawk '{ print $1 }'` echo "No System.map" >&2
t6=`echo $t4 - $t5 | sed -e s/a/A/g -e s/b/B/g -e s/c/C/g -e s/d/D/g -e s/e/E/g -e s/f/F/g` t7=0
t7=`( echo ibase=16 ; echo $t6 ) | bc` else
$3 --source --adjust-vma=$t7 $2/$1.o > $2/$1.lst t3=`grep $t2 $2`
t4=`echo $t3 | gawk '{ print $1 }'`
t5=`echo $t1 | gawk '{ print $1 }'`
t6=`echo $t4 - $t5 | tr a-f A-F`
t7=`( echo ibase=16 ; echo $t6 ) | bc`
fi
else
t7=0
fi
$3 --source --adjust-vma=$t7 $1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment