Hello user process
This commit is contained in:
1
user/.gitignore
vendored
Normal file
1
user/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
FILES.txt
|
14
user/Makefile
Normal file
14
user/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
APP_DIR := $(shell find . -mindepth 1 -maxdepth 1 -type d -not -path "./arch")
|
||||
|
||||
all:
|
||||
rm -f FILES.txt
|
||||
touch FILES.txt
|
||||
for dir in $(APP_DIR); do make -C $$dir FILES=$(CURRENT_DIR)/FILES.txt all; done
|
||||
|
||||
clean:
|
||||
for dir in $(APP_DIR); do make -C $$dir clean; done
|
||||
|
9
user/Makefile.inc
Normal file
9
user/Makefile.inc
Normal file
@ -0,0 +1,9 @@
|
||||
ARCH ?= x86_64
|
||||
|
||||
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc
|
||||
|
||||
CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
include $(CURRENT_DIR)/arch/$(ARCH)/$(ARCH).mk
|
||||
|
||||
LDFLAGS += -nostdlib -static $(shell $(CC) -print-libgcc-file-name) -T $(CURRENT_DIR)/arch/$(ARCH)/link.ld
|
26
user/arch/x86_64/link.ld
Normal file
26
user/arch/x86_64/link.ld
Normal file
@ -0,0 +1,26 @@
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS {
|
||||
/* . = 0xffff000000000000; */
|
||||
. = 0x0000000000000000;
|
||||
|
||||
.rodata ALIGN(4K):
|
||||
{
|
||||
*(.rodata .rodata.*)
|
||||
}
|
||||
|
||||
.text ALIGN(4K):
|
||||
{
|
||||
*(.text .text.*)
|
||||
}
|
||||
|
||||
.data ALIGN(4K):
|
||||
{
|
||||
*(.data .data.*)
|
||||
}
|
||||
|
||||
.bss ALIGN(4K):
|
||||
{
|
||||
*(.bss .bss.*)
|
||||
}
|
||||
}
|
22
user/arch/x86_64/x86_64.mk
Normal file
22
user/arch/x86_64/x86_64.mk
Normal file
@ -0,0 +1,22 @@
|
||||
CC := x86_64-elf-gcc
|
||||
LD := x86_64-elf-ld
|
||||
|
||||
CFLAGS += -m64 \
|
||||
-fPIE \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-sse \
|
||||
-nostartfiles \
|
||||
-nostdlib \
|
||||
-mno-sse2 \
|
||||
-mno-red-zone \
|
||||
-fno-stack-protector \
|
||||
-fno-stack-check \
|
||||
-Os \
|
||||
|
||||
LDFLAGS += -m elf_x86_64 \
|
||||
-pie \
|
||||
--no-dynamic-linker \
|
||||
-z text \
|
||||
-z max-page-size=0x1000
|
||||
|
2
user/hello/.gitignore
vendored
Normal file
2
user/hello/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.o
|
||||
hello
|
21
user/hello/Makefile
Normal file
21
user/hello/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
include ../Makefile.inc
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
TARGET := hello
|
||||
|
||||
SRCFILES := $(wildcard *.s)
|
||||
ASFILES := $(filter %.s,$(SRCFILES))
|
||||
OBJ := $(patsubst %.s,%.o,$(ASFILES))
|
||||
|
||||
%.o: %.s
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
hello: $(OBJ)
|
||||
$(LD) $^ $(LDFLAGS) -o $@
|
||||
echo "$(realpath $@)" >> $(FILES)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) $(TARGET)
|
6
user/hello/hello.s
Normal file
6
user/hello/hello.s
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
.spin:
|
||||
jmp .spin
|
||||
|
Reference in New Issue
Block a user