#!/bin/bash

DIR=${AM_HOME}/am/arch/x86-nemu/img
DEST=$1
shift

make -C $DIR/boot -s

ld -melf_i386 --gc-sections -T $DIR/loader.ld -e _start -o $DEST $DIR/boot/start.o --start-group $@ --end-group
objdump -d $DEST > $DEST.txt

objcopy -S --set-section-flags .bss=alloc,contents -O binary $DEST $DEST.bin
