// Generated by Lisette bindgen
// Source: debug/macho (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.20

import "go:debug/dwarf"
import "go:encoding/binary"
import "go:io"

pub enum Cpu: uint32 {
  Cpu386 = 7,
  CpuAmd64 = 16777223,
  CpuArm = 12,
  CpuArm64 = 16777228,
  CpuPpc = 18,
  CpuPpc64 = 16777234,
}

pub const Cpu386: Cpu = 7

pub const CpuAmd64: Cpu = 16777223

pub const CpuArm: Cpu = 12

pub const CpuArm64: Cpu = 16777228

pub const CpuPpc: Cpu = 18

pub const CpuPpc64: Cpu = 16777234

pub enum LoadCmd: uint32 {
  LoadCmdDylib = 0xc,
  LoadCmdDylinker = 0xf,
  LoadCmdDysymtab = 0xb,
  LoadCmdRpath = 0x8000001c,
  LoadCmdSegment = 0x1,
  LoadCmdSegment64 = 0x19,
  LoadCmdSymtab = 0x2,
  LoadCmdThread = 0x4,
  LoadCmdUnixThread = 0x5,
}

pub const LoadCmdDylib: LoadCmd = 0xc

pub const LoadCmdDylinker: LoadCmd = 0xf

pub const LoadCmdDysymtab: LoadCmd = 0xb

pub const LoadCmdRpath: LoadCmd = 0x8000001c

pub const LoadCmdSegment: LoadCmd = 0x1

pub const LoadCmdSegment64: LoadCmd = 0x19

pub const LoadCmdSymtab: LoadCmd = 0x2

pub const LoadCmdThread: LoadCmd = 0x4

pub const LoadCmdUnixThread: LoadCmd = 0x5

pub enum RelocTypeARM: int {
  ARM_RELOC_BR24 = 5,
  ARM_RELOC_HALF = 8,
  ARM_RELOC_HALF_SECTDIFF = 9,
  ARM_RELOC_LOCAL_SECTDIFF = 3,
  ARM_RELOC_PAIR = 1,
  ARM_RELOC_PB_LA_PTR = 4,
  ARM_RELOC_SECTDIFF = 2,
  ARM_RELOC_VANILLA = 0,
  ARM_THUMB_32BIT_BRANCH = 7,
  ARM_THUMB_RELOC_BR22 = 6,
}

pub const ARM_RELOC_BR24: RelocTypeARM = 5

pub const ARM_RELOC_HALF: RelocTypeARM = 8

pub const ARM_RELOC_HALF_SECTDIFF: RelocTypeARM = 9

pub const ARM_RELOC_LOCAL_SECTDIFF: RelocTypeARM = 3

pub const ARM_RELOC_PAIR: RelocTypeARM = 1

pub const ARM_RELOC_PB_LA_PTR: RelocTypeARM = 4

pub const ARM_RELOC_SECTDIFF: RelocTypeARM = 2

pub const ARM_RELOC_VANILLA: RelocTypeARM = 0

pub const ARM_THUMB_32BIT_BRANCH: RelocTypeARM = 7

pub const ARM_THUMB_RELOC_BR22: RelocTypeARM = 6

pub enum RelocTypeARM64: int {
  ARM64_RELOC_ADDEND = 10,
  ARM64_RELOC_BRANCH26 = 2,
  ARM64_RELOC_GOT_LOAD_PAGE21 = 5,
  ARM64_RELOC_GOT_LOAD_PAGEOFF12 = 6,
  ARM64_RELOC_PAGE21 = 3,
  ARM64_RELOC_PAGEOFF12 = 4,
  ARM64_RELOC_POINTER_TO_GOT = 7,
  ARM64_RELOC_SUBTRACTOR = 1,
  ARM64_RELOC_TLVP_LOAD_PAGE21 = 8,
  ARM64_RELOC_TLVP_LOAD_PAGEOFF12 = 9,
  ARM64_RELOC_UNSIGNED = 0,
}

