[libc-commits] [libc] [libc] Add barebones dl_iterate_phdr implementation (PR #194196)
Jeff Bailey via libc-commits
libc-commits at lists.llvm.org
Fri May 8 23:46:37 PDT 2026
================
@@ -9,56 +9,54 @@
#include "dl_iterate_phdr.h"
#include "llvm-libc-macros/link-macros.h"
+#include "src/__support/CPP/span.h"
#include "src/__support/OSUtil/linux/auxv.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include <elf.h>
-extern "C" void *__executable_start;
+extern "C" void *__ehdr_start;
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, dl_iterate_phdr,
- (__dl_iterate_phdr_callback_t callback, void *arg)) {
- ElfW(Ehdr) *executable_header =
- reinterpret_cast<ElfW(Ehdr) *>(&__executable_start);
- struct dl_phdr_info executable_info;
- executable_info.dlpi_addr = 0;
- executable_info.dlpi_name = nullptr;
- executable_info.dlpi_phdr = reinterpret_cast<ElfW(Phdr) *>(
+struct dl_phdr_info create_executable_info(ElfW(Ehdr) * executable_header) {
----------------
kaladron wrote:
Can you please add a `// TODO: Calculate dlpi_addr for PIE and set dlpi_name for vDSO`? That will give future readers some leading hints on where to start.
https://github.com/llvm/llvm-project/pull/194196
More information about the libc-commits
mailing list