Rework linker scripts so they work on new version of ld.
authorKevin O'Connor <kevin@koconnor.net>
Thu, 9 Apr 2009 01:10:08 +0000 (21:10 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 9 Apr 2009 01:10:08 +0000 (21:10 -0400)
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
src/rombios.lds.S
src/rombios16.lds.S
src/rombios32.lds.S

index 7d7dbebe5fb91dd0de49b7942acf68c4fe4ea9a3..1df23b4417e9654486f9accd6c608762c3e82026 100644 (file)
--- 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 $@"
index e43822ae1af0b9dfe7fdc30fffbb5dee2710a7cc..a6afe1fc50889bafe19ad4ec649a20b997976741 100644 (file)
@@ -16,5 +16,5 @@ SECTIONS
                 *(.text16)
                 final_code16_end = . ;
                 }
-        /DISCARD/ : { *(.discard*) }
+        /DISCARD/ : { *(.discard*) *(.eh_frame) }
 }
index c52afdb784c5ad5dabecb45b822848b74f5b5fbd..a25392ce097e5cf3049afa72d1a1f69562166ac3 100644 (file)
@@ -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.
index 4aa88f083264bddd28afb6dfd633c2cf202cfa45..311da2579ce952ecc930bd0a1177cab7728acede 100644 (file)
@@ -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 = . ;
 }