# macho: unfortunately, LINKEDIT commands NEED to be in order · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/7e87f93e068af192a3c39bdeebfe8e9b612311b0)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 7e87f93e068af192a3c39bdeebfe8e9b612311b0

Requested commit: 7e87f93e068af192a3c39bdeebfe8e9b612311b0

Commit: 7e87f93e068af192a3c39bdeebfe8e9b612311b0

Tree: 20d608f7b80dccd7be5d3fde7d72772d0ee312b2

Author: Jakub Konka

Committer: Jakub Konka

## Message

```
macho: unfortunately, LINKEDIT commands NEED to be in order

Otherwise, Apple's tooling goes mental and reports that the executable
is malformed/fails strict validation. We absolutely have to get it
right to support tools such `codesign` which are required to
successfully launch an app on an iOS device for instance. When Zig
matures enough so that we can ditch any Apple tooling and still be
able to successfully codesign for iOS and other, we can revisit this
area. Until then however, we are stuck in having to rewrite the LINKEDIT
segment at every update run of the self-hosted.

FYI, the strict layout for the MachO binary apparently is (please,
read this with a pinch of salt as this is inferred by me):
* __TEXT segment
* __DATA_CONST segment
* __DATA segment
* __LINKEDIT segment
* dyld info (rebase, bind, weak bind, lazy bind, export)
* symbol table
* dynamic symbol table
* string table
* code signature (if expected)

```

## Parents

- [80e1c244b6c9d5f3e855878d92ecc09dc8eb970a](https://git.cafe/gitcafe/zig/commit/80e1c244b6c9d5f3e855878d92ecc09dc8eb970a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/7e87f93e068af192a3c39bdeebfe8e9b612311b0?format=markdown)
