From 7cf17f2e436e466b52b67cca735397089ff78086 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 8 Apr 2009 21:10:08 -0400 Subject: [PATCH] Rework linker scripts so they work on new version of ld. Declare output sections with explicit start address - don't rely on LD using '.' for the start of the section. Make addresses that are absolute by using the ABSOLUTE() function. Discard .eh_frame - new gcc has this on by default. Also, don't use '-d' - instead use FORCE_COMMON_ALLOCATION. --- Makefile | 2 +- src/rombios.lds.S | 2 +- src/rombios16.lds.S | 8 +++----- src/rombios32.lds.S | 8 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 7d7dbeb..1df23b4 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ $(OUT)ccode32.o: ; $(call whole-compile, $(CFLAGS), $(addprefix src/, $(SRC32)), $(OUT)rom32.o: $(OUT)ccode32.o $(OUT)rombios32.lds @echo " Linking (no relocs) $@" - $(Q)$(LD) -r -d -T $(OUT)rombios32.lds $< -o $@ + $(Q)$(LD) -r -T $(OUT)rombios32.lds $< -o $@ $(OUT)romlayout.lds: $(OUT)romlayout16.o @echo " Building layout information $@" diff --git a/src/rombios.lds.S b/src/rombios.lds.S index e43822a..a6afe1f 100644 --- a/src/rombios.lds.S +++ b/src/rombios.lds.S @@ -16,5 +16,5 @@ SECTIONS *(.text16) final_code16_end = . ; } - /DISCARD/ : { *(.discard*) } + /DISCARD/ : { *(.discard*) *(.eh_frame) } } diff --git a/src/rombios16.lds.S b/src/rombios16.lds.S index c52afdb..a25392c 100644 --- a/src/rombios16.lds.S +++ b/src/rombios16.lds.S @@ -10,17 +10,15 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH("i386") SECTIONS { - . = ( _code32_code32_end - BUILD_BIOS_ADDR ) ; - . = ALIGN(16) ; - code16_start = . ; - .text16 : { + .text16 ALIGN(_code32_code32_end - _code32_code32_start, 16) : { + code16_start = ABSOLUTE(.) ; // The actual placement of the 16bit sections is determined by the // script tools/layoutrom.py #include "../out/romlayout.lds" + code16_end = ABSOLUTE(.) ; } - code16_end = . ; // Discard regular data sections to force a link error if // 16bit code attempts to access data not marked with VAR16. diff --git a/src/rombios32.lds.S b/src/rombios32.lds.S index 4aa88f0..311da25 100644 --- a/src/rombios32.lds.S +++ b/src/rombios32.lds.S @@ -8,17 +8,17 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH("i386") +FORCE_COMMON_ALLOCATION SECTIONS { - . = BUILD_BIOS_ADDR ; - code32_start = . ; - .text : { + .text BUILD_BIOS_ADDR : { + code32_start = ABSOLUTE(.) ; *(.text) code32_rodata = . ; *(.rodata*) *(.data) *(.bss) *(COMMON) + code32_end = ABSOLUTE(.) ; } - code32_end = . ; } -- 2.25.1