diff --git a/system/makefile b/system/makefile index c4751dc..a344fd6 100755 --- a/system/makefile +++ b/system/makefile @@ -7,21 +7,25 @@ REMOVE=rm -f CHANGEPERM=chmod 644 NM=nm OBJCOPY=objcopy -O binary -R .note -R .comment -S +OBJDEBUG=objcopy --only-keep-debug ZOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p' VOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p' -COMP=gzip -5 +COMP=gzip -9 -f -all: system.sys +all: system.sys -system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin - tools/build setup.bin system.bin zoffset.h system.sys +system.sys: system.tmp + $(OBJCOPY) $^ $@ + +system.tmp: piggy.o voffset.h zoffset.h realmode/setup.bin + tools/build realmode/setup.bin system.bin zoffset.h system.tmp sync voffset.h: system $(NM) system|$(VOFFSET)>voffset.h -zoffset.h: system - $(NM) system|$(ZOFFSET)>zoffset.h +zoffset.h: piggy.o + $(NM) piggy.o|$(ZOFFSET)>zoffset.h togit: clean indent @@ -30,6 +34,8 @@ piggy.o: piggy.S system: systemc.o system.o ../lib/libs.o $(LINK) -T system.ld system.o ../lib/libs.o + $(OBJDEBUG) system system.sym + $(NM) system > system.map system.bin: system $(OBJCOPY) $^ $@ @@ -54,6 +60,9 @@ clean: $(REMOVE) system $(REMOVE) piggy.S $(REMOVE) *.o + $(REMOVE) *.tmp + $(REMOVE) *.sym + $(REMOVE) *.map $(REMOVE) *.gz $(REMOVE) *.h $(REMOVE) *.out diff --git a/system/realmode/makefile b/system/realmode/makefile index 313d537..a5be848 100644 --- a/system/realmode/makefile +++ b/system/realmode/makefile @@ -1,17 +1,24 @@ GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../../include -m16 -fomit-frame-pointer -fno-pic -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -c -o -ASM=gcc -nostdinc -ffreestanding -fno-builtin -m16 -fomit-frame-pointer -fno-pic -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -c -o +ASM=gcc -nostdinc -ffreestanding -fno-builtin -m16 -fomit-frame-pointer -fno-pic -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -I ../ -I ../../include -c -o LINK=ld -m elf_i386 -n CONVERT=dos2unix INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl REMOVE=rm -f CHANGEPERM=chmod 644 +NM=nm +OBJCOPY=objcopy -O binary -R .note -R .comment -S +OBJDEBUG=objcopy --only-keep-debug all: setup.bin sync -setup.bin: setupc.o setup.o +setup: setupc.o setup.o $(LINK) -T setup.ld setupc.o setup.o - $(OBJDUMP) + +setup.bin: setup + $(OBJCOPY) $^ $@ + $(OBJDEBUG) setup setup.sym + $(NM) setup > setup.map setupc.o: setup.c $(GCC) $@ $^ @@ -20,7 +27,10 @@ setup.o: setup.S $(ASM) $@ $^ clean: + $(REMOVE) setup $(REMOVE) *.o + $(REMOVE) *.sym + $(REMOVE) *.map $(REMOVE) *.out $(REMOVE) *.bin $(REMOVE) *.sys diff --git a/system/realmode/setup.S b/system/realmode/setup.S index fbd181f..09f0a1f 100644 --- a/system/realmode/setup.S +++ b/system/realmode/setup.S @@ -19,6 +19,8 @@ #include "voffset.h" #include "zoffset.h" +#define __AC(X, Y) (X##Y) +#define _AC(X, Y) __AC(X,Y) SEGBOOT = 0x07C0 SEGSYS = 0x1000 diff --git a/system/realmode/setup.ld b/system/realmode/setup.ld index 96a6c75..adae564 100644 --- a/system/realmode/setup.ld +++ b/system/realmode/setup.ld @@ -5,6 +5,7 @@ */ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH(i386) +OUTPUT(setup) ENTRY(_start) SECTIONS diff --git a/system/system.ld b/system/system.ld index 3903238..2c99002 100644 --- a/system/system.ld +++ b/system/system.ld @@ -10,12 +10,13 @@ SECTIONS .text ALIGN(16): { *(.text) } - . = 0x200000; .data ALIGN(16): { *(.data) } - .bss ALIGN(16): { - *(.bss) + .bss ALIGN(16): { + __bss_start = .; + *(.bss) + __bss_end = .; } _end = .; }