Let's try to start parsing ELFs!
This commit is contained in:
parent
87f67b255e
commit
867d312177
4
.gitignore
vendored
4
.gitignore
vendored
@ -4,4 +4,6 @@ toolchain/
|
|||||||
**/*.o
|
**/*.o
|
||||||
initrd/boot/moon.elf
|
initrd/boot/moon.elf
|
||||||
kernel/bin/moon.elf
|
kernel/bin/moon.elf
|
||||||
initrd/sys/moon.sym
|
initrd/sys/moon.sym
|
||||||
|
initrd/bin/**
|
||||||
|
apps/bin/**
|
10
Makefile
10
Makefile
@ -1,10 +1,12 @@
|
|||||||
build: $(LUNA_ROOT)/kernel/bin/moon.elf
|
build: $(LUNA_ROOT)/kernel/bin/moon.elf apps-build
|
||||||
|
|
||||||
clean: moon-clean initrd-clean
|
clean: moon-clean initrd-clean apps-clean
|
||||||
|
|
||||||
initrd-clean:
|
initrd-clean:
|
||||||
rm -f $(LUNA_ROOT)/initrd/boot/moon.elf $(LUNA_ROOT)/Luna.iso
|
rm -f $(LUNA_ROOT)/initrd/boot/moon.elf $(LUNA_ROOT)/Luna.iso
|
||||||
|
rm -rf $(LUNA_ROOT)/initrd/bin
|
||||||
|
|
||||||
install: $(LUNA_ROOT)/initrd/boot/moon.elf
|
install: $(LUNA_ROOT)/initrd/boot/moon.elf apps-install
|
||||||
|
|
||||||
include kernel/Makefile
|
include kernel/Makefile
|
||||||
|
include apps/Makefile
|
31
apps/Makefile
Normal file
31
apps/Makefile
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
APPS := init
|
||||||
|
|
||||||
|
APPS_DIR := $(LUNA_ROOT)/apps
|
||||||
|
APPS_OBJ := $(APPS_DIR)/lib
|
||||||
|
APPS_BIN := $(APPS_DIR)/bin
|
||||||
|
|
||||||
|
REAL_APPS := $(patsubst %, $(APPS_BIN)/%, $(APPS))
|
||||||
|
|
||||||
|
ASMC := nasm
|
||||||
|
ASMFLAGS := -felf64
|
||||||
|
|
||||||
|
LD := x86_64-elf-ld
|
||||||
|
APP_LDFLAGS := -T$(APPS_DIR)/apps.ld -nostdlib
|
||||||
|
|
||||||
|
$(APPS_OBJ)/%.o: $(APPS_DIR)/%.asm
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
$(ASMC) $(ASMFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
$(APPS_BIN)/%: $(APPS_OBJ)/%.o
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
$(LD) $(APP_LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
apps-build: $(REAL_APPS)
|
||||||
|
|
||||||
|
apps-install: $(REAL_APPS)
|
||||||
|
@mkdir -p $(LUNA_ROOT)/initrd/bin
|
||||||
|
cp $(REAL_APPS) $(LUNA_ROOT)/initrd/bin
|
||||||
|
|
||||||
|
apps-clean:
|
||||||
|
rm -f $(APPS_OBJ)/*
|
||||||
|
rm -f $(APPS_BIN)/*
|
21
apps/apps.ld
Normal file
21
apps/apps.ld
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
ENTRY(_start)
|
||||||
|
OUTPUT_FORMAT(elf64-x86-64)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = 0x10000;
|
||||||
|
.text : ALIGN(16) {
|
||||||
|
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
||||||
|
*(.rodata .rodata.*) /* data */
|
||||||
|
}
|
||||||
|
.data : ALIGN(16) {
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
.bss (NOLOAD) : { /* bss */
|
||||||
|
. = ALIGN(16);
|
||||||
|
*(.bss .bss.*)
|
||||||
|
*(COMMON)
|
||||||
|
}
|
||||||
|
|
||||||
|
/DISCARD/ : { *(.eh_frame) *(.comment) }
|
||||||
|
}
|
5
apps/init.asm
Normal file
5
apps/init.asm
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
section .text
|
||||||
|
global _start
|
||||||
|
_start:
|
||||||
|
mov rax, 0
|
||||||
|
int 42h
|
Loading…
Reference in New Issue
Block a user