]> git.proxmox.com Git - wasi-libc.git/commit
Add `-fstack-protector` support to wasi-libc (#351)
authorYuta Saito <kateinoigakukun@gmail.com>
Tue, 6 Dec 2022 17:19:49 +0000 (02:19 +0900)
committerGitHub <noreply@github.com>
Tue, 6 Dec 2022 17:19:49 +0000 (09:19 -0800)
commit8b7148f69ae241a2749b3defe4606da8143b72e0
tree5aeacd4999c4ae483fa4c3345325410d655fb247
parent6cd1be1f88cd90f17114b95d3ee7e106694aa92b
Add `-fstack-protector` support to wasi-libc (#351)

Inlcude `__stack_chk_fail.c` and initialize `__stack_chk_guard` in ctor.

```
$ cat main.c
char input[] = "0123456789012345";
int main(void) {
    char buf[8];

    for (char *sp = input, *dp = buf; *sp != '\0'; sp++, dp++) {
        *dp = *sp;
    }
    return 0;
}

$ clang main.c -fstack-protector
$ wasmtime ./a.out
Error: failed to run main module `./a.out`

Caused by:
    0: failed to invoke command default
    1: wasm trap: wasm `unreachable` instruction executed
       wasm backtrace:
           0:  0x258 - <unknown>!__stack_chk_fail
           1:  0x21e - <unknown>!__original_main
           2:   0xca - <unknown>!_start
```
Makefile
expected/wasm32-wasi/posix/defined-symbols.txt
expected/wasm32-wasi/single/defined-symbols.txt
libc-top-half/musl/src/env/__stack_chk_fail.c