diff --git a/build.py b/build.py index 031ae15..2dcbb54 100755 --- a/build.py +++ b/build.py @@ -72,7 +72,7 @@ dependencies.append(args.compiler) includes = ['src/include'] cc = args.compiler cc_defines = [] -cc_flags = ['-nostdlib', '-fno-stack-protector', '-mno-sse'] +cc_flags = ['-nostdlib', '-fno-stack-protector'] crt_file = 'crt.lib' lib_file = 'cia.lib' dl_file = 'ld-cia.so' @@ -272,7 +272,7 @@ dl_lib = f'lib/{dl_file}' dl_flags = [ '-shared', '-nostdlib', - '-mno-sse', + # '-mno-sse', '-ffreestanding', '-fno-stack-protector', '-Wl,-e,_dlstart', @@ -292,7 +292,6 @@ if target == 'linux': print_step(f'Compiling {crt_file}\n') if target == 'linux': - # assemble('src/linux/crt-entry.asm', 'bin/crt-entry.o') compile(['src/linux/crt-ctors.c'], 'bin/crt-ctors.o', '-c') archive(['bin/crt-ctors.o'], crt_lib) elif target == 'windows': diff --git a/src/linux/entry.c b/src/linux/entry.c index fe63f79..b9dac28 100644 --- a/src/linux/entry.c +++ b/src/linux/entry.c @@ -14,7 +14,7 @@ void __stack_chk_fail(void) { extern int main(int argc, char **argv, char **envp); static void _fileapi_init(); -void _start() { +void _cia_start() { // Get the envp // char **envp = argv + (argc + 1); // init(argc, argv, envp); diff --git a/src/loader/loader-entry.asm b/src/loader/loader-entry.asm index 24cd490..9759162 100644 --- a/src/loader/loader-entry.asm +++ b/src/loader/loader-entry.asm @@ -11,3 +11,8 @@ _dlstart: mov rdi, rsp lea rsi, _DYNAMIC and rsp, -16 + ; `call` pushes 8-byte value onto the stack + ; by pushing an 8-bit value ourselves we can make + ; sure the stack is aligned after rbp push in prologue + sub rsp, 8 +