From: hpa Date: Sat, 20 Aug 2005 00:24:21 +0000 (+0000) Subject: Reorganize memory so we don't have to relocate pxelinux and have more X-Git-Tag: syslinux-3.11~50 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3dd0c5a66fde387207b5ab2c21f406e20280037;p=profile%2Fivi%2Fsyslinux.git Reorganize memory so we don't have to relocate pxelinux and have more stack for extlinux; add tool to check for section overflow. --- diff --git a/Makefile b/Makefile index 13569d1..742ea12 100644 --- a/Makefile +++ b/Makefile @@ -125,15 +125,18 @@ kwdhash.gen: keywords genhash.pl 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 @@ -141,11 +144,13 @@ 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 diff --git a/cache.inc b/cache.inc index c2472ab..05f7d62 100644 --- a/cache.inc +++ b/cache.inc @@ -77,7 +77,7 @@ getcachesector: 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 diff --git a/checkov.pl b/checkov.pl new file mode 100644 index 0000000..b9ebf7b --- /dev/null +++ b/checkov.pl @@ -0,0 +1,80 @@ +#!/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 = ) { + 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); +} diff --git a/dnsresolv.inc b/dnsresolv.inc index 05d0fff..8a64f40 100644 --- a/dnsresolv.inc +++ b/dnsresolv.inc @@ -1,7 +1,7 @@ ; -*- 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 @@ -10,6 +10,7 @@ ; (at your option) any later version; incorporated herein by reference. ; ; ----------------------------------------------------------------------- +; $Id$ ; ; dnsresolv.inc @@ -150,8 +151,8 @@ dns_skiplabel: .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 diff --git a/extlinux.asm b/extlinux.asm index c7a7381..0e6182b 100644 --- a/extlinux.asm +++ b/extlinux.asm @@ -114,7 +114,7 @@ trackbuf resb trackbufsize ; Track buffer goes here 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") @@ -619,8 +619,14 @@ print_bios: 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. @@ -716,8 +722,8 @@ checksumerr_msg db ' Load error - ', 0 ; Boot failed appended ; ; 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 diff --git a/graphics.inc b/graphics.inc index 273cc6b..df3b3a0 100644 --- a/graphics.inc +++ b/graphics.inc @@ -319,7 +319,7 @@ vgacursorcommon: 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 diff --git a/layout.inc b/layout.inc index 46dfc08..6021d69 100644 --- a/layout.inc +++ b/layout.inc @@ -18,15 +18,15 @@ ; -; 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] @@ -50,6 +50,5 @@ TEXT_START equ 7C00h 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 diff --git a/ldlinux.asm b/ldlinux.asm index 1651ae1..a47aeb3 100644 --- a/ldlinux.asm +++ b/ldlinux.asm @@ -632,8 +632,14 @@ print_bios: 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. @@ -729,8 +735,8 @@ checksumerr_msg db ' Load error - ', 0 ; Boot failed appended ; ; 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 diff --git a/parsecmd.inc b/parsecmd.inc index 65a58ad..95432e5 100644 --- a/parsecmd.inc +++ b/parsecmd.inc @@ -93,7 +93,7 @@ getcommand: jc .eof jmp short .skipline - section .bss + section .latebss alignb 4 vk_size equ (vk_end + 3) & ~3 VKernelBuf: resb vk_size ; "Current" vkernel diff --git a/parseconfig.inc b/parseconfig.inc index 32e84be..30fd544 100644 --- a/parseconfig.inc +++ b/parseconfig.inc @@ -359,7 +359,7 @@ SerialPort dw 0 ; Serial port base (or 0 for no serial port) 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 diff --git a/pxelinux.asm b/pxelinux.asm index db6061f..1084a0c 100644 --- a/pxelinux.asm +++ b/pxelinux.asm @@ -207,7 +207,7 @@ PXEStack resd 1 ; Saved stack during PXE call ; 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 @@ -276,6 +276,7 @@ _start: 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 @@ -285,6 +286,7 @@ _start: shr cx,2 std ; Overlapping areas, copy backwards rep movsd +%endif jmp 0:_start1 ; Canonicalize address _start1: diff --git a/ui.inc b/ui.inc index 7174dbe..0d7cc40 100644 --- a/ui.inc +++ b/ui.inc @@ -166,6 +166,10 @@ print_version: 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