| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
| |
(this is HEAD~1 as of this writing, HEAD containing the Memory64 tests which I want to land separately)
|
|
|
|
| |
Fixes regressions in binary reader introduced by the implementation of
the memory64 extension: https://github.com/WebAssembly/wabt/pull/1500.
|
|
|
|
| |
If bulk memory extension is disabled, do not allow memory index in the
data segment other than zero.
|
|
|
|
|
|
|
|
|
| |
* Fix up reloc-related tests after #1537
PRs #1527 and #1539 needed their test expectations updated after #1537
was merged; this patch does that. It also renames a test for
consistency.
* Adapt test to renaming
|
|
|
|
|
|
|
|
|
|
| |
* fix reloc offsets
* test long function section and long function bodies
(relocation offsets depend on the length of the function size encoding but not on the length of the function section size encoding)
* remove unused variable
* add preceding function in test
|
|
|
|
|
|
|
| |
* Fix reloc section references when --enable-bulk-memory
Fixes #1538.
* Add assertions about successors to elided DataCount section
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Eagerly create symbol tables when writing relocatable binaries
Instead of adding entries to the symbol table as they are referenced,
when writing relocatable binaries, we're going to make symbols for all
functions. This allows exported functions and globals to be written
with the proper exported / no_strip flags, so that resulting files will
link with wasm-ld.
* Symbol table names are export names, without the dollar.
In the previous commit, I wrongly assumed that the globally visible name
for linking was taken from the exports section, whereas actually it's
from the symbol table. Therefore this patch changes to strip off the
dollar, and also to make all named bindings globally visible. The
exported-to-the-host binding is mostly unrelated to the
visible-to-other-compilation-units binding. Unnamed definitions aren't
added to the symbol table.
* Add symbol tables test
* Rename Intern helper to EnsureUnique
|
| |
|
| |
|
|
|
|
| |
This commit refactors the representations of symbols in the binary
writer. It will allow us to fix #1534 in a followup.
|
|
|
|
|
|
|
|
|
| |
* Fix bug when writing multi-value block type
The block type must be written as an SLEB, not an LEB. We also want it
to be relocatable, so I added a way to write a fixed-size SLEB too
(`WriteS32Leb128WithReloc` and `WriteFixedS32Leb128`).
* Fix ubsan issue
|
| |
|
| |
|
| |
|
|
|
|
| |
Fixes: #1520
|
|
|
|
| |
Fixes: #1249
|
|
|
|
| |
I guess maybe we don't do CI with `-Werror` enabled? We probably
should.
|
|
|
| |
This speeds up builds of WABT significantly
|
|
|
|
|
| |
Some proposals are enabled by default now, so the README should reflect that. Also, the flag was flipped to disable (rather than enable), so change that here too.
See issue #1513.
|
|
|
|
|
| |
Adds a type field to `Value` to verify the right union member is being read.
A Wasm module that has been validated shouldn't need this, but any code reading the wrong value would trigger UB, but still often work (like a uint32_t read from a uint64_t on little endian machine), and mask bugs.
Turning this on found bugs in the PR I just landed (as I suspected) but also in older code.
|
|
|
|
| |
The result values of the `WriteToFile` calls for `json_stream` and
`module_streams` are now evaluated and checked.
|
| |
|
|
|
|
| |
This is useful for reproducing bugs found by oss-fuzz (see
https://bugs.chromium.org/p/oss-fuzz/issues/list?q=wabt)
|
|
|
| |
Found by oss-fuzz.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Read memory/table limits flags as uint8_t
In the wasm spec the limits flag is a single byte, not a LEB128 encoded
value.
* Detect malformed memory/table limits flag
* Disallow shared memory when threads are disabled
This adds additional check to disallow "is_shared" (0x2) flag for
memory limits when threads extensions is not enabled. Previously this
flag was unconditionally accepted.
|
|
|
|
| |
The section code is just a single byte, not a LEB128-encoded value.
With this fix the section code is now read correctly with ReadU8().
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The interpreter and wasm2c were incorrectly handling some float-to-int
conversions. For clarity, the wasm2c implementations of these
conversions now matches the implementation in interp-math.h more closely
(e.g. the numeric ranges are written as `x >= min && x <= max` in both
cases).
Quite a few wasm2c tests were previously being skipped, since wasm2c
doesn't currently support multi-value; it's better instead to duplicate
the tests here and disable the parts that are not supported so we don't
lose test coverage.
|
|
|
|
|
|
|
| |
Function types and struct types share an index space, but a function can
only be defined using a function type.
Since `Module::GetFuncType` already returns `nullptr` for an OOB index,
it makes sense to return `nullptr` for an invalid type too.
|
| |
|
|
|
|
| |
It would previously assume the blocktype is "simple" (at most a single result value), but now also supports function signatures.
Also fixed it ignoring the validator result.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was originally landed in 6bff9f0, but was incorrect (the test
didn't even do the right thing!)
The problem was that the local index was correctly being updated, but it
happened _after_ the names had already been resolved. To fix it,
`ResolveFuncTypes` and `ResolveNamesModule` needed be called in that
order. There was an erroneous assertion that fired as a result ("This
should only be run after resolving names"), but that's incorrect -- the
code works properly before resolving names too, since
`Module::GetFuncType` can properly look up function types by name.
Thanks to @alexcrichton for pointing this out.
|
|
|
|
|
| |
The previous change prevented `WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX`
from being defined, but `WASM_RT_MEMCHECK_SIGNAL_HANDLER` was still
defined, which would prevent the memory bounds check.
|
|
|
|
|
|
|
| |
- cassert for assert
- confing.h for WABT_UNREACHABLE
I think it was working because type.h was only included in common.h,
both cassert and config.h was included prior to including type.h.
|
|
|
|
|
| |
All enumeration values are handled in the switch, but it's still
possible to produce an invalid value, which would not return.
|
| |
|
|
|
|
| |
Also remove default case from `ir-util.cc` so we get compile warnings in
the future.
|
|
|
|
|
|
|
|
|
| |
See https://github.com/WebAssembly/reference-types/issues/99.
This change also updates the testsuite, so the spec tests pass too.
In addition, the behavior of `br_table` is no longer different from MVP,
and has a text to confirm this. That is now fixed in `type-checker.cc`
too.
|
|
|
|
|
|
| |
The reference types proposal originally modified the `br_table` behavior
to only check arity, not the specific types. This was to remove a
subtyping check, but now that subtyping has been removed, we can revert
back to the original (MVP) br_table behavior.
|
| |
|
|
|
|
|
| |
_Static_assert and _Alignof aren't defined everywhere. Also use PRIu64 format specifier where needed.
Co-authored-by: Ben Smith <binji@chromium.org>
|
|
|
| |
This is designed to exactly mimic the definition that LLVM uses under MSVC; this allows use of both WABT and LLVM headers in the same codebase without having to work around compilation errors.
|
| |
|
|
|
|
|
| |
TL;DR: this makes it simpler and safer for projects including WABT via FetchContent to configure options via the CMAKE_ARGS argument.
Importing projects may want to set (e.g.) BUILD_TESTS to "no". However, this doesn't work without creating an identical option() in the importing in the importing project. Enabling CMP0077 in supported versions of CMake allows importing projects to set default values for the variables without touching the cache.
|
|
|
|
|
|
|
| |
libwabt.js is meant to be included in multiple environments (web,
node.js, etc.) so it shouldn't be using NODERAWFS. A recent change to
the build system include `-s NODERAWFS` for all link steps, but those
are only needed for the wabt executables (e.g. wasm2wast.js).
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a function is specified like this:
(func (type $t) ...)
the type can have any sequence of params and results, but it is not
known what that signature is until it is resolved. However, locals that
are parsed will be given a binding index under the assumption that the
signature is empty, e.g.
(func (type $t)
(local $v0 i32)
(local $v1 i32)
...
)
So `$v0` will have index 0, and `$v1` will have index 1. If it turns out
later that type `$t` has any parameters, then these indexes need to be
updated.
|