diff --git a/Makefile b/Makefile index 1b3b33e47aeea8f799560cc7405c0d167b3d7aa8..7815e99be5186c9e0c2bca9f0eb74b6053592504 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ AS := as -LD := ld -m elf_x86_64 - -LDFLAG := -Ttext 0x0 -s --oformat binary +LD := ld image : linux.img @@ -15,16 +13,16 @@ kernel/system : kernel/head.S kernel/*.c mm/*.c kernel/blk_drv/*.c fs/*.c cd kernel; make system; cd .. bootsect : bootsect.o - $(LD) $(LDFLAG) -o $@ $< + $(LD) -T x86_32.lds.S -o $@ $< bootsect.o : bootsect.S - $(AS) -o $@ $< + $(AS) --32 -o $@ $< setup : setup.o - $(LD) $(LDFLAG) -e _start_setup -o $@ $< + $(LD) -T x86_32.lds.S -e _start_setup -o $@ $< setup.o : setup.S - $(AS) -o $@ $< + $(AS) --32 -o $@ $< clean: rm *.o rm bootsect diff --git a/fs/Makefile b/fs/Makefile index 193ad9fdcb8fc7395ada1e8165e6d7dae7610a74..149ff4f95d461a70ab017ff570332fda8bd68842 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -1,7 +1,6 @@ GCC := gcc LD := ld CCFLAG := -I../include -nostdinc -ffreestanding -Wall -fomit-frame-pointer -fno-stack-protector -fno-pic -c -m32 -LDFLAG := -Ttext 0x0 -s --oformat binary -m elf_i386 INCDIR := ../include OBJS := read_write.o buffer.o super.o open.o file_table.o inode.o namei.o fcntl.o char_dev.o bitmap.o truncate.o diff --git a/kernel/Makefile b/kernel/Makefile index 8c976ab530a846818505373f4686fe1fcb71505d..f4ecbca102409e4087ec7cf982f95778839bbd7a 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,12 +1,12 @@ GCC := gcc CCFLAG := -I../include -nostdinc -ffreestanding -Wall -fomit-frame-pointer -fno-pic -fno-stack-protector -c -m32 -LDFLAG := -Ttext 0x0 -s --oformat binary -m elf_i386 INCDIR := ../include OBJS := head.o main.o sys_call.o asm.o sched.o printk.o vsprintf.o mktime.o \ traps.o fork.o panic.o chr_drv/chr_drv.a blk_drv/blk_drv.a ../mm/mm.o ../lib/lib.a ../fs/fs.o + system: $(OBJS) - $(LD) $(LDFLAG) -M -e startup_32 -o $@ $^ > System.map + $(LD) -T ../x86_32.lds.S -M -e startup_32 -o $@ $^ > System.map head.o : head.S $(GCC) -m32 -traditional -c -o $@ $< diff --git a/mm/Makefile b/mm/Makefile index e334d0b0d68d92cb7a23198304ba9a49a0514e4e..f62260d0e28dc9d15a764550768befb9f54acbd9 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -1,7 +1,6 @@ GCC := gcc -LD := ld +LD := ld CCFLAG := -I../include -nostdinc -ffreestanding -Wall -fomit-frame-pointer -fno-pic -fno-stack-protector -c -m32 -LDFLAG := -Ttext 0x0 -s --oformat binary -m elf_i386 INCDIR := ../include OBJS := swap.o memory.o page.o diff --git a/x86_32.lds.S b/x86_32.lds.S new file mode 100644 index 0000000000000000000000000000000000000000..c19de30a26dd6ab1ed6bc9b292b566ef092bfdc6 --- /dev/null +++ b/x86_32.lds.S @@ -0,0 +1,20 @@ +OUTPUT_FORMAT("binary") +OUTPUT_ARCH(i386) +SECTIONS +{ + .text 0x00 : + { + *(.text) + /* + *(.text.unlikely .text.*_unlikely .text.unlikely.*) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(SORT(.text.sorted.*)) + *(.text .stub .text.* .gnu.linkonce.t.*) + */ + } + . = 0x200; + _end = .; PROVIDE (end = .); + /DISCARD/ : {*(*)} +}