pub const ARM64_RELOC_ADDEND: RelocTypeARM64 = 10

pub const ARM64_RELOC_BRANCH26: RelocTypeARM64 = 2

pub const ARM64_RELOC_GOT_LOAD_PAGE21: RelocTypeARM64 = 5

pub const ARM64_RELOC_GOT_LOAD_PAGEOFF12: RelocTypeARM64 = 6

pub const ARM64_RELOC_PAGE21: RelocTypeARM64 = 3

pub const ARM64_RELOC_PAGEOFF12: RelocTypeARM64 = 4

pub const ARM64_RELOC_POINTER_TO_GOT: RelocTypeARM64 = 7

pub const ARM64_RELOC_SUBTRACTOR: RelocTypeARM64 = 1

pub const ARM64_RELOC_TLVP_LOAD_PAGE21: RelocTypeARM64 = 8

pub const ARM64_RELOC_TLVP_LOAD_PAGEOFF12: RelocTypeARM64 = 9

pub const ARM64_RELOC_UNSIGNED: RelocTypeARM64 = 0

pub enum RelocTypeGeneric: int {
  GENERIC_RELOC_LOCAL_SECTDIFF = 4,
  GENERIC_RELOC_PAIR = 1,
  GENERIC_RELOC_PB_LA_PTR = 3,
  GENERIC_RELOC_SECTDIFF = 2,
  GENERIC_RELOC_TLV = 5,
  GENERIC_RELOC_VANILLA = 0,
}

pub const GENERIC_RELOC_LOCAL_SECTDIFF: RelocTypeGeneric = 4

pub const GENERIC_RELOC_PAIR: RelocTypeGeneric = 1

pub const GENERIC_RELOC_PB_LA_PTR: RelocTypeGeneric = 3

pub const GENERIC_RELOC_SECTDIFF: RelocTypeGeneric = 2

pub const GENERIC_RELOC_TLV: RelocTypeGeneric = 5

pub const GENERIC_RELOC_VANILLA: RelocTypeGeneric = 0

pub enum RelocTypeX86_64: int {
  X86_64_RELOC_BRANCH = 2,
  X86_64_RELOC_GOT = 4,
  X86_64_RELOC_GOT_LOAD = 3,
  X86_64_RELOC_SIGNED = 1,
  X86_64_RELOC_SIGNED_1 = 6,
  X86_64_RELOC_SIGNED_2 = 7,
  X86_64_RELOC_SIGNED_4 = 8,
  X86_64_RELOC_SUBTRACTOR = 5,
  X86_64_RELOC_TLV = 9,
  X86_64_RELOC_UNSIGNED = 0,
}

pub const X86_64_RELOC_BRANCH: RelocTypeX86_64 = 2

pub const X86_64_RELOC_GOT: RelocTypeX86_64 = 4

pub const X86_64_RELOC_GOT_LOAD: RelocTypeX86_64 = 3

pub const X86_64_RELOC_SIGNED: RelocTypeX86_64 = 1

pub const X86_64_RELOC_SIGNED_1: RelocTypeX86_64 = 6

pub const X86_64_RELOC_SIGNED_2: RelocTypeX86_64 = 7

pub const X86_64_RELOC_SIGNED_4: RelocTypeX86_64 = 8

pub const X86_64_RELOC_SUBTRACTOR: RelocTypeX86_64 = 5

pub const X86_64_RELOC_TLV: RelocTypeX86_64 = 9

pub const X86_64_RELOC_UNSIGNED: RelocTypeX86_64 = 0

pub fn NewFatFile(r: io.ReaderAt) -> Result<Ref<FatFile>, error>

pub fn NewFile(r: io.ReaderAt) -> Result<Ref<File>, error>

pub fn Open(name: string) -> Result<Ref<File>, error>

