added linker script

git-svn-id: svn://anubis/hos/trunk@12 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
josh 2009-06-24 21:53:32 +00:00
parent 09fb19df15
commit 788597b6f4
3 changed files with 31 additions and 7 deletions

View File

@ -1,14 +1,16 @@
KERNEL = hos KERNEL = hos
LOAD_ADDRESS = 0x100000 LDFLAGS = -T link.ld
LDTARGET = elf32-i386
LDFLAGS = -Ttext $(LOAD_ADDRESS) --oformat $(LDTARGET)
.PHONY: clean .PHONY: clean
all: all: $(KERNEL)
$(KERNEL): boot.o
ld $(LDFLAGS) -o $@ $<
boot.o: boot.asm
nasm -f elf -o boot.o boot.asm nasm -f elf -o boot.o boot.asm
ld $(LDFLAGS) -o $(KERNEL) boot.o
clean: clean:
-rm -f *~ $(KERNEL) *.o -rm -f *~ $(KERNEL) *.o

View File

@ -3,9 +3,7 @@
%define MULTIBOOT_HEADER_FLAGS 0x3 %define MULTIBOOT_HEADER_FLAGS 0x3
[global start] [global start]
[global _start]
start: start:
_start:
jmp multiboot_entry jmp multiboot_entry
align 4 align 4

24
kernel/link.ld Normal file
View File

@ -0,0 +1,24 @@
ENTRY(start)
SECTIONS
{
.text 0x00100000 : {
code = .; _code = .; __code = .;
*(.text)
}
.gnulinkonce : {
*(.gnu.linkonce*)
. = ALIGN(4096);
}
.data : {
data = .; _data = .; __data = .;
*(.data)
*(.rodata)
. = ALIGN(4096);
}
.bss : {
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}