reworking runtime, updating project structure.

This commit is contained in:
Max 2023-11-20 02:50:12 +01:00
parent 21f40e3083
commit d262af06a6
14 changed files with 44 additions and 14 deletions

View File

@ -54,7 +54,10 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/bin)
add_subdirectory(src)
add_subdirectory(include)
add_subdirectory(tests)
if (DOCUMENTATION)
add_subdirectory(doc)
endif(DOCUMENTATION)
add_subdirectory(src)
add_subdirectory(doc)
endif(DOCUMENTATION)

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Max
Copyright (c) 2023
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

3
include/CMakeLists.txt Normal file
View File

@ -0,0 +1,3 @@
# Public include
add_subdirectory(based)

View File

@ -0,0 +1,2 @@
# Public based include

View File

@ -3,6 +3,7 @@
add_library(based SHARED "base.c")
target_compile_features(based PRIVATE c_std_99)
target_link_libraries(based PUBLIC runtime)
target_include_directories(based
PUBLIC

View File

@ -1,5 +1,5 @@
# cli project
add_executable(basedcli "main.c")
add_executable(bcli "main.c")
target_link_libraries(basedcli runtime)
target_link_libraries(bcli PUBLIC based)

View File

@ -4,7 +4,7 @@ add_library(runtime STATIC
"rtinternal.h"
"runtime.c")
target_link_libraries(runtime PUBLIC based)
#target_link_libraries(runtime PUBLIC based)
target_include_directories(runtime
PUBLIC

View File

@ -1,3 +1,3 @@
#include "base.h"
//#include "base.h"
extern int main(int argc, BYTE** argv, BYTE** envp);
extern int main(int argc, char** argv, char** envp);

View File

@ -5,5 +5,5 @@ int rt_bootstrap(void)
// Bootstraping => based.
// Invoke main.
// Return exit code to caller.
return 420;
return 0;
}

View File

@ -9,9 +9,13 @@
_start:
xor %rbp, %rbp // Clear stack frame pointer
mov (%rsp), %rdi // Movq argc to rdi
mov (%rsp), %rdi // Mov argc to rdi
lea 0x8(%rsp), %rsi // Get the argv address
lea 16(%rsp,%rdi,8), %rdx // Get the envp address
call rt_unix_start // Start c function
//call rt_unix_start // Start c function
// Use exit_group syscall
movq $231, %rax
movq $0, %rdi
syscall
hlt // Halt if the lib or app does not call the exit function.

View File

@ -1,6 +1,6 @@
#include "base.h"
//#include "base.h"
void rt_unix_start(int argc, BYTE** argv, BYTE** envp)
void rt_unix_start(int argc, char** argv, char** envp)
{
//TODO: Callback => main & syscall to exit group
}

3
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,3 @@
# CMakeLists test directory
add_subdirectory(HelloWorld)

View File

@ -0,0 +1,5 @@
# Hello World! test
add_executable(hello "main.c")
target_link_libraries(hello PUBLIC based)

9
tests/HelloWorld/main.c Normal file
View File

@ -0,0 +1,9 @@
//
// Created by max on 20-11-23.
//
int main()
{
//TODO: Print hello world!
return 0;
}