pub fn OpenFat(name: string) -> Result<Ref<FatFile>, error>

/// A Dylib represents a Mach-O load dynamic library command.
pub struct Dylib {
  pub LoadBytes: LoadBytes,
  pub Name: string,
  pub Time: uint32,
  pub CurrentVersion: uint32,
  pub CompatVersion: uint32,
}

/// A DylibCmd is a Mach-O load dynamic library command.
pub struct DylibCmd {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Name: uint32,
  pub Time: uint32,
  pub CurrentVersion: uint32,
  pub CompatVersion: uint32,
}

/// A Dysymtab represents a Mach-O dynamic symbol table command.
pub struct Dysymtab {
  pub LoadBytes: LoadBytes,
  pub DysymtabCmd: DysymtabCmd,
  pub IndirectSyms: Slice<uint32>,
}

/// A DysymtabCmd is a Mach-O dynamic symbol table command.
pub struct DysymtabCmd {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Ilocalsym: uint32,
  pub Nlocalsym: uint32,
  pub Iextdefsym: uint32,
  pub Nextdefsym: uint32,
  pub Iundefsym: uint32,
  pub Nundefsym: uint32,
  pub Tocoffset: uint32,
  pub Ntoc: uint32,
  pub Modtaboff: uint32,
  pub Nmodtab: uint32,
  pub Extrefsymoff: uint32,
  pub Nextrefsyms: uint32,
  pub Indirectsymoff: uint32,
  pub Nindirectsyms: uint32,
  pub Extreloff: uint32,
  pub Nextrel: uint32,
  pub Locreloff: uint32,
  pub Nlocrel: uint32,
}

/// A FatArch is a Mach-O File inside a FatFile.
pub struct FatArch {
  pub FatArchHeader: FatArchHeader,
  pub File: Option<Ref<File>>,
}

/// A FatArchHeader represents a fat header for a specific image architecture.
pub struct FatArchHeader {
  pub Cpu: Cpu,
  pub SubCpu: uint32,
  pub Offset: uint32,
  pub Size: uint32,
  pub Align: uint32,
}

/// A FatFile is a Mach-O universal binary that contains at least one architecture.
pub struct FatFile {
  pub Magic: uint32,
  pub Arches: Slice<FatArch>,
}

/// A File represents an open Mach-O file.
pub struct File {
  pub FileHeader: FileHeader,
  pub ByteOrder: Option<binary.ByteOrder>,
  pub Loads: Slice<Option<Load>>,
  pub Sections: Slice<Option<Ref<Section>>>,
  pub Symtab: Option<Ref<Symtab>>,
  pub Dysymtab: Option<Ref<Dysymtab>>,
}

/// A FileHeader represents a Mach-O file header.
pub struct FileHeader {
  pub Magic: uint32,
  pub Cpu: Cpu,
  pub SubCpu: uint32,
  pub Type: Type,
  pub Ncmd: uint32,
  pub Cmdsz: uint32,
  pub Flags: uint32,
}

/// FormatError is returned by some operations if the data does
/// not have the correct format for an object file.
pub type FormatError

/// A Load represents any Mach-O load command.
pub interface Load {
  fn Raw() -> Slice<uint8>
}

/// A LoadBytes is the uninterpreted bytes of a Mach-O load command.
pub struct LoadBytes(Slice<uint8>)

/// An Nlist32 is a Mach-O 32-bit symbol table entry.
pub struct Nlist32 {
  pub Name: uint32,
  pub Type: uint8,
  pub Sect: uint8,
  pub Desc: uint16,
  pub Value: uint32,
}

/// An Nlist64 is a Mach-O 64-bit symbol table entry.
pub struct Nlist64 {
  pub Name: uint32,
  pub Type: uint8,
  pub Sect: uint8,
  pub Desc: uint16,
  pub Value: uint64,
}

