diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-11-26 22:43:30 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-04-21 01:51:24 +0200 |
| commit | f25b015e5b668028c34974bbb22faa4105c26690 (patch) | |
| tree | 28f2b08c17b3585d06694ad74004d0617eadb785 /private_include/nw/sections.h | |
| download | nanowasm-sync-f25b015e5b668028c34974bbb22faa4105c26690.tar.gz | |
First commit
Diffstat (limited to 'private_include/nw/sections.h')
| -rw-r--r-- | private_include/nw/sections.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/private_include/nw/sections.h b/private_include/nw/sections.h new file mode 100644 index 0000000..bef9cd8 --- /dev/null +++ b/private_include/nw/sections.h @@ -0,0 +1,65 @@ +/* + * nanowasm, a tiny WebAssembly/Wasm interpreter + * Copyright (C) 2023-2024 Xavier Del Campo Romero + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#ifndef SECTIONS_H +#define SECTIONS_H + +#include <nanowasm/nw.h> +#include <nw/types.h> +#include <stddef.h> +#include <stdio.h> + +struct section +{ + const struct nw_mod_cfg *cfg; + FILE *f; +}; + +int section_custom_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_type_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_import_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_function_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_table_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_memory_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_global_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_export_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_start_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_element_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_code_check(const struct section *s, struct nw_mod *m, unsigned long len); +int section_data_check(const struct section *s, struct nw_mod *m, unsigned long len); + +struct section_function +{ + varuint32 type, index, nreturn; +}; + +struct section_code +{ + long start; +}; + +int section_function(const struct section *s, const struct nw_mod *m, + varuint32 idx, struct section_function *f); +int section_code(const struct section *s, const struct nw_mod *m, + varuint32 idx, struct section_code *c); + +int section_code_push(FILE *f, long pc, struct nw_frame *fr); +int section_type_push(FILE *f, const struct nw_mod *m, varuint32 idx, + struct nw_frame *fr); +int section_global_push(FILE *f, const struct nw_mod *m, struct nw_interp *i); + +struct resizable_limits +{ + bool max_available; + size_t sz, max; +}; + +int check_resizable_limits(FILE *f, struct resizable_limits *r); + +#endif |
