diff options
author | bloodstalker <thabogre@gmail.com> | 2018-06-26 10:36:55 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2018-06-26 10:36:55 +0000 |
commit | 26e2a879bdefafee3bff0a41e1167cbf29b3ab3f (patch) | |
tree | 7107b6666e8f39c00bf34abc70eb47926789e5be /test/linker | |
parent | Initial commit (diff) | |
download | dwasm-26e2a879bdefafee3bff0a41e1167cbf29b3ab3f.tar.gz dwasm-26e2a879bdefafee3bff0a41e1167cbf29b3ab3f.zip |
first commit
Diffstat (limited to 'test/linker')
-rw-r--r-- | test/linker/.depend | 2 | ||||
-rw-r--r-- | test/linker/file0.c | 20 | ||||
-rw-r--r-- | test/linker/file1.c | 25 | ||||
-rw-r--r-- | test/linker/makefile | 44 |
4 files changed, 91 insertions, 0 deletions
diff --git a/test/linker/.depend b/test/linker/.depend new file mode 100644 index 0000000..9cb14ac --- /dev/null +++ b/test/linker/.depend @@ -0,0 +1,2 @@ +file0.o: file0.c file1.c +file1.o: file1.c diff --git a/test/linker/file0.c b/test/linker/file0.c new file mode 100644 index 0000000..5eb172b --- /dev/null +++ b/test/linker/file0.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <inttypes.h> +#include "file1.c" + +#define CODE_SECTION_0_0 "constant_0_0" +#define CODE_SECTION_0_1 "constant_0_1" +#define CODE_SECTION_0_2 "constant_0_2" +#define CODE_SECTION_0_3 "constant_0_3" +#define CODE_SECTION_0_4 "constant_0_4" + +int g_int_0_0 = 0; +int g_int_0_1 = 1; + +int dummy_f_0_0(int n) { + return n*4; +} + +int main (int argc, char** argv) { + return 123; +} diff --git a/test/linker/file1.c b/test/linker/file1.c new file mode 100644 index 0000000..233eaad --- /dev/null +++ b/test/linker/file1.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <inttypes.h> +#if 1 +void print(void) { + printf("external symbol"); +} +#endif + +#define CODE_SECTION_1_0 "constant_1_0" +#define CODE_SECTION_1_1 "constant_1_1" +#define CODE_SECTION_1_2 "constant_1_2" +#define CODE_SECTION_1_3 "constant_1_3" +#define CODE_SECTION_1_4 "constant_1_4" + +int g_int_1_0 = 10; +int g_int_1_1 = 11; + +int dummy_f_1_0(int n) { + if (n >= 1) return dummy_f_1_0(n-1) * n; + else return 1; +} + +int dymmy_f_1_1(int n) { + return n*2; +} diff --git a/test/linker/makefile b/test/linker/makefile new file mode 100644 index 0000000..1cc9413 --- /dev/null +++ b/test/linker/makefile @@ -0,0 +1,44 @@ +TARGET=file0 +CC=clang +CC?=clang +CC_FLAGS= +CC_EXTRA?= +CC_FLAGS+=$(CC_EXTRA) + +SRCS=$(wildcard *.c) +WASM=$(patsubst %.c, %.wasm, $(wildcard *.c)) + +.DEFAULT:all + +.PHONY:all clean help + +all:$(TARGET) wasmforce + +depend:.depend + +.depend:$(SRCS) + rm -rf .depend + $(CC) -MM $(CC_FLAGS) $^ > ./.depend + +-include ./.depend + +%.wasm:%.c + llvm-wasm $< + +wasmforce:$(WASM) + @echo forcing generation of wasm and wast + +.c.o: + $(CC) $(CC_FLAGS) -c $< -o $@ + +$(TARGET): $(TARGET).o + $(CC) $^ $(LD_FLAGS) -o $@ + +clean: + rm -f *.s *.wasm *.wast *.bc *.o *~ $(TARGET) + rm .depend + +help: + @echo "all is the default target" + @echo "there is delete." + @echo "there is clean." |