1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00

ELF modules

This commit is contained in:
Alex Kotov 2020-11-25 16:00:24 +05:00
parent c9fc17fef2
commit 5700b59e72
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
7 changed files with 87 additions and 9 deletions

View file

@ -62,7 +62,7 @@ $(KERNEL): $(OBJS)
$(AS) $< -o $@
%.asm.cpp.o: %.asm.cpp
nasm -felf32 -o $@ $<
nasm -f elf32 -o $@ $<
%.asm.cpp: %.asm
cpp -P $< $@

View file

@ -1,7 +1,18 @@
CCPREFIX = i686-elf-
AR = $(CCPREFIX)ar
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
MEMGR = memgr
$(MEMGR): main.asm
nasm -f bin $< -o $@
all: $(MEMGR)
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
View 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)
}
}

View file

@ -1,4 +1,6 @@
main:
[GLOBAL _start]
_start:
xor eax, eax
xor ebx, ebx
int 0x80

View file

@ -1,7 +1,18 @@
CCPREFIX = i686-elf-
AR = $(CCPREFIX)ar
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
PROCMAN = procman
$(PROCMAN): main.asm
nasm -f bin $< -o $@
all: $(PROCMAN)
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
View 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)
}
}

View file

@ -1,4 +1,6 @@
main:
[GLOBAL _start]
_start:
xor eax, eax
xor ebx, ebx
int 0x80