38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "builder.hpp"
|
|
#include "coff_reader.hpp"
|
|
#include "elf_reader.hpp"
|
|
#include "macho_reader.hpp"
|
|
|
|
#include <string>
|
|
#include <variant>
|
|
|
|
namespace voidlibc::voidlink {
|
|
|
|
struct LoweredText {
|
|
SectionSpec section; // code + relocs (portable IR)
|
|
std::vector<SymbolSpec> symbols; // unified: exports first, then imports
|
|
};
|
|
|
|
// Lower the .text section of an ELF .o into a portable VoidLibC
|
|
// SectionSpec + unified SymbolSpec list.
|
|
std::variant<LoweredText, std::string>
|
|
lower_elf_text(const elf::ParsedObject& obj,
|
|
voidlibc::format::TargetOS target_os);
|
|
|
|
// Lower a COFF .obj (x86-64 Windows) into portable VoidLibC representation.
|
|
// Handles IMAGE_REL_AMD64_REL32 / REL32_1..5 / ADDR64 and produces the same
|
|
// LoweredText as lower_elf_text() so that fuse / pack-elf work uniformly.
|
|
std::variant<LoweredText, std::string>
|
|
lower_coff_text(const coff::ParsedObject& obj,
|
|
voidlibc::format::TargetOS target_os);
|
|
|
|
// Lower a Mach-O .o (x86-64 macOS) into portable VoidLibC representation.
|
|
// Handles X86_64_RELOC_SIGNED / BRANCH / UNSIGNED / GOT_LOAD / SUBTRACTOR.
|
|
std::variant<LoweredText, std::string>
|
|
lower_macho_text(const macho::ParsedObject& obj,
|
|
voidlibc::format::TargetOS target_os);
|
|
|
|
} // namespace voidlibc::voidlink
|