From 61d542720e7a444b4585dfbbaeb55d901769037d Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Thu, 27 Jan 2022 06:43:20 +0500 Subject: [PATCH] Add linker scripts --- build.sh | 4 ++-- src/x86_stage1.ld | 12 ++++++++++++ src/x86_stage2.ld | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/x86_stage1.ld create mode 100644 src/x86_stage2.ld diff --git a/build.sh b/build.sh index 90af7c6..2dfc2ef 100755 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ CROSS="$BIN/i386-elf-" ${CROSS}gcc -c src/x86_stage1.S -o src/x86_stage1.o ${CROSS}gcc -c src/x86_stage2.S -o src/x86_stage2.o -${CROSS}ld -Ttext 200000 --oformat binary -o src/x86_stage1.bin src/x86_stage1.o -${CROSS}ld -Ttext 200000 --oformat binary -o src/x86_stage2.bin src/x86_stage2.o +${CROSS}ld -Tsrc/x86_stage1.ld --oformat binary -o src/x86_stage1.bin src/x86_stage1.o +${CROSS}ld -Tsrc/x86_stage2.ld --oformat binary -o src/x86_stage2.bin src/x86_stage2.o ./testyboot mbr mbr.bin src/x86_stage1.bin cat mbr.bin src/x86_stage2.bin > disk.img diff --git a/src/x86_stage1.ld b/src/x86_stage1.ld new file mode 100644 index 0000000..4d02c8b --- /dev/null +++ b/src/x86_stage1.ld @@ -0,0 +1,12 @@ +OUTPUT_ARCH("i386") +ENTRY(_start) + +SECTIONS +{ + . = 0x7c00; + + .text : + { + *(.text); + } +} diff --git a/src/x86_stage2.ld b/src/x86_stage2.ld new file mode 100644 index 0000000..1392376 --- /dev/null +++ b/src/x86_stage2.ld @@ -0,0 +1,12 @@ +OUTPUT_ARCH("i386") +ENTRY(_start) + +SECTIONS +{ + . = 0x7e00; + + .text : + { + *(.text); + } +}