From f53df62268d63a84c5763ce37a4cac267add57a8 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwinge@gnu.org>
Date: Tue, 3 Oct 2006 14:57:50 +0000
Subject: 2006-10-03  Thomas Schwinge  <tschwinge@gnu.org>

[task #5941 --- ``Linker script for GNU Mach'']
	* Makefile.in (kernel.o): Remove `$(systype)-objfiles-prepend' hackery.
	* i386/Makefile.in (sysdep.a): Likewise.
	* i386/Makerules.in: Likewise.
	(LDFLAGS-kernel): Point to the linker script.
	* i386/i386at/boothdr.S (_start): Don't put into `.text', but into
	`.text.start' instead.
	* i386/ldscript: Change to put `.text' at 0x100000 and put
	`.text.start' first into `.text'.
---
 ChangeLog             | 10 ++++++++++
 Makefile.in           |  5 +----
 i386/Makefile.in      |  4 +---
 i386/Makerules.in     |  8 ++------
 i386/i386at/boothdr.S |  7 +++++--
 i386/ldscript         |  6 ++++++
 6 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9db6137..340389f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,16 @@
 2006-10-03  Thomas Schwinge  <tschwinge@gnu.org>
 
 	[task #5941 --- ``Linker script for GNU Mach'']
+
+	* Makefile.in (kernel.o): Remove `$(systype)-objfiles-prepend' hackery.
+	* i386/Makefile.in (sysdep.a): Likewise.
+	* i386/Makerules.in: Likewise.
+	(LDFLAGS-kernel): Point to the linker script.
+	* i386/i386at/boothdr.S (_start): Don't put into `.text', but into
+	`.text.start' instead.
+	* i386/ldscript: Change to put `.text' at 0x100000 and put
+	`.text.start' first into `.text'.
+
 	* i386/ldscript: New file, copied from `/lib/ldscripts/elf_i386.x' of a
 	GNU Binutils 2.16.1 installation.
 
diff --git a/Makefile.in b/Makefile.in
index 1217b28..1849f77 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -281,11 +281,8 @@ clib-routines := memcpy memmove memset bcopy bzero \
 #	@rm -f $@
 #	$(AR) cq $@ $^
 
-# Then dependency on `$(systype)/sysdep.a' also makes sure that
-# `$($(systype)-objfiles-prepend)' are created.
 kernel.o: $(objfiles) $(systype)/sysdep.a # kernel.a
-	$(LD) -r -o $@ \
-	  $(addprefix $(systype)/,$($(systype)-objfiles-prepend)) $^
+	$(LD) -r -o $@ $^
 kernel-undef: kernel.o
 	$(NM) -u $< | sed 's/  *U  *//;s/^_*//' | sort -u > $@
 kernel-undef-bad: kernel-undef Makefile
diff --git a/i386/Makefile.in b/i386/Makefile.in
index 6fcd5c3..dc5c661 100644
--- a/i386/Makefile.in
+++ b/i386/Makefile.in
@@ -134,11 +134,9 @@ boothdr.o: i386asm.h
 all: sysdep.a
 	$(MAKE) -C linux $@
 
-# `$($(systype)-objfiles-prepend)' are special, but are nevertheless
-# created for the target `sysdep.a'.
 sysdep.a: $(objfiles) linux/linux.o
 	rm -f $@
-	$(AR) cr $@ $(filter-out $($(systype)-objfiles-prepend),$^)
+	$(AR) cr $@ $^
 	$(RANLIB) $@
 
 check:
diff --git a/i386/Makerules.in b/i386/Makerules.in
index ef04948..9f09bcc 100644
--- a/i386/Makerules.in
+++ b/i386/Makerules.in
@@ -33,12 +33,8 @@ DEFINES += -DCONTINUATIONS -D__ELF__ -Di386 $(DEFS-$(systype))
 # The system specific ones always override the generic ones.
 INCLUDES += -I$(abs_top_srcdir)/$(systype)/bogus
 
-# Arrange for a suitable load address.
-LDFLAGS-kernel += -Ttext 100000
-
-# `boothdr.o' has to be at the beginning of the kernel image.
-$(systype)-objfiles-prepend = boothdr.o
-
+# i386 specific linker script.
+LDFLAGS-kernel += -T $(abs_top_srcdir)/$(systype)/ldscript
 
 #
 # Autoconf support
diff --git a/i386/i386at/boothdr.S b/i386/i386at/boothdr.S
index de80753..125eece 100644
--- a/i386/i386at/boothdr.S
+++ b/i386/i386at/boothdr.S
@@ -3,8 +3,11 @@
 
 #include "i386asm.h"
 
-	.text
-
+	/*
+	 * This section will be put first into .text.  See also	i386/ldscript.
+	 */
+	.section .text.start,"ax"
+	
 	/* We should never be entered this way.  */
 	.globl	start,_start
 start:
diff --git a/i386/ldscript b/i386/ldscript
index 0680714..19a5c76 100644
--- a/i386/ldscript
+++ b/i386/ldscript
@@ -46,8 +46,14 @@ SECTIONS
     KEEP (*(.init))
   } =0x90909090
   .plt            : { *(.plt) }
+  /*
+   * _start needs to be at 0x100000, so that's where .text will be begin
+   * and .text.start will be first in there.  See also i386/i386at/boothdr.S.
+   */
+  . = 0x100000;
   .text           :
   {
+    *(.text.start)
     *(.text .stub .text.* .gnu.linkonce.t.*)
     KEEP (*(.text.*personality*))
     /* .gnu.warning sections are handled specially by elf32.em.  */
-- 
cgit v1.2.3