compiled newlib, need to hook up the system calls
This commit is contained in:
24
programs/crt0.S
Normal file
24
programs/crt0.S
Normal file
@@ -0,0 +1,24 @@
|
||||
.global _start
|
||||
.intel_syntax noprefix
|
||||
|
||||
.section .text
|
||||
_start:
|
||||
xor ebp, ebp
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
mov eax, [esp + 4]
|
||||
lea ebx, [esp + 8]
|
||||
lea ecx, [esp + 12]
|
||||
|
||||
push ecx
|
||||
push ebx
|
||||
push eax
|
||||
|
||||
call main
|
||||
|
||||
push eax
|
||||
call exit
|
||||
|
||||
1: hlt
|
||||
jmp 1b
|
||||
28
programs/crt0.s
Normal file
28
programs/crt0.s
Normal file
@@ -0,0 +1,28 @@
|
||||
# 0 "crt0.S"
|
||||
# 0 "<built-in>"
|
||||
# 0 "<command-line>"
|
||||
# 1 "crt0.S"
|
||||
.global _start
|
||||
.intel_syntax noprefix
|
||||
|
||||
.section .text
|
||||
_start:
|
||||
xor ebp, ebp
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
mov eax, [esp + 4]
|
||||
lea ebx, [esp + 8]
|
||||
lea ecx, [esp + 12]
|
||||
|
||||
push ecx
|
||||
push ebx
|
||||
push eax
|
||||
|
||||
call main
|
||||
|
||||
push eax
|
||||
call exit
|
||||
|
||||
1: hlt
|
||||
jmp 1b
|
||||
31
programs/linker.ld
Normal file
31
programs/linker.ld
Normal file
@@ -0,0 +1,31 @@
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x40000000;
|
||||
|
||||
.text ALIGN(4K) :
|
||||
{
|
||||
/* Force the crt0.o entry code to be placed FIRST in memory */
|
||||
KEEP(*crt0.o(.text))
|
||||
*(.text .text.*)
|
||||
}
|
||||
|
||||
.rodata ALIGN(4K) :
|
||||
{
|
||||
*(.rodata .rodata.*)
|
||||
}
|
||||
|
||||
.data ALIGN(4K) :
|
||||
{
|
||||
*(.data .data.*)
|
||||
}
|
||||
|
||||
.bss ALIGN(4K) :
|
||||
{
|
||||
_bss_start = .;
|
||||
*(.bss .bss.*)
|
||||
*(COMMON)
|
||||
_bss_end = .;
|
||||
}
|
||||
}
|
||||
8
programs/main.c
Normal file
8
programs/main.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
printf("Hello, World from RockOS!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,16 +1,23 @@
|
||||
CC = i686-elf-gcc
|
||||
LD = i686-elf-ld
|
||||
|
||||
CFLAGS := -ffreestanding -O2 -Wall -Wextra
|
||||
CFLAGS = -ffreestanding -O2 -Wall -Wextra -I../rocklibc/include
|
||||
LDFLAGS = -m elf_i386 -nostdlib
|
||||
|
||||
all: origin.elf
|
||||
TARGET = origin.elf
|
||||
|
||||
origin.o: origin.S
|
||||
$(CC) -c origin.S -o origin.o $(CFLAGS)
|
||||
all: $(TARGET)
|
||||
|
||||
origin.elf: origin.o
|
||||
$(LD) -Ttext 0x40000000 origin.o -o origin.elf
|
||||
mv origin.elf ../isodir/boot
|
||||
crt0.o: crt0.s
|
||||
$(CC) $(CFLAGS) -c crt0.s -o crt0.o
|
||||
|
||||
main.o: main.c
|
||||
$(CC) $(CFLAGS) -c main.c -o main.o
|
||||
|
||||
$(TARGET): crt0.o main.o ../rocklibc/rlibc.a
|
||||
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o ../rocklibc/rlibc.a $(shell $(CC) -print-libgcc-file-name) -o $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f origin.o origin.elf
|
||||
rm -f *.o $(TARGET)
|
||||
|
||||
.PHONY: all clean
|
||||
@@ -1,16 +0,0 @@
|
||||
.code32
|
||||
|
||||
.section .text
|
||||
.global _start
|
||||
_start:
|
||||
mov $1, %eax
|
||||
mov $(message), %ebx
|
||||
mov $0, %ecx
|
||||
mov $0, %edx
|
||||
int $0x80
|
||||
loop:
|
||||
jmp loop
|
||||
|
||||
.section .data
|
||||
message:
|
||||
.asciz "Hello, Userland!\n";
|
||||
Reference in New Issue
Block a user