mirror of
https://github.com/hmaxnl/based.git
synced 2025-01-18 01:14:21 +01:00
reworking runtime, updating project structure.
This commit is contained in:
parent
21f40e3083
commit
d262af06a6
|
@ -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)
|
2
LICENSE
2
LICENSE
|
@ -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
3
include/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Public include
|
||||
|
||||
add_subdirectory(based)
|
2
include/based/CMakeLists.txt
Normal file
2
include/based/CMakeLists.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Public based include
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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)
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -5,5 +5,5 @@ int rt_bootstrap(void)
|
|||
// Bootstraping => based.
|
||||
// Invoke main.
|
||||
// Return exit code to caller.
|
||||
return 420;
|
||||
return 0;
|
||||
}
|
|
@ -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.
|
|
@ -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
3
tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
# CMakeLists test directory
|
||||
|
||||
add_subdirectory(HelloWorld)
|
5
tests/HelloWorld/CMakeLists.txt
Normal file
5
tests/HelloWorld/CMakeLists.txt
Normal 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
9
tests/HelloWorld/main.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
//
|
||||
// Created by max on 20-11-23.
|
||||
//
|
||||
|
||||
int main()
|
||||
{
|
||||
//TODO: Print hello world!
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user