Skip to content

Instantly share code, notes, and snippets.

@ElvishJerricco
Last active April 19, 2018 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElvishJerricco/5f3baeb27ffc54d06385725a7ce5eff8 to your computer and use it in GitHub Desktop.
Save ElvishJerricco/5f3baeb27ffc54d06385725a7ce5eff8 to your computer and use it in GitHub Desktop.
#define NUM 16
int foo[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int *bar = ((int *)&foo) + NUM;
#!/usr/bin/env bash
set -eu
CC="clang --target=wasm32-unknown-unknown-wasm -nostdlib"
$CC -c test.c -o test1.o
$CC -r test1.o -o test2.o
$CC -r test2.o -o test3.o
@ElvishJerricco
Copy link
Author

ElvishJerricco commented Apr 19, 2018

Output:

lld: error: unexpected existing value for R_WEBASSEMBLY_MEMORY_ADDR_I32: existing=64 expected=4294967232
clang-7: error: lld command failed with exit code 1 (use -v to see invocation)

@ElvishJerricco
Copy link
Author

ElvishJerricco commented Apr 19, 2018

Interestingly, whether or not this breaks depends on that NUM being 16. If NUM >= 16 && NUM < 32, it breaks. But if NUM < 16 || NUM >= 32, it works. EDIT: "works" as in it exits cleanly; I guess I'm not really sure how to verify that it's correct.

@sbc100
Copy link

sbc100 commented Apr 19, 2018

Fix is here: https://reviews.llvm.org/D45825. Thanks for tracking that down!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment