0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib/std/macho.zig

2127 lines
67 KiB

2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2020-02-22 12:44:21 +01:00
2020-02-22 12:44:21 +01:00
2020-02-22 12:44:21 +01:00
2020-02-22 12:44:21 +01:00
2021-05-17 14:28:49 +02:00
2021-05-17 14:28:49 +02:00
2021-05-17 14:28:49 +02:00
2021-05-17 14:28:49 +02:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
Improvements to docs and text * 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-04-23 20:06:21 +02:00
Improvements to docs and text * 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-04-23 20:06:21 +02:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2023-03-16 20:41:46 +01:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
macho: implement pruning of unused segments and sections 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-29 08:05:32 +02:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2022-10-07 21:24:44 +03:30
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2018-08-27 19:25:18 -04:00
2018-08-25 03:07:37 -04:00
2022-10-07 21:24:44 +03:30
2021-03-01 00:16:01 +01:00
2021-03-17 00:21:56 +01:00
2021-03-17 00:21:56 +01:00
2022-03-22 00:03:13 +01:00
2022-03-22 00:03:13 +01:00
2021-03-03 01:52:21 +01:00
2021-03-03 01:52:21 +01:00