From: Ben Pfaff Date: Thu, 2 Sep 2004 21:50:25 +0000 (+0000) Subject: Make linking of start.S less brittle. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=commitdiff_plain;h=dfb64e1c2e16f8e5183de565bd4819d875379cee Make linking of start.S less brittle. --- diff --git a/src/Makefile.inc b/src/Makefile.inc index 982b5e8..bab467a 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -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. diff --git a/src/threads/kernel.lds.S b/src/threads/kernel.lds.S index b911b29..ce5d23d 100644 --- a/src/threads/kernel.lds.S +++ b/src/threads/kernel.lds.S @@ -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) } diff --git a/src/threads/start.S b/src/threads/start.S index 5862479..df63f85 100644 --- a/src/threads/start.S +++ b/src/threads/start.S @@ -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.