diff options
author | Schrodinger ZHU Yifan <yifanzhu@rochester.edu> | 2023-12-18 15:27:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-18 12:27:30 -0800 |
commit | 6c1f56fdb51d0a7d5be13289e8b5f5a7bea40cf8 (patch) | |
tree | b85d1b6f977e546ecd6d1e143bed7b16b1b052a1 /libc/startup | |
parent | 927926b8af4fd6ab966b95d7b6eb31790758ced1 (diff) | |
download | llvm-6c1f56fdb51d0a7d5be13289e8b5f5a7bea40cf8.zip llvm-6c1f56fdb51d0a7d5be13289e8b5f5a7bea40cf8.tar.gz llvm-6c1f56fdb51d0a7d5be13289e8b5f5a7bea40cf8.tar.bz2 |
[libc] expose aux vector (#75806)
This patch lifts aux vector related definitions to app.h. Because
startup's refactoring is in progress, this patch still contains
duplicated changes. This problem will be addressed very soon in an
incoming patch.
Diffstat (limited to 'libc/startup')
-rw-r--r-- | libc/startup/linux/aarch64/start.cpp | 13 | ||||
-rw-r--r-- | libc/startup/linux/riscv/start.cpp | 13 | ||||
-rw-r--r-- | libc/startup/linux/x86_64/start.cpp | 13 |
3 files changed, 12 insertions, 27 deletions
diff --git a/libc/startup/linux/aarch64/start.cpp b/libc/startup/linux/aarch64/start.cpp index c3e20eb..bc01582 100644 --- a/libc/startup/linux/aarch64/start.cpp +++ b/libc/startup/linux/aarch64/start.cpp @@ -126,12 +126,7 @@ static void call_fini_array_callbacks() { } // namespace LIBC_NAMESPACE using LIBC_NAMESPACE::app; - -// TODO: Would be nice to use the aux entry structure from elf.h when available. -struct AuxEntry { - uint64_t type; - uint64_t value; -}; +using LIBC_NAMESPACE::AuxEntry; __attribute__((noinline)) static void do_start() { auto tid = LIBC_NAMESPACE::syscall_impl<long>(SYS_gettid); @@ -155,9 +150,9 @@ __attribute__((noinline)) static void do_start() { // denoted by an AT_NULL entry. Elf64_Phdr *program_hdr_table = nullptr; uintptr_t program_hdr_count; - for (AuxEntry *aux_entry = reinterpret_cast<AuxEntry *>(env_end_marker + 1); - aux_entry->type != AT_NULL; ++aux_entry) { - switch (aux_entry->type) { + app.auxv_ptr = reinterpret_cast<AuxEntry *>(env_end_marker + 1); + for (auto *aux_entry = app.auxv_ptr; aux_entry->id != AT_NULL; ++aux_entry) { + switch (aux_entry->id) { case AT_PHDR: program_hdr_table = reinterpret_cast<Elf64_Phdr *>(aux_entry->value); break; diff --git a/libc/startup/linux/riscv/start.cpp b/libc/startup/linux/riscv/start.cpp index 4d37662..5b6e5bd 100644 --- a/libc/startup/linux/riscv/start.cpp +++ b/libc/startup/linux/riscv/start.cpp @@ -115,12 +115,7 @@ static void call_fini_array_callbacks() { } // namespace LIBC_NAMESPACE using LIBC_NAMESPACE::app; - -// TODO: Would be nice to use the aux entry structure from elf.h when available. -struct AuxEntry { - LIBC_NAMESPACE::AuxEntryType type; - LIBC_NAMESPACE::AuxEntryType value; -}; +using LIBC_NAMESPACE::AuxEntry; #if defined(LIBC_TARGET_ARCH_IS_X86_64) || \ defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ @@ -158,9 +153,9 @@ __attribute__((noinline)) static void do_start() { // denoted by an AT_NULL entry. PgrHdrTableType *program_hdr_table = nullptr; uintptr_t program_hdr_count; - for (AuxEntry *aux_entry = reinterpret_cast<AuxEntry *>(env_end_marker + 1); - aux_entry->type != AT_NULL; ++aux_entry) { - switch (aux_entry->type) { + app.auxv_ptr = reinterpret_cast<AuxEntry *>(env_end_marker + 1); + for (auto *aux_entry = app.auxv_ptr; aux_entry->id != AT_NULL; ++aux_entry) { + switch (aux_entry->id) { case AT_PHDR: program_hdr_table = reinterpret_cast<PgrHdrTableType *>(aux_entry->value); break; diff --git a/libc/startup/linux/x86_64/start.cpp b/libc/startup/linux/x86_64/start.cpp index 496105d..c98f58a 100644 --- a/libc/startup/linux/x86_64/start.cpp +++ b/libc/startup/linux/x86_64/start.cpp @@ -144,12 +144,7 @@ static void call_fini_array_callbacks() { } // namespace LIBC_NAMESPACE using LIBC_NAMESPACE::app; - -// TODO: Would be nice to use the aux entry structure from elf.h when available. -struct AuxEntry { - uint64_t type; - uint64_t value; -}; +using LIBC_NAMESPACE::AuxEntry; extern "C" void _start() { // This TU is compiled with -fno-omit-frame-pointer. Hence, the previous value @@ -193,9 +188,9 @@ extern "C" void _start() { // denoted by an AT_NULL entry. Elf64_Phdr *program_hdr_table = nullptr; uintptr_t program_hdr_count = 0; - for (AuxEntry *aux_entry = reinterpret_cast<AuxEntry *>(env_end_marker + 1); - aux_entry->type != AT_NULL; ++aux_entry) { - switch (aux_entry->type) { + app.auxv_ptr = reinterpret_cast<AuxEntry *>(env_end_marker + 1); + for (auto *aux_entry = app.auxv_ptr; aux_entry->id != AT_NULL; ++aux_entry) { + switch (aux_entry->id) { case AT_PHDR: program_hdr_table = reinterpret_cast<Elf64_Phdr *>(aux_entry->value); break; |