# wasm-linker: delay code atom allocation till write · gitcafe/zig

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

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

Visibility: public

Requested revision: 7fe629a8124f27e8db01e090031a5243a452e831

Requested commit: 7fe629a8124f27e8db01e090031a5243a452e831

Commit: 7fe629a8124f27e8db01e090031a5243a452e831

Tree: b9bb349520685f9b972a789a49f72ddd719464ad

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm-linker: delay code atom allocation till write

We delay atom allocation for the code section until we write the actual
atoms. We do this to ensure the offset of the atom also includes the
'size' field which is leb128-encoded and therefore variable. We need this
correct offset to ensure debug info works correctly.

The ordering of the code section is now automatic due to iterating the
function section and then finding the corresponding atom to each
function. This also ensures each function corresponds to the right atom,
and they do not go out-of-sync.

Lastly, we removed the `next` field as it is no longer required and also
removed manually setting the offset in synthetic functions. This means
atoms use less memory and synthetic functions are less prone. They will
also be placed in order of function order correctly.

```

## Parents

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

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