commit
bba5c8a39a
109 files changed
+14085
No files matched your search
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include "format/reloc_ir.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace voidlibc::loader::macos {
|
||||
|
||||
struct MachoExportedSymbol {
|
||||
std::string name;
|
||||
std::uint64_t code_offset = 0;
|
||||
std::uint64_t size = 0;
|
||||
bool is_function = true;
|
||||
bool weak = false;
|
||||
};
|
||||
|
||||
struct MachoImportedSymbol {
|
||||
std::uint32_t sym_id = 0;
|
||||
std::string name;
|
||||
std::string library; // dylib install name; "" → /usr/lib/libSystem.B.dylib
|
||||
};
|
||||
|
||||
struct MachoInternalSymbol {
|
||||
std::uint32_t sym_id = 0;
|
||||
std::uint64_t code_offset = 0;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct MachoDataSymbol {
|
||||
std::uint32_t sym_id = 0;
|
||||
std::uint64_t data_offset = 0;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct MachoSynthInput {
|
||||
std::vector<std::uint8_t> code;
|
||||
std::vector<MachoExportedSymbol> exports;
|
||||
std::vector<voidlibc::format::RelocEntry> relocs;
|
||||
std::vector<MachoInternalSymbol> internal_symbols;
|
||||
std::vector<MachoImportedSymbol> imports;
|
||||
std::vector<std::uint8_t> data_blob;
|
||||
std::vector<MachoDataSymbol> data_symbols;
|
||||
std::string soname;
|
||||
// Explicit LC_LOAD_DYLIB entries. Empty + imports present → defaults to
|
||||
// /usr/lib/libSystem.B.dylib. Empty + no imports → static (no NEEDED).
|
||||
std::vector<std::string> needed_libs;
|
||||
};
|
||||
|
||||
struct MachoSynthOutput {
|
||||
std::vector<std::uint8_t> bytes;
|
||||
std::string error;
|
||||
bool ok = true;
|
||||
};
|
||||
|
||||
// Produce a minimal Mach-O64 dylib (MH_DYLIB, x86_64) that dlopen will accept.
|
||||
// Layout: __TEXT (header+LCs+code+stubs) / __DATA (data+nl_symbol_ptr) / __LINKEDIT.
|
||||
// Non-lazy binding via LC_DYLD_INFO_ONLY bind opcodes; no lazy stubs.
|
||||
MachoSynthOutput synthesize_macho(const MachoSynthInput& input);
|
||||
|
||||
} // namespace voidlibc::loader::macos
|
||||
Reference in new issue
Block a user