stack for extlinux; add tool to check for section overflow.
ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
$(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
-DMAP=ldlinux.map -l ldlinux.lst -o ldlinux.bin ldlinux.asm
+ $(PERL) checkov.pl ldlinux.map $@
pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
$(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
-DMAP=pxelinux.map -l pxelinux.lst -o pxelinux.bin pxelinux.asm
+ $(PERL) checkov.pl pxelinux.map $@
isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
$(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
-DMAP=isolinux.map -l isolinux.lst -o isolinux.bin isolinux.asm
- $(PERL) checksumiso.pl isolinux.bin
+ $(PERL) checkov.pl isolinux.map $@
+ $(PERL) checksumiso.pl $@
# Special verbose version of isolinux.bin
isolinux-debug.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
-DDEBUG_MESSAGES \
-DMAP=isolinux-debug.map -l isolinux-debug.lst \
-o isolinux-debug.bin isolinux.asm
+ $(PERL) checkov.pl isolinux-debug.map $@
$(PERL) checksumiso.pl $@
extlinux.bin: extlinux.asm kwdhash.gen version.gen
$(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
-DMAP=extlinux.map -l extlinux.lst -o extlinux.bin extlinux.asm
+ $(PERL) checkov.pl extlinux.map $@
pxelinux.0: pxelinux.bin
cp pxelinux.bin pxelinux.0
pop cx
ret
- section .bss
+ section .latebss
alignb 4
CachePtrs resd 65536/SECTOR_SIZE ; Cached sector pointers
NextCacheSlot resw 1 ; Next cache slot to occupy
--- /dev/null
+#!/usr/bin/perl
+#
+# checkov.pl
+#
+# Check NASM map output for overflow
+#
+# This assumes that a section for which start != vstart, both
+# ranges need to be checked for overflow (true for SYSLINUX)
+#
+
+($in, $target) = @ARGV;
+
+sub overlap($$$$) {
+ my($s1,$e1,$s2,$e2) = @_;
+
+ return 1 if ( $s2 < $e1 && $e2 > $s1 );
+ return 1 if ( $s1 < $e2 && $e1 > $s2 );
+
+ return 0;
+}
+
+open(IN, '<', $in) or die "$0: Cannot open input file: $in\n";
+
+$section = undef;
+while ( $line = <IN> ) {
+ if ( $line =~ /^-/ ) {
+ if ( $line =~ /^\-\-\-\- Section (\S+) / ) {
+ $section = $1;
+ } else {
+ $section = undef;
+ }
+ } elsif ( defined($section) ) {
+ if ( $line =~ /^length\:\s*(\S+)/ ) {
+ $length{$section} = hex $1;
+ } elsif ( $line =~ /^start\:\s*(\S+)/ ) {
+ $start{$section} = hex $1;
+ } elsif ( $line =~ /^vstart\:\s*(\S+)/ ) {
+ $vstart{$section} = hex $1;
+ }
+ }
+}
+close(IN);
+
+$err = 0;
+
+foreach $s ( keys(%start) ) {
+ $sstart = $start{$s};
+ $svstart = $vstart{$s};
+ $send = $sstart + $length{$s};
+ $svend = $svstart + $length{$s};
+
+ if ( $send > 0x10000 || $svend > 0x10000 ) {
+ print STDERR "$target: 16-bit overflow on section $s\n";
+ $err++;
+ }
+
+ foreach $o ( keys(%start) ) {
+ next if ( $s ge $o );
+
+ $ostart = $start{$o};
+ $ovstart = $vstart{$o};
+ $oend = $ostart + $length{$o};
+ $ovend = $ovstart + $length{$o};
+
+ if ( overlap($sstart, $send, $ostart, $oend) ||
+ overlap($svstart, $svend, $ostart, $oend) ||
+ overlap($sstart, $send, $ovstart, $ovend) ||
+ overlap($svstart, $svend, $ovstart, $ovend) ) {
+ print STDERR "$target: section $s overlaps section $o\n";
+ $err++;
+ }
+ }
+}
+
+if ( $err ) {
+ unlink($target);
+ exit(1);
+} else {
+ exit(0);
+}
; -*- fundamental -*-
; -----------------------------------------------------------------------
;
-; Copyright 2004 H. Peter Anvin - All Rights Reserved
+; Copyright 2004-2005 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; (at your option) any later version; incorporated herein by reference.
;
; -----------------------------------------------------------------------
+; $Id$
;
; dnsresolv.inc
.rdata: equ $
endstruc
- section .bss
- alignb 2, db 0
+ section .latebss
+ alignb 2
DNSSendBuf resb DNS_MAX_PACKET
DNSRecvBuf resb DNS_MAX_PACKET
LocalDomain resb 256 ; Max possible length
getcbuf resb trackbufsize
; ends at 4800h
- section .bss
+ section .latebss
SuperBlock resb 1024 ; ext2 superblock
SuperInfo resq 16 ; DOS superblock expanded
ClustSize resd 1 ; Bytes/cluster ("block")
jne .cbios
mov si,ebios_name
.cbios:
+ mov [BIOSName],si
call writestr
+ section .bss
+%define HAVE_BIOSNAME 1
+BIOSName resw 1
+
+ section .text
;
; Now we read the rest of LDLINUX.SYS. Don't bother loading the first
; sector again, though.
;
; BIOS type string
;
-cbios_name db 'CBIOS', 0
-ebios_name db 'EBIOS', 0
+cbios_name db ' CBIOS', 0
+ebios_name db ' EBIOS', 0
;
; Debug routine
linear_color db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0
UsingVGA db 0
- section .bss
+ section .latebss
alignb 2
GraphXSize resw 1 ; Width of splash screen file
VGAPos resw 1 ; Pointer into VGA memory
;
-; Memory below 0800h is reserved for the BIOS and the MBR
+; Memory below 0800h is reserved for the BIOS and the MBR.
BSS_START equ 0800h
-; PXELINUX needs lots of BSS, so it relocates itself on startup
-%if IS_PXELINUX
-TEXT_START equ 0A000h
-%else
+; Text starts at the load address of 07C00h.
TEXT_START equ 7C00h
-%endif
+
+; The secondary BSS section, above the text; we really wish we could
+; just make it follow .bcopy32, but it doesn't seem to work that way.
+LATEBSS_START equ 0B000h
%ifdef MAP
[map all MAP]
section .data align=16 ; follows=.text
; NASM BUG: We would like to do follows=.bcopy32
- section .latebss nobits align=16 start=0E000h
-
+ section .latebss nobits align=16 start=LATEBSS_START
jne .cbios
mov si,ebios_name
.cbios:
+ mov [BIOSName],si
call writestr
+ section .bss
+%define HAVE_BIOSNAME 1
+BIOSName resw 1
+
+ section .text
;
; Now we read the rest of LDLINUX.SYS. Don't bother loading the first
; sector again, though.
;
; BIOS type string
;
-cbios_name db 'CBIOS', 0
-ebios_name db 'EBIOS', 0
+cbios_name db ' CBIOS', 0
+ebios_name db ' EBIOS', 0
;
; Debug routine
jc .eof
jmp short .skipline
- section .bss
+ section .latebss
alignb 4
vk_size equ (vk_end + 3) & ~3
VKernelBuf: resb vk_size ; "Current" vkernel
VKernelBytes dw 0 ; Number of bytes used by vkernels
VKernel db 0 ; Have we seen any "label" statements?
- section .bss
+ section .latebss
alignb 4 ; For the good of REP MOVSD
command_line resb max_cmd_len+2 ; Command line buffer
alignb 4
; writing a received ARP packet into low memory.
RBFG_brainfuck resb 0E00h
- section .bss
+ section .latebss
alignb 4
RebootTime resd 1 ; Reboot timeout, if set by option
StrucPtr resd 1 ; Pointer to PXENV+ or !PXE structure
mov ds,ax
mov es,ax
+%if TEXT_START != 0x7c00
; This is uglier than it should be, but works around
; some NASM 0.98.38 bugs.
mov di,section..bcopy32.start
shr cx,2
std ; Overlapping areas, copy backwards
rep movsd
+%endif
jmp 0:_start1 ; Canonicalize address
_start1:
push di ; Command line write pointer
mov si,syslinux_banner
call cwritestr
+%ifdef HAVE_BIOSNAME
+ mov si,[BIOSName]
+ call cwritestr
+%endif
mov si,copyright_str
call cwritestr