$(OUT)romlayout32.o: ; $(call whole-compile, $(CFLAGS), $(addprefix src/, $(SRC32)),$@)
-$(OUT)rom32.notreloc.o: $(OUT)romlayout32.o $(OUT)rombios32.lds
+$(OUT)rom32.o: $(OUT)romlayout32.o $(OUT)rombios32.lds
@echo " Linking (no relocs) $@"
- $(Q)ld -r -T $(OUT)rombios32.lds $< -o $@.raw
- $(Q)objcopy --prefix-symbols=_code32_ $@.raw $@
+ $(Q)ld -r -T $(OUT)rombios32.lds $< -o $@
-$(OUT)rom16.o: $(OUT)romlayout16.o $(OUT)rom32.notreloc.o $(OUT)rombios16.lds
+$(OUT)rom16.o: $(OUT)romlayout16.o $(OUT)rom32.o $(OUT)rombios16.lds
@echo " Linking $@"
- $(Q)ld -T $(OUT)rombios16.lds -R $(OUT)rom32.notreloc.o $< -o $@
+ $(Q)objcopy --prefix-symbols=_code32_ $(OUT)rom32.o $(OUT)rom32.rename.o
+ $(Q)ld -T $(OUT)rombios16.lds -R $(OUT)rom32.rename.o $< -o $@
-$(OUT)rom32.o: $(OUT)rom16.o $(OUT)romlayout32.o $(OUT)rombios32.lds
+$(OUT)rom.o: $(OUT)rom16.o $(OUT)rom32.o $(OUT)rombios.lds
@echo " Linking $@"
- $(Q)ld -T $(OUT)rombios32.lds $(OUT)rom16.o $(OUT)romlayout32.o -o $@
+ $(Q)ld -T $(OUT)rombios.lds $(OUT)rom16.o $(OUT)rom32.o -o $@
-$(OUT)bios.bin.elf: $(OUT)rom32.o
+$(OUT)bios.bin.elf: $(OUT)rom.o
@echo " Prepping $@"
$(Q)nm $< | ./tools/checkrom.py
$(Q)strip $< -o $@
--- /dev/null
+// Linker definitions for merging 16 and 32 bit code
+//
+// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include "config.h"
+
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH("i386")
+ENTRY(post32);
+SECTIONS
+{
+ .text code32_start : {
+ *(.text)
+
+ . = code16_start ;
+ final_code16_start = . ;
+ *(.text16)
+
+ . = code16_fixed_start ;
+ final_code16_fixed_start = . ;
+ *(.text16.fixed.addr)
+ }
+
+ .bss __bss_start : {
+ *(.bss)
+ }
+}
OUTPUT_ARCH("i386")
SECTIONS
{
- .text16 ( _code32_code16_start - BUILD_BIOS_ADDR ) : {
+ . = ( _code32_code32_end - BUILD_BIOS_ADDR ) ;
+ code16_start = . ;
+ .text16 : {
*(.text)
*(.rodata*)
*(.data)
}
+ freespace1_start = . ;
+ code16_end = . ;
- .text16.fixed.addr BUILD_START_FIXED : {
+ . = BUILD_START_FIXED ;
+ code16_fixed_start = . ;
+ freespace1_end = . ;
+ .text16.fixed.addr : {
*(.text.fixed.addr)
}
+ code16_fixed_end = . ;
}
-// Linker definitions for 16 and 32 bit code
+// Linker definitions for 32 bit code
//
// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
//
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH("i386")
-ENTRY(post32);
SECTIONS
{
- .text BUILD_BIOS_ADDR : {
- code32_start = . ;
+ . = BUILD_BIOS_ADDR ;
+ code32_start = . ;
+ .text : {
*(.text)
-
- . = ALIGN(16) ;
code32_rodata = . ;
*(.rodata*)
-
- . = ALIGN(16) ;
code32_data = . ;
*(.data)
- code32_end = . ;
-
. = ALIGN(16) ;
- code16_start = . ;
- *(.text16)
- code16_end = . ;
- freespace1_start = . ;
-
- . = BUILD_START_FIXED ;
- freespace1_end = . ;
- *(.text16.fixed.addr)
}
+ code32_end = . ;
- .bss BUILD_BSS_ADDR : {
- __bss_start = . ;
+ . = BUILD_BSS_ADDR ;
+ __bss_start = . ;
+ .bss : {
*(.bss)
*(COMMON)
- __bss_end = . ;
}
+ __bss_end = . ;
}
except:
pass
- c16s = syms['code16_start']
- c32s = syms['_code32_code16_start']
- if c16s != c32s:
- print "Error! 16bit code moved during linking (0x%x vs 0x%x)" % (
- c32s, c16s)
+ c16s = syms['code16_start'] + 0xf0000
+ c32s = syms['final_code16_start']
+ f16s = syms['code16_fixed_start'] + 0xf0000
+ f32s = syms['final_code16_fixed_start']
+ if c16s != c32s or f16s != f32s:
+ print ("Error! 16bit code moved during linking"
+ " (0x%x vs 0x%x, 0x%x vs 0x%x)" % (
+ c32s, c16s, f16s, f32s))
sys.exit(1)
size16 = syms['code16_end'] - syms['code16_start']
size32 = syms['code32_end'] - syms['code32_start']
sizefree = syms['freespace1_end'] - syms['freespace1_start']
+ tablefree = syms['freespace2_end'] - syms['freespace2_start']
print "16bit C-code size: %d" % size16
print "32bit C-code size: %d" % size32
print "Total C-code size: %d" % (size16+size32)
print "Free C-code space: %d" % sizefree
+ print "BIOS table space: %d" % tablefree
if __name__ == '__main__':
main()