Skip to content

Commit

Permalink
Update linux build script to run on modern tools
Browse files Browse the repository at this point in the history
  • Loading branch information
sivasankarankb committed Feb 14, 2023
1 parent 31c8696 commit 9759c36
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
21 changes: 19 additions & 2 deletions extras/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ These were removed from the old sources as they no longer require to be built.
Those sources were kept only for historic reasons.

These files were re-created. There were no build scripts for Linux distros
back then. A simple translation to linux commands has been done.
Copy the scripts to the outermost directory before running.
back then. The included Linux script has been tested on very modern build
tools. Copy the scripts to the outermost directory before running.


v0.1.0
Expand Down Expand Up @@ -51,3 +51,20 @@ v0.1.0
the definition from `ports.c` to `proto.h`. Place it below the `io_wait()`
declaration there.

- \[07\] (Fix included in Linux build script)

Modern x86-64 tools have to be instructed to produce 32bit code explicitly.
The `-m32` GCC flag and i386 ELF emulation in LD with `-melf_i386` seems
to do the trick as of now.

- \[08\] (Fix included in Linux build script)

Modern Linux builds of GCC produce position independent executables (PIEs) by
default. The kernel is always loaded to a fixed address. PIE generation is
disabled with the `-fno-pie` switch.

- \[09\] (Fix included in Linux build script)

A stack smash protector added by GCC requires handling from within the kernel.
This was never implemented in the original kernel code. This feature is
disabled with the `-fno-stack-protector` flag.
5 changes: 3 additions & 2 deletions extras/linux-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ clear

# GNU/Linux GCC Build Script for Blaze OS v0.1.0

CFLAGS="-c -nostdinc -nostdlib -ffreestanding -march=i386 -fleading-underscore"
CFLAGS="-c -nostdinc -nostdlib -ffreestanding -march=i386 -fleading-underscore \
-fno-pie -fno-stack-protector -m32"
CFILES="kernel irq isr itext memmgr pic ports ps2"
CFILECOUNT=$(echo "$CFILES" | wc -w)
SRCCOUNT=$(($CFILECOUNT + 1))
Expand Down Expand Up @@ -32,7 +33,7 @@ for CSOURCE in ${CFILES}; do

echo "4 of 6 Create kernel binary"

ld obj/idt.o obj/libk.a -T linker.ld -o obj/ldkern.o
ld -melf_i386 obj/idt.o obj/libk.a -T linker.ld -o obj/ldkern.o
objcopy -R .note -R .comment -S -g -O binary obj/ldkern.o bin/kernel.bin

echo "5 of 6 Create boot disk image"
Expand Down

0 comments on commit 9759c36

Please sign in to comment.