/// Regs386 is the Mach-O 386 register structure.
pub struct Regs386 {
  pub AX: uint32,
  pub BX: uint32,
  pub CX: uint32,
  pub DX: uint32,
  pub DI: uint32,
  pub SI: uint32,
  pub BP: uint32,
  pub SP: uint32,
  pub SS: uint32,
  pub FLAGS: uint32,
  pub IP: uint32,
  pub CS: uint32,
  pub DS: uint32,
  pub ES: uint32,
  pub FS: uint32,
  pub GS: uint32,
}

/// RegsAMD64 is the Mach-O AMD64 register structure.
pub struct RegsAMD64 {
  pub AX: uint64,
  pub BX: uint64,
  pub CX: uint64,
  pub DX: uint64,
  pub DI: uint64,
  pub SI: uint64,
  pub BP: uint64,
  pub SP: uint64,
  pub R8: uint64,
  pub R9: uint64,
  pub R10: uint64,
  pub R11: uint64,
  pub R12: uint64,
  pub R13: uint64,
  pub R14: uint64,
  pub R15: uint64,
  pub IP: uint64,
  pub FLAGS: uint64,
  pub CS: uint64,
  pub FS: uint64,
  pub GS: uint64,
}

/// A Reloc represents a Mach-O relocation.
pub struct Reloc {
  pub Addr: uint32,
  pub Value: uint32,
  pub Type: uint8,
  pub Len: uint8,
  pub Pcrel: bool,
  pub Extern: bool,
  pub Scattered: bool,
}

/// A Rpath represents a Mach-O rpath command.
pub struct Rpath {
  pub LoadBytes: LoadBytes,
  pub Path: string,
}

/// A RpathCmd is a Mach-O rpath command.
pub struct RpathCmd {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Path: uint32,
}

pub struct Section {
  pub SectionHeader: SectionHeader,
  pub Relocs: Slice<Reloc>,
  pub ReaderAt: Option<io.ReaderAt>,
}

/// A Section32 is a 32-bit Mach-O section header.
pub struct Section32 {
  // SKIPPED field "Name": array-currently-not-representable — fixed-size array cannot currently be represented in Lisette
  // SKIPPED field "Seg": array-currently-not-representable — fixed-size array cannot currently be represented in Lisette
  pub Addr: uint32,
  pub Size: uint32,
  pub Offset: uint32,
  pub Align: uint32,
  pub Reloff: uint32,
  pub Nreloc: uint32,
  pub Flags: uint32,
  pub Reserve1: uint32,
  pub Reserve2: uint32,
}

/// A Section64 is a 64-bit Mach-O section header.
pub struct Section64 {
  // SKIPPED field "Name": array-currently-not-representable — fixed-size array cannot currently be represented in Lisette
  // SKIPPED field "Seg": array-currently-not-representable — fixed-size array cannot currently be represented in Lisette
  pub Addr: uint64,
  pub Size: uint64,
  pub Offset: uint32,
  pub Align: uint32,
  pub Reloff: uint32,
  pub Nreloc: uint32,
  pub Flags: uint32,
  pub Reserve1: uint32,
  pub Reserve2: uint32,
  pub Reserve3: uint32,
}

pub struct SectionHeader {
  pub Name: string,
  pub Seg: string,
  pub Addr: uint64,
  pub Size: uint64,
  pub Offset: uint32,
  pub Align: uint32,
  pub Reloff: uint32,
  pub Nreloc: uint32,
  pub Flags: uint32,
}

/// A Segment represents a Mach-O 32-bit or 64-bit load segment command.
pub struct Segment {
  pub LoadBytes: LoadBytes,
  pub SegmentHeader: SegmentHeader,
  pub ReaderAt: Option<io.ReaderAt>,
}

/// A Segment32 is a 32-bit Mach-O segment load command.
pub struct Segment32 {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  // SKIPPED field "Name": array-currently-not-representable — fixed-size array cannot currently be represented in Lisette
  pub Addr: uint32,
  pub Memsz: uint32,
  pub Offset: uint32,
  pub Filesz: uint32,
  pub Maxprot: uint32,
  pub Prot: uint32,
  pub Nsect: uint32,
  pub Flag: uint32,
}

/// A Segment64 is a 64-bit Mach-O segment load command.
pub struct Segment64 {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  // SKIPPED field "Name": array-currently-not-representable — fixed-size array cannot currently be represented in Lisette
  pub Addr: uint64,
  pub Memsz: uint64,
  pub Offset: uint64,
  pub Filesz: uint64,
  pub Maxprot: uint32,
  pub Prot: uint32,
  pub Nsect: uint32,
  pub Flag: uint32,
}

/// A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.
pub struct SegmentHeader {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Name: string,
  pub Addr: uint64,
  pub Memsz: uint64,
  pub Offset: uint64,
  pub Filesz: uint64,
  pub Maxprot: uint32,
  pub Prot: uint32,
  pub Nsect: uint32,
  pub Flag: uint32,
}

/// A Symbol is a Mach-O 32-bit or 64-bit symbol table entry.
pub struct Symbol {
  pub Name: string,
  pub Type: uint8,
  pub Sect: uint8,
  pub Desc: uint16,
  pub Value: uint64,
}

/// A Symtab represents a Mach-O symbol table command.
pub struct Symtab {
  pub LoadBytes: LoadBytes,
  pub SymtabCmd: SymtabCmd,
  pub Syms: Slice<Symbol>,
}

/// A SymtabCmd is a Mach-O symbol table command.
pub struct SymtabCmd {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Symoff: uint32,
  pub Nsyms: uint32,
  pub Stroff: uint32,
  pub Strsize: uint32,
}

/// A Thread is a Mach-O thread state command.
pub struct Thread {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Type: uint32,
  pub Data: Slice<uint32>,
}

/// A Type is the Mach-O file type, e.g. an object file, executable, or dynamic library.
pub struct Type(uint32)

pub const FlagAllModsBound = 0x1000

pub const FlagAllowStackExecution = 0x20000

pub const FlagAppExtensionSafe = 0x2000000

pub const FlagBindAtLoad = 0x8

pub const FlagBindsToWeak = 0x10000

pub const FlagCanonical = 0x4000

pub const FlagDeadStrippableDylib = 0x400000

pub const FlagDyldLink = 0x4

pub const FlagForceFlat = 0x100

pub const FlagHasTLVDescriptors = 0x800000

pub const FlagIncrLink = 0x2

pub const FlagLazyInit = 0x40

pub const FlagNoFixPrebinding = 0x400

pub const FlagNoHeapExecution = 0x1000000

pub const FlagNoMultiDefs = 0x200

pub const FlagNoReexportedDylibs = 0x100000

pub const FlagNoUndefs = 0x1

pub const FlagPIE = 0x200000

pub const FlagPrebindable = 0x800

pub const FlagPrebound = 0x10

pub const FlagRootSafe = 0x40000

pub const FlagSetuidSafe = 0x80000

pub const FlagSplitSegs = 0x20

pub const FlagSubsectionsViaSymbols = 0x2000

pub const FlagTwoLevel = 0x80

pub const FlagWeakDefines = 0x8000

pub const Magic32 = 0xfeedface

pub const Magic64 = 0xfeedfacf

pub const MagicFat = 0xcafebabe

pub const TypeBundle: Type = 8

pub const TypeDylib: Type = 6

pub const TypeExec: Type = 2

pub const TypeObj: Type = 1

/// ErrNotFat is returned from [NewFatFile] or [OpenFat] when the file is not a
/// universal binary but may be a thin binary, based on its magic number.
pub var ErrNotFat: Ref<FormatError>

impl Cpu {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl Dylib {
  fn Raw(self) -> Slice<uint8>
}

impl Dysymtab {
  fn Raw(self) -> Slice<uint8>
}

impl FatArch {
  /// Close closes the [File].
  /// If the [File] was created using [NewFile] directly instead of [Open],
  /// Close has no effect.
  #[allow(unused_result)]
  fn Close(self) -> Result<(), error>

  /// DWARF returns the DWARF debug information for the Mach-O file.
  fn DWARF(self) -> Result<Ref<dwarf.Data>, error>

  /// ImportedLibraries returns the paths of all libraries
  /// referred to by the binary f that are expected to be
  /// linked with the binary at dynamic link time.
  fn ImportedLibraries(self) -> Result<Slice<string>, error>

  /// ImportedSymbols returns the names of all symbols
  /// referred to by the binary f that are expected to be
  /// satisfied by other libraries at dynamic load time.
  fn ImportedSymbols(self) -> Result<Slice<string>, error>

  /// Section returns the first section with the given name, or nil if no such
  /// section exists.
  fn Section(self, name: string) -> Option<Ref<Section>>

  /// Segment returns the first Segment with the given name, or nil if no such segment exists.
  fn Segment(self, name: string) -> Option<Ref<Segment>>
}

impl FatFile {
  #[allow(unused_result)]
  fn Close(self: Ref<FatFile>) -> Result<(), error>
}

impl File {
  /// Close closes the [File].
  /// If the [File] was created using [NewFile] directly instead of [Open],
  /// Close has no effect.
  #[allow(unused_result)]
  fn Close(self: Ref<File>) -> Result<(), error>

  /// DWARF returns the DWARF debug information for the Mach-O file.
  fn DWARF(self: Ref<File>) -> Result<Ref<dwarf.Data>, error>

  /// ImportedLibraries returns the paths of all libraries
  /// referred to by the binary f that are expected to be
  /// linked with the binary at dynamic link time.
  fn ImportedLibraries(self: Ref<File>) -> Result<Slice<string>, error>

  /// ImportedSymbols returns the names of all symbols
  /// referred to by the binary f that are expected to be
  /// satisfied by other libraries at dynamic load time.
  fn ImportedSymbols(self: Ref<File>) -> Result<Slice<string>, error>

  /// Section returns the first section with the given name, or nil if no such
  /// section exists.
  fn Section(self: Ref<File>, name: string) -> Option<Ref<Section>>

  /// Segment returns the first Segment with the given name, or nil if no such segment exists.
  fn Segment(self: Ref<File>, name: string) -> Option<Ref<Segment>>
}

impl FormatError {
  fn Error(self: Ref<FormatError>) -> string
}

impl LoadBytes {
  fn Raw(self) -> Slice<uint8>
}

impl LoadCmd {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl RelocTypeARM {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl RelocTypeARM64 {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl RelocTypeGeneric {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl RelocTypeX86_64 {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl Rpath {
  fn Raw(self) -> Slice<uint8>
}

impl Section {
  /// Data reads and returns the contents of the Mach-O section.
  fn Data(self: Ref<Section>) -> Result<Slice<uint8>, error>

  /// Open returns a new ReadSeeker reading the Mach-O section.
  fn Open(self: Ref<Section>) -> io.ReadSeeker

  fn ReadAt(self, mut p: Slice<uint8>, off: int64) -> Partial<int, error>
}

impl Segment {
  /// Data reads and returns the contents of the segment.
  fn Data(self: Ref<Segment>) -> Result<Slice<uint8>, error>

  /// Open returns a new ReadSeeker reading the segment.
  fn Open(self: Ref<Segment>) -> io.ReadSeeker

  fn Raw(self) -> Slice<uint8>

  fn ReadAt(self, mut p: Slice<uint8>, off: int64) -> Partial<int, error>
}

impl Symtab {
  fn Raw(self) -> Slice<uint8>
}

impl Type {
  fn GoString(self) -> string

  fn String(self) -> string
}
