From 1445843b99f68998892302a011bec30b5c3b28fe Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 23 May 2009 18:21:18 -0400 Subject: [PATCH] Eliminate "_code32_" prefix on 32bit symbols referenced from 16bit code. Use linking magic to eliminate the need for the _code32_ prefix. --- Makefile | 20 +++++++++++--------- src/layout16.lds.S | 21 +++++++++++++++++++++ src/resume.c | 4 ++-- src/rombios16.lds.S | 13 ++++--------- src/romlayout.S | 8 ++++---- 5 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 src/layout16.lds.S diff --git a/Makefile b/Makefile index 56d0a5b..3a4a1e9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -# Legacy Bios build system +# SeaBIOS build system # -# Copyright (C) 2008 Kevin O'Connor +# Copyright (C) 2008,2009 Kevin O'Connor # # This file may be distributed under the terms of the GNU LGPLv3 license. @@ -111,16 +111,18 @@ $(OUT)romlayout.lds: $(OUT)romlayout16.o @echo " Building layout information $@" $(Q)$(OBJDUMP) -h $< | ./tools/layoutrom.py $@ -$(OUT)rombios16.lds: $(OUT)romlayout.lds +$(OUT)layout16.lds: $(OUT)romlayout.lds -$(OUT)rom16.o: $(OUT)romlayout16.o $(OUT)rom32.o $(OUT)rombios16.lds - @echo " Linking (16bit) $@" - $(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)rom16.o: $(OUT)romlayout16.o $(OUT)rom32.o $(OUT)layout16.lds + @echo " Linking (no relocs) $@" + $(Q)$(LD) -r -T $(OUT)layout16.lds $< -o $@ -$(OUT)rom.o: $(OUT)rom16.o $(OUT)rom32.o $(OUT)rombios.lds +$(OUT)rom.o: $(OUT)rom16.o $(OUT)rom32.o $(OUT)rombios16.lds $(OUT)rombios.lds @echo " Linking $@" - $(Q)$(LD) -T $(OUT)rombios.lds $(OUT)rom16.o $(OUT)rom32.o -o $@ + $(Q)$(LD) -T $(OUT)rombios16.lds $(OUT)rom16.o -R $(OUT)rom32.o -o $(OUT)rom16.final.o + $(Q)$(STRIP) $(OUT)rom16.final.o + $(Q)$(OBJCOPY) --extract-symbol --adjust-vma 0xf0000 $(OUT)rom16.o $(OUT)rom16.moved.o + $(Q)$(LD) -T $(OUT)rombios.lds $(OUT)rom16.final.o $(OUT)rom32.o -R $(OUT)rom16.moved.o -o $@ $(OUT)bios.bin.elf: $(OUT)rom.o @echo " Prepping $@" diff --git a/src/layout16.lds.S b/src/layout16.lds.S new file mode 100644 index 0000000..7b27dd4 --- /dev/null +++ b/src/layout16.lds.S @@ -0,0 +1,21 @@ +// Placement of the 16bit code. +// +// Copyright (C) 2008,2009 Kevin O'Connor +// +// This file may be distributed under the terms of the GNU LGPLv3 license. + +#include "config.h" // BUILD_BIOS_ADDR + +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") +OUTPUT_ARCH("i386") +SECTIONS +{ + +// The actual placement of the 16bit sections is determined by the +// script tools/layoutrom.py +#include "../out/romlayout.lds" + + // Discard regular data sections to force a link error if + // 16bit code attempts to access data not marked with VAR16. + /DISCARD/ : { *(.text*) *(.rodata*) *(.data*) *(.bss*) *(COMMON) } +} diff --git a/src/resume.c b/src/resume.c index 38723d8..ad868f6 100644 --- a/src/resume.c +++ b/src/resume.c @@ -1,6 +1,6 @@ // Code for handling calls to "post" that are resume related. // -// Copyright (C) 2008 Kevin O'Connor +// Copyright (C) 2008,2009 Kevin O'Connor // // This file may be distributed under the terms of the GNU LGPLv3 license. @@ -40,7 +40,7 @@ handle_resume(u8 status) asm volatile( "movw %w1, %%ss\n" "movl %0, %%esp\n" - "pushl $_code32_s3_resume\n" + "pushl $s3_resume\n" "jmp transition32\n" : : "i"(BUILD_S3RESUME_STACK_ADDR), "r"(0) ); diff --git a/src/rombios16.lds.S b/src/rombios16.lds.S index 4793f56..6e6a2f1 100644 --- a/src/rombios16.lds.S +++ b/src/rombios16.lds.S @@ -1,6 +1,6 @@ // Linker definitions for 16bit code // -// Copyright (C) 2008 Kevin O'Connor +// Copyright (C) 2008,2009 Kevin O'Connor // // This file may be distributed under the terms of the GNU LGPLv3 license. @@ -10,12 +10,7 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH("i386") SECTIONS { - -// The actual placement of the 16bit sections is determined by the -// script tools/layoutrom.py -#include "../out/romlayout.lds" - - // Discard regular data sections to force a link error if - // 16bit code attempts to access data not marked with VAR16. - /DISCARD/ : { *(.text*) *(.rodata*) *(.data*) *(.bss*) *(COMMON) } + .text16 code16_start : { + *(.text16) + } } diff --git a/src/romlayout.S b/src/romlayout.S index 9fe5c71..a128018 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -234,7 +234,7 @@ entry_post: jnz 1f // Normal entry point - ENTRY_INTO32 _code32__start + ENTRY_INTO32 _start // Entry point when a post call looks like a resume. 1: @@ -345,7 +345,7 @@ post32: movw %ax, %gs movw %ax, %ss movl $BUILD_STACK_ADDR, %esp - ljmpl $SEG32_MODE32_CS, $_code32__start + ljmpl $SEG32_MODE32_CS, $_start .code16gcc @@ -403,11 +403,11 @@ irqentryarg: // int 18/19 are special - they reset stack and call into 32bit mode. DECLFUNC entry_19 entry_19: - ENTRY_INTO32 _code32_handle_19 + ENTRY_INTO32 handle_19 DECLFUNC entry_18 entry_18: - ENTRY_INTO32 _code32_handle_18 + ENTRY_INTO32 handle_18 /**************************************************************** -- 2.39.5