aboutsummaryrefslogtreecommitdiff
path: root/arch/i686/linker.ld
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-03-28 20:03:38 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-08-12 10:13:59 +0300
commitedf9e71e2a7b6b89775c29cf28c19c6b89992c25 (patch)
tree3adbf944d9e47a743063487c4facb7eed1fbdee0 /arch/i686/linker.ld
downloadkernel-edf9e71e2a7b6b89775c29cf28c19c6b89992c25.tar.xz
Initial commit
x86 kernel that prints a hello world message to com1
Diffstat (limited to 'arch/i686/linker.ld')
-rw-r--r--arch/i686/linker.ld54
1 files changed, 54 insertions, 0 deletions
diff --git a/arch/i686/linker.ld b/arch/i686/linker.ld
new file mode 100644
index 0000000..61a3be9
--- /dev/null
+++ b/arch/i686/linker.ld
@@ -0,0 +1,54 @@
+ENTRY(_start)
+OUTPUT_FORMAT(elf32-i386)
+
+MULTIBOOT_SIZE = 0x2000;
+VADDR_BASE = 0xc0000000;
+
+SECTIONS
+{
+ /* First put the multiboot header, as it is required to be put very early in the image or the bootloader won't *
+ * recognize the file format. *
+ * Once the MMU is set up, this section is no longer needed and should be unmapped. */
+ . = 0;
+ .bootstrap : {
+ . = ALIGN(8);
+ __multiboot_begin = .;
+ KEEP(*(.multiboot.header))
+ KEEP(*(.multiboot.text))
+ KEEP(*(.multiboot.pages))
+ __multiboot_end = .;
+ }
+
+ . = VADDR_BASE;
+
+ .text ALIGN(4K) : AT(ADDR(.text) - VADDR_BASE + MULTIBOOT_SIZE) {
+ __text_begin = .;
+ *(.text*)
+ __text_end = .;
+ }
+
+ /* Read-only data. */
+ .rodata ALIGN(4K) : AT(ADDR(.rodata) - VADDR_BASE + MULTIBOOT_SIZE) {
+ __rodata_begin = .;
+ *(.constinit)
+ *(.rodata*)
+ __rodata_end = .;
+ }
+
+ /* Read-write data (uninitialized) and stack */
+ .bss ALIGN(4K) : AT(ADDR(.bss) - VADDR_BASE + MULTIBOOT_SIZE) {
+ __bss_begin = .;
+ *(.stack)
+ *(.pages)
+ *(.bss*)
+ __bss_end = .;
+ }
+
+ /* Read-write data (initialized) */
+ .data ALIGN(4K) : AT(ADDR(.data) - VADDR_BASE + MULTIBOOT_SIZE) {
+ __data_begin = .;
+ *(.init)
+ *(.data)
+ __data_end = .;
+ }
+}