#!/bin/sh # # Copyright (c) 1994-1998 University of Utah and the Flux Group. # All rights reserved. # # This file is part of the Flux OSKit. The OSKit is free software, also known # as "open source;" you can redistribute it and/or modify it under the terms # of the GNU General Public License (GPL), version 2, as published by the Free # Software Foundation (FSF). To explore alternate licensing terms, contact # the University of Utah at csl-dist@cs.utah.edu or +1-801-585-3271. # # The OSKit is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GPL for more details. You should have # received a copy of the GPL along with the OSKit; see the file COPYING. If # not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA. # # This little script uses GNU ld to build a DOS boot image # from a MultiBoot kernel image and a set of boot modules. bootdir=${BOOTDIR-@prefix@/lib/oskit} cc=${CC-@CC@} ld=${LD-@LD@} dosld=${DOS_LD-@DOS_LD@} modules= outfile=image.exe savetemps= # Parse the command-line options. until [ $# -eq 0 ] do case "$1" in -x ) db="$2"; shift; shift;; -o ) outfile="$2"; shift; shift;; -save-temps) savetemps="$1"; shift;; * ) modules="$modules $1"; shift;; esac done # Wrap each of the input files in a .o file. # At the same time, build an assembly language module # containing a table describing the boot modules. echo >$outfile.mods.S ".text; .long 0xf00baabb; .long endtab-tab; tab:" files= for module in $modules; do # Split out the associated string, if any. file=`echo $module | sed -e 's,:.*$,,'` string=`echo $module | sed -e 's,^[^:]*:,,'` if test -z "$string"; then string=$file; fi # Add this file to the list of files to be included, # but only if it hasn't already been seen before # (e.g., with a different attached string). alreadythere= for afile in $files; do if [ $file = $afile ]; then alreadythere=yes; fi done if [ -z $alreadythere ]; then files="$files $file"; fi # Convert all non-alphanum chars to underscores for the symbol name. # The BFD binary input format will do the same thing # to produce the symbol names that it "wraps around" the input files. sym_name=`echo $file | sed -e 's,[^a-zA-Z0-9],_,g'` # Produce an entry in the module description file. echo >>$outfile.mods.S ".long _binary_$sym_name""_start" echo >>$outfile.mods.S ".long _binary_$sym_name""_end" echo >>$outfile.mods.S ".long 1f" echo >>$outfile.mods.S ".long 2f" echo >>$outfile.mods.S ".data" echo >>$outfile.mods.S "1: .ascii \"$string\\0\"; 2:" echo >>$outfile.mods.S ".text" done echo >>$outfile.mods.S "endtab:" # Assemble the module vector file. $cc -c -o $outfile.mods.o $outfile.mods.S || exit 1 # Link the module vector file with the boot module files. # Use the binary bfd backend for both the input bmod files and the output file. $dosld -Ttext 0 -defsym _start=0 -oformat binary -o $outfile.tmp \ $outfile.mods.o -format binary $files -format default \ || exit 1 # Create the final boot image by tacking that onto the end of 'dosboot.exe'. cat $bootdir/dosboot.exe $outfile.tmp >$outfile if test -z "$savetemps"; then rm -f $outfile.mods.S $outfile.mods.o $outfile.tmp fi exit 0