Skip to content

Commit 1f1b3df

Browse files
committed
test code
1 parent 0839fcd commit 1f1b3df

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

c/shlib_2/build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#! /bin/sh
2+
3+
set -e
4+
set -x
5+
6+
#CC=/Volumes/PortableSSD/llvm/build/bin/clang
7+
#CC=/Volumes/PortableSSD/git/wasi-sdk/build/toolchain/install/bin/clang
8+
CC=${CC:-/opt/wasi-sdk-24.0/bin/clang}
9+
10+
${CC} -Os -ffreestanding -nostdlib -fPIC -shared -fvisibility=default -Xlinker --no-entry -o lib.so lib.c
11+
12+
${CC} -Os -ffreestanding -nostdlib -fPIC \
13+
-Xlinker -Bdynamic \
14+
-Xlinker --unresolved-symbols=import-dynamic \
15+
-Xlinker --export-table \
16+
-Xlinker --growable-table \
17+
-Xlinker --export-memory \
18+
-Xlinker --export=__stack_pointer \
19+
-Xlinker --export=__heap_base \
20+
-Xlinker --export=__heap_end \
21+
-Xlinker --entry=_start -o main main.c lib.so

c/shlib_2/lib.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void
2+
f(void)
3+
{
4+
}

c/shlib_2/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
void f(void);
2+
void (*f_p)(void) = f;
3+
4+
void
5+
_start(void)
6+
{
7+
f_p();
8+
}

0 commit comments

Comments
 (0)