add syscall_stubs file

This commit is contained in:
vms 2019-08-20 15:49:01 +02:00
parent 2edc942401
commit 460d09a911
5 changed files with 25 additions and 10 deletions

View File

@ -5,14 +5,15 @@ TARGET_TRIPLE = wasm32-unknown-wasi
CFLAGS = -nostartfiles -fvisibility=hidden
LDFLAGS = -Wl,--no-entry,--demangle,--allow-undefined
EXPORT_FUNCS = --export=allocate,--export=deallocate,--export=invoke
SDK = sdk/allocator.c sdk/logger.c
SDK = sdk/allocator.c sdk/logger.c sdk/syscalls_stubs.c
SRC = src/main.c
.PHONY: default all clean
default: $(TARGET)
all: default
$(TARGET): main.c $(SDK)
$(TARGET): $(SRC) $(SDK)
$(CC) --sysroot=$(SYSROOT) --target=$(TARGET_TRIPLE) $(CFLAGS) $(LDFLAGS) -Wl,$(EXPORT_FUNCS) $^ -o $@.wasm
.PRECIOUS: $(TARGET)

7
main.c
View File

@ -1,7 +0,0 @@
#include "sdk/allocator.h"
#include "sdk/logger.h"
#include "sdk/side_module_api.h"
char *invoke(const char *str, int length) {
}

View File

@ -2,7 +2,7 @@
#define C_TEMPLATE_SIDE_MODULE_API_H
#include <string.h>
#include <sttlib.h>
#include <stdlib.h>
/*
* Concatenate preprocessor tokens A and B without expanding macro definitions

14
sdk/syscalls_stubs.c Normal file
View File

@ -0,0 +1,14 @@
#include <stdio.h>
size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) {
return 1;
}
int __stdio_close(FILE *f) {
return 1;
}
off_t __stdio_seek(FILE *_f, off_t _offset, int _value) {
return 1;
}

7
src/main.c Normal file
View File

@ -0,0 +1,7 @@
#include "../sdk/allocator.h"
#include "../sdk/logger.h"
#include "../sdk/side_module_api.h"
char *invoke(const char *str, int length) {
}