summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordzwdz2021-07-18 17:06:32 +0200
committerdzwdz2021-07-18 17:06:32 +0200
commit185c7c44c0da51b5442abf4fd3fb549f99c5bab8 (patch)
treecc3e73fed5b322a312bdcd55dd4ee6e97f135a15
parentca5ce39490d4df893f8285f940602dc140b29247 (diff)
clean up the linker script, remove duplicate labels
-rw-r--r--src/kernel/arch/generic.h4
-rw-r--r--src/kernel/arch/i386/boot.s2
-rw-r--r--src/kernel/arch/i386/gdt/gdt.c2
-rw-r--r--src/kernel/linker.ld3
-rw-r--r--src/kernel/mem.c1
5 files changed, 5 insertions, 7 deletions
diff --git a/src/kernel/arch/generic.h b/src/kernel/arch/generic.h
index e06ac27..46782f8 100644
--- a/src/kernel/arch/generic.h
+++ b/src/kernel/arch/generic.h
@@ -6,8 +6,8 @@
// some code assumes that it's a power of 2
#define PAGE_SIZE 4096
-// src/arch/i386/boot.s
-extern char stack_top;
+// linker.ld
+extern char _bss_end;
__attribute__((noreturn))
void halt_cpu();
diff --git a/src/kernel/arch/i386/boot.s b/src/kernel/arch/i386/boot.s
index 74de9b7..e6eb26f 100644
--- a/src/kernel/arch/i386/boot.s
+++ b/src/kernel/arch/i386/boot.s
@@ -2,7 +2,7 @@
.global _start
.type _start, @function
_start:
- mov $stack_top, %esp
+ mov $_bss_end, %esp // the stack is at the top of bss
push %ebx // address of the Multiboot struct
call kmain_early
diff --git a/src/kernel/arch/i386/gdt/gdt.c b/src/kernel/arch/i386/gdt/gdt.c
index 2935e6e..e4cd3ef 100644
--- a/src/kernel/arch/i386/gdt/gdt.c
+++ b/src/kernel/arch/i386/gdt/gdt.c
@@ -80,7 +80,7 @@ static void gdt_prepare() {
// tss
memset(&TSS, 0, sizeof(TSS));
TSS.ss0 = SEG_r0data << 3; // kernel data segment
- TSS.esp0 = (uintptr_t) &stack_top;
+ TSS.esp0 = (uintptr_t) &_bss_end;
GDT[SEG_TSS] = (struct gdt_entry) {
.limit_low = sizeof(TSS),
diff --git a/src/kernel/linker.ld b/src/kernel/linker.ld
index 650ecd7..274abc3 100644
--- a/src/kernel/linker.ld
+++ b/src/kernel/linker.ld
@@ -22,9 +22,8 @@ SECTIONS
*(COMMON)
*(.bss)
- stack_bottom = .;
+ _stack_bottom = .;
. += 16K;
- stack_top = .;
}
_bss_end = (. + 0xFFF) & ~0xFFF; /* aligned to 4K */
}
diff --git a/src/kernel/mem.c b/src/kernel/mem.c
index ba5b504..1fce506 100644
--- a/src/kernel/mem.c
+++ b/src/kernel/mem.c
@@ -6,7 +6,6 @@ static void *highest_page;
void mem_init(struct kmain_info *info) {
// finds the highest used page, and starts allocating pages above it
- extern char _bss_end;
void *highest = &_bss_end;
size_t page_mask = PAGE_SIZE - 1;