aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-06-08 17:13:51 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-06-08 17:13:51 -0700
commit9e3d217ee3869e4f4ddb1466621c079e14754660 (patch)
tree638575ae4165ab469bbe765c72868db9cc33de34
parent601eab3b8c947b2725e9376954bcd5ebfc954d0a (diff)
downloadsyslinux-elf-syslinux-3.50.tar.gz
syslinux-elf-syslinux-3.50.tar.xz
syslinux-elf-syslinux-3.50.zip
Show list file addresses in absolutesyslinux-3.50
Small Perl script to postprocess the listfile and show absolute addresses instead of section-relative. This only applies to the main address, not to addresses in bracketed fields.
-rw-r--r--Makefile37
-rwxr-xr-xlstadjust.pl61
-rw-r--r--memdisk/Makefile4
-rw-r--r--sample/Makefile2
4 files changed, 72 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index 24450357..4a53774f 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ LDFLAGS = -O2 -s $(LDHASH)
AR = ar
RANLIB = ranlib
-NASM = nasm -O99
+NASM = nasm
NINCLUDE =
BINDIR = /usr/bin
SBINDIR = /sbin
@@ -137,32 +137,11 @@ version.h: version version.pl
kwdhash.gen: keywords genhash.pl
$(PERL) genhash.pl < keywords > kwdhash.gen
-ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
- $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
- -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
- $(PERL) checkov.pl ldlinux.map $@
-
-pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
- $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
- -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
- $(PERL) checkov.pl $(@:.bin=.map) $@
-
-isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
- $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
- -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
- $(PERL) checkov.pl $(@:.bin=.map) $@
- $(PERL) checksumiso.pl $@
-
-# Special verbose version of isolinux.bin
-isolinux-debug.bin: isolinux-debug.asm kwdhash.gen version.gen checksumiso.pl
- $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
- -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
- $(PERL) checkov.pl $(@:.bin=.map) $@
- $(PERL) checksumiso.pl $@
-
-extlinux.bin: extlinux.asm kwdhash.gen version.gen
- $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
- -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
+# Standard rule for {ldlinux,pxelinux,isolinux,isolinux-debug,extlinux}.bin
+%.bin: %.asm kwdhash.gen version.gen
+ $(NASM) -O99 -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
+ -DMAP=$(@:.bin=.map) -l $(@:.bin=.lsr) -o $@ $<
+ $(PERL) lstadjust.pl $(@:.bin=.lsr) $(@:.bin=.map) $(@:.bin=.lst)
$(PERL) checkov.pl $(@:.bin=.map) $@
pxelinux.0: pxelinux.bin
@@ -184,7 +163,7 @@ mbr_bin.c: mbr/mbr.bin bin2c.pl
$(PERL) bin2c.pl syslinux_mbr < $< > $@
copybs.com: copybs.asm
- $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
+ $(NASM) -O99 -f bin -l copybs.lst -o copybs.com copybs.asm
bootsect_bin.c: ldlinux.bss bin2c.pl
$(PERL) bin2c.pl syslinux_bootsect < $< > $@
@@ -229,7 +208,7 @@ install-all: install install-lib
local-tidy:
rm -f *.o *_bin.c stupid.* patch.offset
- rm -f *.lst *.map
+ rm -f *.lsr *.lst *.map
rm -f $(OBSOLETE)
tidy: local-tidy
diff --git a/lstadjust.pl b/lstadjust.pl
new file mode 100755
index 00000000..84b6e8b1
--- /dev/null
+++ b/lstadjust.pl
@@ -0,0 +1,61 @@
+#!/usr/bin/perl
+#
+# Take a NASM list and map file and make the offsets in the list file
+# absolute. This makes debugging a lot easier.
+#
+# Usage:
+#
+# lstadjust.pl listfile mapfile outfile
+#
+
+($listfile, $mapfile, $outfile) = @ARGV;
+
+open(LST, "< $listfile\0")
+ or die "$0: cannot open: $listfile: $!\n";
+open(MAP, "< $mapfile\0")
+ or die "$0: cannot open: $mapfile: $!\n";
+open(OUT, "> $outfile\0")
+ or die "$0: cannot create: $outfile: $!\n";
+
+%vstart = ();
+undef $sec;
+
+while (defined($line = <MAP>)) {
+ chomp $line;
+ if ($line =~ /^\-+\s+Section\s+(\S+)\s+\-/) {
+ $sec = $1;
+ }
+ next unless (defined($sec));
+ if ($line =~ /^vstart:\s+([0-9a-f]+)/i) {
+ $vstart{$sec} = hex $1;
+ }
+}
+close(MAP);
+
+$offset = 0;
+while (defined($line = <LST>)) {
+ chomp $line;
+
+ $source = substr($line, 40);
+ if ($source =~ /^([^;]*);/) {
+ $source = $1;
+ }
+
+ if ($source =~ /^\S*\s+(\S+)\s+(\S+)/) {
+ $op = $1;
+ $arg = $2;
+
+ if ($op =~ /^(|\[)section$/i) {
+ $offset = $vstart{$arg};
+ } elsif ($op =~ /^(absolute|\[absolute|struc)$/i) {
+ $offset = 0;
+ }
+ }
+
+ if ($line =~ /^(\s*[0-9]+ )([0-9A-F]{8})(\s.*)$/) {
+ $line = sprintf("%s%08X%s", $1, (hex $2)+$offset, $3);
+ }
+
+ print OUT $line, "\n";
+}
+
diff --git a/memdisk/Makefile b/memdisk/Makefile
index 161a163e..0525b709 100644
--- a/memdisk/Makefile
+++ b/memdisk/Makefile
@@ -29,8 +29,8 @@ SFLAGS = $(M32) -march=i386 -D__ASSEMBLY__
LDFLAGS = $(M32) -g
INCLUDE = -I../com32/include
LD = ld -m elf_i386
-NASM = nasm -O99
-NFLAGS = -dVERSION='"$(VERSION)"' -dDATE='"$(DATE)"' -dWITH_EDD
+NASM = nasm
+NFLAGS = -O99 -dVERSION='"$(VERSION)"' -dDATE='"$(DATE)"' -dWITH_EDD
NINCLUDE =
OBJCOPY = objcopy
PERL = perl
diff --git a/sample/Makefile b/sample/Makefile
index cc22a984..22573e63 100644
--- a/sample/Makefile
+++ b/sample/Makefile
@@ -56,7 +56,7 @@ all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32 \
$(OBJCOPY) -O binary $< $@
%.com: %.asm
- $(NASM) -f bin -o $@ -l $*.lst $<
+ $(NASM) -O99 -f bin -o $@ -l $*.lst $<
$(LIB): $(LIBOBJS)
rm -f $@