mirror of
https://github.com/tailix/kernel.git
synced 2025-09-04 22:42:59 -04:00
ELF modules
This commit is contained in:
parent
c9fc17fef2
commit
5700b59e72
7 changed files with 87 additions and 9 deletions
|
@ -62,7 +62,7 @@ $(KERNEL): $(OBJS)
|
||||||
$(AS) $< -o $@
|
$(AS) $< -o $@
|
||||||
|
|
||||||
%.asm.cpp.o: %.asm.cpp
|
%.asm.cpp.o: %.asm.cpp
|
||||||
nasm -felf32 -o $@ $<
|
nasm -f elf32 -o $@ $<
|
||||||
|
|
||||||
%.asm.cpp: %.asm
|
%.asm.cpp: %.asm
|
||||||
cpp -P $< $@
|
cpp -P $< $@
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
|
CCPREFIX = i686-elf-
|
||||||
|
|
||||||
|
AR = $(CCPREFIX)ar
|
||||||
|
AS = $(CCPREFIX)as
|
||||||
|
CC = $(CCPREFIX)gcc
|
||||||
|
|
||||||
MEMGR = memgr
|
MEMGR = memgr
|
||||||
|
|
||||||
$(MEMGR): main.asm
|
all: $(MEMGR)
|
||||||
nasm -f bin $< -o $@
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(MEMGR)
|
rm -f $(MEMGR) main.o
|
||||||
|
|
||||||
|
$(MEMGR): main.o
|
||||||
|
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^
|
||||||
|
|
||||||
|
main.o: main.asm
|
||||||
|
nasm -f elf32 $< -o $@
|
||||||
|
|
26
memgr/linker.ld
Normal file
26
memgr/linker.ld
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
OUTPUT_ARCH("i386")
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text BLOCK(4K) : ALIGN(4K)
|
||||||
|
{
|
||||||
|
*(.text)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata BLOCK(4K) : ALIGN(4K)
|
||||||
|
{
|
||||||
|
*(.rodata)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data BLOCK(4K) : ALIGN(4K)
|
||||||
|
{
|
||||||
|
*(.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss BLOCK(4K) : ALIGN(4K)
|
||||||
|
{
|
||||||
|
*(COMMON)
|
||||||
|
*(.bss)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
main:
|
[GLOBAL _start]
|
||||||
|
|
||||||
|
_start:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
int 0x80
|
int 0x80
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
|
CCPREFIX = i686-elf-
|
||||||
|
|
||||||
|
AR = $(CCPREFIX)ar
|
||||||
|
AS = $(CCPREFIX)as
|
||||||
|
CC = $(CCPREFIX)gcc
|
||||||
|
|
||||||
PROCMAN = procman
|
PROCMAN = procman
|
||||||
|
|
||||||
$(PROCMAN): main.asm
|
all: $(PROCMAN)
|
||||||
nasm -f bin $< -o $@
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(PROCMAN)
|
rm -f $(PROCMAN) main.o
|
||||||
|
|
||||||
|
$(PROCMAN): main.o
|
||||||
|
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^
|
||||||
|
|
||||||
|
main.o: main.asm
|
||||||
|
nasm -f elf32 $< -o $@
|
||||||
|
|
26
procman/linker.ld
Normal file
26
procman/linker.ld
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
OUTPUT_ARCH("i386")
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text BLOCK(4K) : ALIGN(4K)
|
||||||
|
{
|
||||||
|
*(.text)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata BLOCK(4K) : ALIGN(4K)
|
||||||
|
{
|
||||||
|
*(.rodata)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data BLOCK(4K) : ALIGN(4K)
|
||||||
|
{
|
||||||
|
*(.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss BLOCK(4K) : ALIGN(4K)
|
||||||
|
{
|
||||||
|
*(COMMON)
|
||||||
|
*(.bss)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
main:
|
[GLOBAL _start]
|
||||||
|
|
||||||
|
_start:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
int 0x80
|
int 0x80
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue