MACH(3)
π MACH(3) β bestie's guide to libmach β¨
okay so this is from the Library Functions Manual (that's the manual name, we're folding it in, you're welcome π) and it's all about machbytype and machbyname β giving you machine-independent access to executables and programs. iykyk. π
β¨ NAME β¨
machbytype, machbyname β machine-independent access to executables and programs π«Ά
πΈ SYNOPSIS πΈ
#include <u.h>
#include <libc.h>
#include <mach.h>
void machbytype(int type)
int machbyname(char *name)
extern Mach *mach;
π¦ DESCRIPTION π¦
so libmach is literally the whole interface for getting at executable files and executing images across all the architectures and operating systems. and the iconic part? it's machine-independent. like, for example, you can inspect Mac OS X core dumps from an x86 Linux machine and vice versa. no cap, that's the flex. π
in its current form the library is mainly useful for writing debuggers of one sort or another, which is very main character of it.
π the Mach structure π
an architecture is described primarily by a Mach structure, and that thing holds the data structures and parameters describing the particular architecture. most library functions just assume the global variable mach points at the structure for the architecture being debugged.
- it gets set implicitly by
crackhdr(peepmach-file(3)for that one) - or you can set it explicitly by calling
machbynameormachbytype
π operating systems, or: there's no OS structure π
there is no operating system-specific structure akin to mach. nope, not a thing. typically the choice of operating system on a particular architecture affects only the executable and core dump formats β the various file parsers just deduce the operating system from information in the binary files themselves and adjust accordingly. lowkey genius. β¨
π the supported architectures π
386β Intel 32-bit x86 (386 and later)powerβ IBM PowerPC, typically running Mac OS X
π§ other manual pages, a whole saga π§
other manual pages describe the library functions in detail, so go read them, bestie:
mach-cmd(3)β describes some convenience routines for attaching to processes and core filesmach-file(3)β describes the manipulation of binary filesmach-map(3)β describes the interface to address spaces and register sets in executable files and executing programsmach-stack(3)β describes support for unwinding the stackmach-swap(3)β describes helper functions for accessing data in a particular byte ordermach-symbol(3)β describes the interface to debugging symbol information
π₯ SOURCE π₯
/src/libmach
slay. π
π SEE ALSO π
mach-file(3), mach-map(3), mach-stack(3), mach-swap(3), mach-symbol(3)
and that's the tea β β this whole page is literally MACH(3) from the source at /src/libmach, so go forth and debug something iconic. mwah π«Άππ
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms