# start: Fix \_start\(\) to initialize the ToC for powerpc64\. · gitcafe/zig

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

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

Visibility: public

Requested revision: 7bc78967b400322a0fc5651f37a1b0428c37fb9d

Requested commit: 7bc78967b400322a0fc5651f37a1b0428c37fb9d

Commit: 7bc78967b400322a0fc5651f37a1b0428c37fb9d

Tree: c4eee7937ac827aa648b1b027232dac88106749c

Author: Alex Rønne Petersen

Committer: Alex Rønne Petersen

## Message

```
start: Fix _start() to initialize the ToC for powerpc64.

The previous version of this function referenced the argc_argv_ptr global
variable as an inline asm operand. This caused LLVM to generate prologue code to
initialize the ToC so that the global variable can actually be accessed.

Ordinarily, there's nothing wrong with that. But _start() is a naked function!
This makes it actually super surprising that LLVM did this. It also means that
the old version only really worked by accident.

Once the reference to the global variable was removed, no ToC was set up, thus
violating the calling convention once we got to posixCallMainAndExit(). This
then caused any attempt to access global variables here to crash - namely when
setting std.os.linux.elf_aux_maybe.

The fix is to just initialize the ToC manually in _start().

```

## Parents

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

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