# macho: redo relocation handling and lazy bind globals · gitcafe/zig

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

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

Visibility: public

Requested revision: fc302f00a9de5de0490f4a66720e75946763c695

Requested commit: fc302f00a9de5de0490f4a66720e75946763c695

Commit: fc302f00a9de5de0490f4a66720e75946763c695

Tree: 3ac9dfd61b29a6dbab7054abe6e71daf7f085e6c

Author: Jakub Konka

Committer: Jakub Konka

## Message

```
macho: redo relocation handling and lazy bind globals

* apply late symbol resolution for globals - instead of resolving
  the exact location of a symbol in locals, globals or undefs,
  we postpone the exact resolution until we have a full picture
  for relocation resolution.
* fixup stubs to defined symbols - this is currently a hack rather
  than a final solution. I'll need to work out the details to make
  it more approachable. Currently, we preemptively create a stub
  for a lazy bound global and fix up stub offsets in stub helper
  routine if the global turns out to be undefined only. This is quite
  wasteful in terms of space as we create stub, stub helper and lazy ptr
  atoms but don't use them for defined globals.
* change log scope to .link for macho.
* remove redundant code paths from Object and Atom.
* drastically simplify the contents of Relocation struct (i.e., it is
  now a simple superset of macho.relocation_info), clean up relocation
  parsing and resolution logic.

```

## Parents

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

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