Make linking of start.S less brittle.
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 2 Sep 2004 21:50:25 +0000 (21:50 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 2 Sep 2004 21:50:25 +0000 (21:50 +0000)
src/Makefile.inc
src/threads/kernel.lds.S
src/threads/start.S

index 982b5e800f5e5b63f9ddb5f0a7772beb80ab626c..bab467aca9339fac0d0976e18c2af7b153be782c 100644 (file)
@@ -15,8 +15,7 @@ CFLAGS = -g -O3 -MMD -msoft-float $(WARNINGS) $(INCLUDES) $(DEFINES)
 ASFLAGS = -Wa,--gstabs+ $(INCLUDES) $(DEFINES)
 
 # Core kernel.
-THREADS_SRC  = start.S         # Must be linked first.
-THREADS_SRC += init.c          # Main program.
+THREADS_SRC  = init.c          # Main program.
 THREADS_SRC += thread.c                # Thread management core.
 THREADS_SRC += switch.S                # Thread switch routine.
 THREADS_SRC += interrupt.c     # Interrupt core.
@@ -25,6 +24,7 @@ THREADS_SRC += synch.c                # Synchronization.
 THREADS_SRC += paging.c                # Page tables.
 THREADS_SRC += palloc.c                # Page allocator.
 THREADS_SRC += malloc.c                # Subpage allocator.
+THREADS_SRC += start.S         # Startup code.
 
 # Device driver code.
 DEVICES_SRC  = timer.c         # Timer device.
index b911b29fa45853714f6e069468c1cdd8b4f20b9d..ce5d23d39b38f395b9580fb3dd78c8bfbc046b6f 100644 (file)
@@ -11,7 +11,7 @@ SECTIONS
   _start = .;
 
   /* Kernel starts with code, followed by read-only data and writable data. */
-  .text : { *(.text) } = 0x9090
+  .text : { *(.start) *(.text) } = 0x9090
   .rodata : { *(.rodata) *(.rodata.*) }
   .data : { *(.data) }
 
index 58624791a78e599bac5df8914a0fc0398b8dc52c..df63f8595abec0bdfe08835706ce64f4ad695d5d 100644 (file)
@@ -1,8 +1,12 @@
-# This module gets linked first, so that the kernel entry point
-# is the very beginning of its binary image.  All we need to do is
-# jump to the real entry point.
+#### The loader needs to have some way to know the kernel's entry
+#### point, that is, the address to which it should jump to start the
+#### kernel.  We handle this by writing the linker script kernel.lds.S
+#### so that this module appears at the very beginning of the kernel
+#### image, and then using that as the entry point.
 
 .globl start
+.section .start
+
 start: call main
 
        # If main returns, spin.