26 lines
777 B
C++
26 lines
777 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace voidlibc::loader::linux_handoff {
|
|
|
|
struct LoadResult {
|
|
void* dl_handle = nullptr; // opaque handle from dlopen
|
|
std::string error; // empty on success
|
|
bool ok = false;
|
|
};
|
|
|
|
// Take a synthesized ELF DSO buffer, place it in a memfd (or fallback
|
|
// temp file), and dlopen it. Returns the raw dlopen handle. Callers
|
|
// own it and must dlclose() it.
|
|
LoadResult dlopen_buffer(const std::vector<std::uint8_t>& elf_bytes,
|
|
const char* debug_name = "voidlibc.elf");
|
|
|
|
// Thin wrappers so the caller never includes <dlfcn.h>.
|
|
void* sym(void* handle, const char* name);
|
|
int close_(void* handle);
|
|
|
|
} // namespace voidlibc::loader::linux_handoff
|