Skip to content
Snippets Groups Projects
Commit 00ea3c3e authored by Bensong Liu's avatar Bensong Liu
Browse files

use PIE mode to prevent LD from producing huge binary

parent 71bd3674
No related branches found
No related tags found
No related merge requests found
Pipeline #835 failed with stage
...@@ -9,13 +9,13 @@ ARCH = i386 ...@@ -9,13 +9,13 @@ ARCH = i386
endif endif
assemble: kernel head assemble: kernel head
ld -o kernel.img -Ttext 0x7e00 --oformat binary image_head.o kernel.o -m elf_$(ARCH) ld -o kernel.img -fpie -shared --oformat binary image_head.o kernel.o -m elf_$(ARCH)
head: head:
nasm -f elf$(BITS) -DTARGET_BITS=$(BITS) image_head.asm -o image_head.o nasm -f elf$(BITS) -DTARGET_BITS=$(BITS) image_head.asm -o image_head.o
kernel: kernel:
g++ -ffreestanding -fno-pie -c kernel.cc -o kernel.o -m$(BITS) -std=c++17 g++ -ffreestanding -fpie -c kernel.cc -o kernel.o -m$(BITS) -std=c++17
clean: clean:
rm -f *.o *.img rm -f *.o *.img
......
global _start
_start:
[bits TARGET_BITS] [bits TARGET_BITS]
[extern main] [extern main]
call main call main
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment