aboutsummaryrefslogtreecommitdiff
path: root/lib/std/macho.zig
AgeCommit message (Collapse)Author
2025-12-05std: replace usages of std.mem.indexOf with std.mem.findAdrià Arrufat
2025-11-20std.debug: split up Mach-O debug info handlingMatthew Lugg
Like ELF, we now have `std.debug.MachOFile` for the host-independent parts, and `std.debug.SelfInfo.MachO` for logic requiring the file to correspond to the running program.
2025-09-30std: fixesmlugg
2025-09-30yet moremlugg
2025-09-30change one million thingsmlugg
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-08-28link.MachO: update to not use GenericWriterAndrew Kelley
2024-07-31remove hard tabs from source codeAndrew Kelley
these are illegal according to the spec
2024-04-18The Mach-O header flags gained two new members at some point, and these are ↵cryptocode
missing in the Zig std library. This PR adds these. The macOS libc header is already up-to-date: https://github.com/ziglang/zig/blob/130fb5cb0fb9039e79450c9db58d6590c5bee3b3/lib/libc/include/any-macos-any/mach-o/loader.h#L232-L241
2024-04-06lib/std/macho: update PLATFORM enum with VISIONOS tagsJakub Konka
2024-01-24std.macho: add segment flagsJakub Konka
2023-12-06macho: rename flag to EXPORT_SYMBOL_FLAGS_WEAK_DEFINITIONJakub Konka
2023-12-06lib/std/macho: add missing LC defs and missing N_NO_DEAD_STRIP desc for nlistsJakub Konka
2023-11-17std.macho: fix LoadCommandIterator to work with underaligned dataJakub Konka
2023-10-03std.macho: remove alignment from LoadCommandIteratorAndrew Kelley
2023-08-18macho: add helper for accessing tools array in LC_BUILD_VERSION cmdJakub Konka
2023-07-20dwarf: move macho unwind code from macho -> dwarfkcbanner
dwarf: fixup unchecked .eh_frame CIE offset subtraction
2023-07-20macho: don't scan all eh_frame entries, instead follow the offset from the ↵kcbanner
__unwind_info directly
2023-07-20dwarf: add abi.stripInstructionPtrAuthCodekcbanner
2023-07-20macho: remove unnecessary checkskcbanner
2023-07-20macho: add aarch64 implementation to unwindFramekcbanner
dwarf: map the V registers in abi.regBytes test: add test case that exercises the stack-indirect __unwind_info mode in x86_64
2023-07-20macho: add unwindFrame which can unwind stack frames using the __unwind_info ↵kcbanner
section dwarf: fixup missing error
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-04-30std: fix a bunch of typosLinus Groh
The majority of these are in comments, some in doc comments which might affect the generated documentation, and a few in parameter names - nothing that should be breaking, however.
2023-04-23Improvements to docs and textzooster
* docs(std.math): elaborate on difference between absCast and absInt * docs(std.rand.Random.weightedIndex): elaborate on likelihood I think this makes it easier to understand. * langref: add small reminder * docs(std.fs.path.extension): brevity * docs(std.bit_set.StaticBitSet): mention the specific types * std.debug.TTY: explain what purpose this struct serves This should also make it clearer that this struct is not supposed to provide unrelated terminal manipulation functionality such as setting the cursor position or something because terminals are complicated and we should keep this struct simple and focused on debugging. * langref(package listing): brevity * langref: explain what exactly `threadlocal` causes to happen * std.array_list: link between swapRemove and orderedRemove Maybe this can serve as a TLDR and make it easier to decide. * PrefetchOptions.locality: clarify docs that this is a range This confused me previously and I thought I can only use either 0 or 3. * fix typos and more * std.builtin.CallingConvention: document some CCs * langref: explain possibly cryptic names I think it helps knowing what exactly these acronyms (@clz and @ctz) and abbreviations (@popCount) mean. * variadic function error: add missing preposition * std.fmt.format docs: nicely hyphenate * help menu: say what to optimize for I think this is slightly more specific than just calling it "optimizations". These are speed optimizations. I used the word "performance" here.
2023-03-21macho: use TOOL=0x5 to mean ZIG as the build toolJakub Konka
2023-03-18macho: add hot-code swapping pocJakub Konka
2023-01-21std.macho: add OLD = 0 as valid mode for both arm64 and x86_64Jakub Konka
2023-01-19macho: port arm64 and x86_64 compact unwind defs verbatimJakub Konka
We do not need more for the purpose of parsing and synthesising unwind info by the linker. If we ever decide to generate unwind info for Zig by the compiler, we can re-add packed struct defs again.
2022-12-27macho: add Zig wrapper for compact unwind encoding on arm64Jakub Konka
2022-12-20macho: add missing defs of compact unwind info recordsJakub Konka
2022-12-16macho: store LC headers to often updated LINKEDIT sectionsJakub Konka
2022-11-18run zig fmt on everything checked by CIStevie Hryciw
2022-11-04all: rename i386 to x86Ali Chraghi
2022-09-18macho: rewrite how we allocate space in incremental contextJakub Konka
2022-08-03macho: add missing align cast in LoadCommandIteratorJakub Konka
2022-08-03macho: update how we insert output sectionsJakub Konka
Instead of generating sections upfront, allow generation by scanning the object files for input -> output sections mapping. Next, always strive to keep output sections in the final container sorted as they appear in the final binary. This makes the linker less messy wrt handling of output sections sort order for dyld/macOS not to complain. There's still more work to be done for incremental context though to make this work but looks promising already.
2022-08-03macho: sync with zldJakub Konka
gitrev a2c32e972f8c5adfcda8ed2d99379ae868f59c24 https://github.com/kubkon/zld/commit/a2c32e972f8c5adfcda8ed2d99379ae868f59c24
2022-07-20macho: Pass sections by pointer when slicing namesCody Tapscott
We were accidentally returning a pointer to stack memory, because these arguments were passed by value. It's just an accident that stage 1 was passing these by reference, so things were alright until stage 3.
2022-07-01macho: implement pruning of unused segments and sectionsJakub Konka
This is a prelude to a more elaborate work which will implement `-dead_strip` flag - garbage collection of unreachable atoms. Here, when sorting sections, we also check that the section is actually populated with some atoms, and if not, we exclude it from the final linked image. This can happen when we do not import any symbols from dynamic libraries in which case we will not be populating the stubs sections or the GOT table, implying we can skip allocating those sections. Furthermore, we also make a check that a segment is actually occupied too, with the exception of `__TEXT` segment which is non-optional given that it wraps the header and load commands and thus is required by the `dyld` to perform dynamic linking, and `__PAGEZERO` which is generally non-optional when the linked image is an executable. For any other segment, if its section count is zero, we mark it as dead and skip allocating it and generating a load command for it. This commit also includes some minor improvements to the linker such as refactoring of the segment allocating codepaths, skipping `__PAGEZERO` generation for dylibs, and skipping generation of zero-sized atoms for special symbols such as `__mh_execute_header` and `___dso_handle`. These special symbols are only allocated local and global symbol pair and their VM addresses is set to the start of the `__TEXT` segment, but no `Atom` is created, as it's not necessary given that they never carry any machine code. Finally, we now always force-link against `libSystem` which turns out to be required for `dyld` to properly handle `LC_MAIN` load command on older macOS versions such as 10.15.7.
2022-06-28macho: discriminate between normal and weak dylibsJakub Konka
Parse `-weak-lx` and `-weak_framework x` in the CLI.
2022-04-01macho: set CS_LINKER_SIGNED flag in code signature generated by zldJakub Konka
This way, if the user wants to use `codesign` (or other tool) they will not be forced to `-f` force signature update. This matches the behavior promoted by Apple's `ld64` linker.
2022-03-22macho: add more codesig constantsJakub Konka
2022-03-19Sema: implement zirSwitchCaptureElse for error setsVeikka Tuominen
2022-03-13std+macho: revert and fix exposing Mach wrappers in std.os and std.cJakub Konka
2022-03-13std: fix imports for darwin specific flags and funcsJakub Konka
2022-03-13macos: add Mach task abstractionJakub Konka
`std.os.darwin.MachTask` wraps `mach_port_t` and can be used to issue kernel calls tied to the wrapped Mach kernel port/task.
2022-03-13macos: add more mach primitivesJakub Konka
2021-12-15macho: put `LC_*` consts in a typed enum(u32) LCJakub Konka
repeat for `PLATFORM_*` and `TOOL_*` sets
2021-12-10macho: move all helpers from commands.zig into std.machoJakub Konka
This way we will finally be able to share common parsing logic between different Zig components and 3rd party packages.