From f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:52 -0500 Subject: build: Build mlibc + add distclean target Signed-off-by: Ian Moffett --- lib/mlibc/options/elf/generic/phdr.cpp | 10 ----- lib/mlibc/options/elf/generic/startup.cpp | 73 ------------------------------- 2 files changed, 83 deletions(-) delete mode 100644 lib/mlibc/options/elf/generic/phdr.cpp delete mode 100644 lib/mlibc/options/elf/generic/startup.cpp (limited to 'lib/mlibc/options/elf/generic') diff --git a/lib/mlibc/options/elf/generic/phdr.cpp b/lib/mlibc/options/elf/generic/phdr.cpp deleted file mode 100644 index 334d52c..0000000 --- a/lib/mlibc/options/elf/generic/phdr.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include - -#include -#include - -extern "C" int __dlapi_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void *); - -int dl_iterate_phdr(int (*callback)(struct dl_phdr_info*, size_t, void*), void *data) { - return __dlapi_iterate_phdr(callback, data); -} diff --git a/lib/mlibc/options/elf/generic/startup.cpp b/lib/mlibc/options/elf/generic/startup.cpp deleted file mode 100644 index d53881b..0000000 --- a/lib/mlibc/options/elf/generic/startup.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include - -extern "C" size_t __init_array_start[]; -extern "C" size_t __init_array_end[]; -extern "C" size_t __preinit_array_start[]; -extern "C" size_t __preinit_array_end[]; - -static int constructors_ran_already = 0; - -struct global_constructor_guard { - global_constructor_guard() { - constructors_ran_already = 1; - } -}; - -static global_constructor_guard g; - -void __mlibc_run_constructors() { -/* - if (!constructors_ran_already) { - size_t constructor_count = (size_t)__init_array_end - (size_t)__init_array_start; - constructor_count /= sizeof(void*); - for (size_t i = 0; i < constructor_count; i++) { - void (*ptr)(void) = (void(*)(void))(__init_array_start[i]); - ptr(); - } - } -*/ -} - -namespace mlibc { - -void parse_exec_stack(void *opaque_sp, exec_stack_data *data) { - auto sp = reinterpret_cast(opaque_sp); - data->argc = *sp++; - data->argv = reinterpret_cast(sp); - sp += data->argc; // Skip all arguments. - __ensure(!*sp); // Skip the terminating null element. - sp++; - data->envp = reinterpret_cast(sp); -} - -// TODO: This does not have to be here; we could also move it to options/internal. -void set_startup_data(int argc, char **argv, char **envp) { - if(argc) { - program_invocation_name = argv[0]; - - if(auto slash = strrchr(argv[0], '/'); slash) { - program_invocation_short_name = slash + 1; - }else{ - program_invocation_short_name = argv[0]; - } - } - - // Initialize environ. - // TODO: Copy the arguments instead of pointing to them? - auto ev = envp; - while(*ev) { - auto fail = mlibc::putenv(*ev); - __ensure(!fail); - ev++; - } -} - -} // namespace mlibc - -- cgit v1.2.3