Skip to content

Commit f8753eb

Browse files
committed
Add in the troublesome .wasms from fuzz testing
This code could really use some boost PP magic or such to keep down on the repetition
1 parent 91ecbe7 commit f8753eb

14 files changed

+419
-156
lines changed

unittests/contracts/fuzz1.wasm

27 Bytes
Binary file not shown.

unittests/contracts/fuzz10.wasm

148 Bytes
Binary file not shown.

unittests/contracts/fuzz11.wasm

18 Bytes
Binary file not shown.

unittests/contracts/fuzz12.wasm

76 Bytes
Binary file not shown.

unittests/contracts/fuzz2.wasm

67 Bytes
Binary file not shown.

unittests/contracts/fuzz3.wasm

80 Bytes
Binary file not shown.

unittests/contracts/fuzz4.wasm

77 Bytes
Binary file not shown.

unittests/contracts/fuzz5.wasm

211 Bytes
Binary file not shown.

unittests/contracts/fuzz6.wasm

853 Bytes
Binary file not shown.

unittests/contracts/fuzz7.wasm

230 Bytes
Binary file not shown.

unittests/contracts/fuzz8.wasm

11 Bytes
Binary file not shown.

unittests/contracts/fuzz9.wasm

31.1 KB
Binary file not shown.

unittests/incbin.h

Lines changed: 352 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
1+
/**
2+
* From https://github.com/graphitemaster/incbin licenced in public domain
3+
*/
4+
#ifndef INCBIN_HDR
5+
#define INCBIN_HDR
6+
#include <limits.h>
7+
#if defined(__AVX512BW__) || \
8+
defined(__AVX512CD__) || \
9+
defined(__AVX512DQ__) || \
10+
defined(__AVX512ER__) || \
11+
defined(__AVX512PF__) || \
12+
defined(__AVX512VL__) || \
13+
defined(__AVX512F__)
14+
# define INCBIN_ALIGNMENT_INDEX 6
15+
#elif defined(__AVX__) || \
16+
defined(__AVX2__)
17+
# define INCBIN_ALIGNMENT_INDEX 5
18+
#elif defined(__SSE__) || \
19+
defined(__SSE2__) || \
20+
defined(__SSE3__) || \
21+
defined(__SSSE3__) || \
22+
defined(__SSE4_1__) || \
23+
defined(__SSE4_2__) || \
24+
defined(__neon__)
25+
# define INCBIN_ALIGNMENT_INDEX 4
26+
#elif ULONG_MAX != 0xffffffffu
27+
# define INCBIN_ALIGNMENT_INDEX 3
28+
# else
29+
# define INCBIN_ALIGNMENT_INDEX 2
30+
#endif
31+
32+
/* Lookup table of (1 << n) where `n' is `INCBIN_ALIGNMENT_INDEX' */
33+
#define INCBIN_ALIGN_SHIFT_0 1
34+
#define INCBIN_ALIGN_SHIFT_1 2
35+
#define INCBIN_ALIGN_SHIFT_2 4
36+
#define INCBIN_ALIGN_SHIFT_3 8
37+
#define INCBIN_ALIGN_SHIFT_4 16
38+
#define INCBIN_ALIGN_SHIFT_5 32
39+
#define INCBIN_ALIGN_SHIFT_6 64
40+
41+
/* Actual alignment value */
42+
#define INCBIN_ALIGNMENT \
43+
INCBIN_CONCATENATE( \
44+
INCBIN_CONCATENATE(INCBIN_ALIGN_SHIFT, _), \
45+
INCBIN_ALIGNMENT_INDEX)
46+
47+
/* Stringize */
48+
#define INCBIN_STR(X) \
49+
#X
50+
#define INCBIN_STRINGIZE(X) \
51+
INCBIN_STR(X)
52+
/* Concatenate */
53+
#define INCBIN_CAT(X, Y) \
54+
X ## Y
55+
#define INCBIN_CONCATENATE(X, Y) \
56+
INCBIN_CAT(X, Y)
57+
/* Deferred macro expansion */
58+
#define INCBIN_EVAL(X) \
59+
X
60+
#define INCBIN_INVOKE(N, ...) \
61+
INCBIN_EVAL(N(__VA_ARGS__))
62+
63+
/* Green Hills uses a different directive for including binary data */
64+
#if defined(__ghs__)
65+
# define INCBIN_MACRO "\tINCBIN"
66+
#else
67+
# define INCBIN_MACRO ".incbin"
68+
#endif
69+
70+
#ifndef _MSC_VER
71+
# define INCBIN_ALIGN \
72+
__attribute__((aligned(INCBIN_ALIGNMENT)))
73+
#else
74+
# define INCBIN_ALIGN __declspec(align(INCBIN_ALIGNMENT))
75+
#endif
76+
77+
#if defined(__arm__) || /* GNU C and RealView */ \
78+
defined(__arm) || /* Diab */ \
79+
defined(_ARM) /* ImageCraft */
80+
# define INCBIN_ARM
81+
#endif
82+
83+
#ifdef __GNUC__
84+
/* Utilize .balign where supported */
85+
# define INCBIN_ALIGN_HOST ".balign " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
86+
# define INCBIN_ALIGN_BYTE ".balign 1\n"
87+
#elif defined(INCBIN_ARM)
88+
/*
89+
* On arm assemblers, the alignment value is calculated as (1 << n) where `n' is
90+
* the shift count. This is the value passed to `.align'
91+
*/
92+
# define INCBIN_ALIGN_HOST ".align" INCBIN_STRINGIZE(INCBIN_ALIGNMENT_INDEX) "\n"
93+
# define INCBIN_ALIGN_BYTE ".align 0\n"
94+
#else
95+
/* We assume other inline assembler's treat `.align' as `.balign' */
96+
# define INCBIN_ALIGN_HOST ".align" INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
97+
# define INCBIN_ALIGN_BYTE ".align 1\n"
98+
#endif
99+
100+
/* INCBIN_CONST is used by incbin.c generated files */
101+
#if defined(__cplusplus)
102+
# define INCBIN_EXTERNAL extern "C"
103+
# define INCBIN_CONST extern const
104+
#else
105+
# define INCBIN_EXTERNAL extern
106+
# define INCBIN_CONST const
107+
#endif
108+
109+
/**
110+
* @brief Optionally override the linker section into which data is emitted.
111+
*
112+
* @warning If you use this facility, you'll have to deal with platform-specific linker output
113+
* section naming on your own
114+
*
115+
* Overriding the default linker output section, e.g for esp8266/Arduino:
116+
* @code
117+
* #define INCBIN_OUTPUT_SECTION ".irom.text"
118+
* #include "incbin.h"
119+
* INCBIN(Foo, "foo.txt");
120+
* // Data is emitted into program memory that never gets copied to RAM
121+
* @endcode
122+
*/
123+
#if !defined(INCBIN_OUTPUT_SECTION)
124+
# if defined(__APPLE__)
125+
# define INCBIN_OUTPUT_SECTION ".const_data"
126+
# else
127+
# define INCBIN_OUTPUT_SECTION ".rodata"
128+
# endif
129+
#endif
130+
131+
#if defined(__APPLE__)
132+
/* The directives are different for Apple branded compilers */
133+
# define INCBIN_SECTION INCBIN_OUTPUT_SECTION "\n"
134+
# define INCBIN_GLOBAL(NAME) ".globl " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
135+
# define INCBIN_INT ".long "
136+
# define INCBIN_MANGLE "_"
137+
# define INCBIN_BYTE ".byte "
138+
# define INCBIN_TYPE(...)
139+
#else
140+
# define INCBIN_SECTION ".section " INCBIN_OUTPUT_SECTION "\n"
141+
# define INCBIN_GLOBAL(NAME) ".global " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
142+
# define INCBIN_INT ".int "
143+
# if defined(__USER_LABEL_PREFIX__)
144+
# define INCBIN_MANGLE INCBIN_STRINGIZE(__USER_LABEL_PREFIX__)
145+
# else
146+
# define INCBIN_MANGLE ""
147+
# endif
148+
# if defined(INCBIN_ARM)
149+
/* On arm assemblers, `@' is used as a line comment token */
150+
# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", %object\n"
151+
# elif defined(__MINGW32__) || defined(__MINGW64__)
152+
/* Mingw doesn't support this directive either */
153+
# define INCBIN_TYPE(NAME)
154+
# else
155+
/* It's safe to use `@' on other architectures */
156+
# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n"
157+
# endif
158+
# define INCBIN_BYTE ".byte "
159+
#endif
160+
161+
/* List of style types used for symbol names */
162+
#define INCBIN_STYLE_CAMEL 0
163+
#define INCBIN_STYLE_SNAKE 1
164+
165+
/**
166+
* @brief Specify the prefix to use for symbol names.
167+
*
168+
* By default this is `g', producing symbols of the form:
169+
* @code
170+
* #include "incbin.h"
171+
* INCBIN(Foo, "foo.txt");
172+
*
173+
* // Now you have the following symbols:
174+
* // const unsigned char gFooData[];
175+
* // const unsigned char *const gFooEnd;
176+
* // const unsigned int gFooSize;
177+
* @endcode
178+
*
179+
* If however you specify a prefix before including: e.g:
180+
* @code
181+
* #define INCBIN_PREFIX incbin
182+
* #include "incbin.h"
183+
* INCBIN(Foo, "foo.txt");
184+
*
185+
* // Now you have the following symbols instead:
186+
* // const unsigned char incbinFooData[];
187+
* // const unsigned char *const incbinFooEnd;
188+
* // const unsigned int incbinFooSize;
189+
* @endcode
190+
*/
191+
#if !defined(INCBIN_PREFIX)
192+
# define INCBIN_PREFIX g
193+
#endif
194+
195+
/**
196+
* @brief Specify the style used for symbol names.
197+
*
198+
* Possible options are
199+
* - INCBIN_STYLE_CAMEL "CamelCase"
200+
* - INCBIN_STYLE_SNAKE "snake_case"
201+
*
202+
* Default option is *INCBIN_STYLE_CAMEL* producing symbols of the form:
203+
* @code
204+
* #include "incbin.h"
205+
* INCBIN(Foo, "foo.txt");
206+
*
207+
* // Now you have the following symbols:
208+
* // const unsigned char <prefix>FooData[];
209+
* // const unsigned char *const <prefix>FooEnd;
210+
* // const unsigned int <prefix>FooSize;
211+
* @endcode
212+
*
213+
* If however you specify a style before including: e.g:
214+
* @code
215+
* #define INCBIN_STYLE INCBIN_STYLE_SNAKE
216+
* #include "incbin.h"
217+
* INCBIN(foo, "foo.txt");
218+
*
219+
* // Now you have the following symbols:
220+
* // const unsigned char <prefix>foo_data[];
221+
* // const unsigned char *const <prefix>foo_end;
222+
* // const unsigned int <prefix>foo_size;
223+
* @endcode
224+
*/
225+
#if !defined(INCBIN_STYLE)
226+
# define INCBIN_STYLE INCBIN_STYLE_CAMEL
227+
#endif
228+
229+
/* Style lookup tables */
230+
#define INCBIN_STYLE_0_DATA Data
231+
#define INCBIN_STYLE_0_END End
232+
#define INCBIN_STYLE_0_SIZE Size
233+
#define INCBIN_STYLE_1_DATA _data
234+
#define INCBIN_STYLE_1_END _end
235+
#define INCBIN_STYLE_1_SIZE _size
236+
237+
/* Style lookup: returning identifier */
238+
#define INCBIN_STYLE_IDENT(TYPE) \
239+
INCBIN_CONCATENATE( \
240+
INCBIN_STYLE_, \
241+
INCBIN_CONCATENATE( \
242+
INCBIN_EVAL(INCBIN_STYLE), \
243+
INCBIN_CONCATENATE(_, TYPE)))
244+
245+
/* Style lookup: returning string literal */
246+
#define INCBIN_STYLE_STRING(TYPE) \
247+
INCBIN_STRINGIZE( \
248+
INCBIN_STYLE_IDENT(TYPE)) \
249+
250+
/* Generate the global labels by indirectly invoking the macro with our style
251+
* type and concatenating the name against them. */
252+
#define INCBIN_GLOBAL_LABELS(NAME, TYPE) \
253+
INCBIN_INVOKE( \
254+
INCBIN_GLOBAL, \
255+
INCBIN_CONCATENATE( \
256+
NAME, \
257+
INCBIN_INVOKE( \
258+
INCBIN_STYLE_IDENT, \
259+
TYPE))) \
260+
INCBIN_INVOKE( \
261+
INCBIN_TYPE, \
262+
INCBIN_CONCATENATE( \
263+
NAME, \
264+
INCBIN_INVOKE( \
265+
INCBIN_STYLE_IDENT, \
266+
TYPE)))
267+
268+
/**
269+
* @brief Externally reference binary data included in another translation unit.
270+
*
271+
* Produces three external symbols that reference the binary data included in
272+
* another translation unit.
273+
*
274+
* The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with
275+
* "Data", as well as "End" and "Size" after. An example is provided below.
276+
*
277+
* @param NAME The name given for the binary data
278+
*
279+
* @code
280+
* INCBIN_EXTERN(Foo);
281+
*
282+
* // Now you have the following symbols:
283+
* // extern const unsigned char <prefix>FooData[];
284+
* // extern const unsigned char *const <prefix>FooEnd;
285+
* // extern const unsigned int <prefix>FooSize;
286+
* @endcode
287+
*/
288+
#define INCBIN_EXTERN(NAME) \
289+
INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char \
290+
INCBIN_CONCATENATE( \
291+
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
292+
INCBIN_STYLE_IDENT(DATA))[]; \
293+
INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char *const \
294+
INCBIN_CONCATENATE( \
295+
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
296+
INCBIN_STYLE_IDENT(END)); \
297+
INCBIN_EXTERNAL const unsigned int \
298+
INCBIN_CONCATENATE( \
299+
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
300+
INCBIN_STYLE_IDENT(SIZE))
301+
302+
/**
303+
* @brief Include a binary file into the current translation unit.
304+
*
305+
* Includes a binary file into the current translation unit, producing three symbols
306+
* for objects that encode the data and size respectively.
307+
*
308+
* The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with
309+
* "Data", as well as "End" and "Size" after. An example is provided below.
310+
*
311+
* @param NAME The name to associate with this binary data (as an identifier.)
312+
* @param FILENAME The file to include (as a string literal.)
313+
*
314+
* @code
315+
* INCBIN(Icon, "icon.png");
316+
*
317+
* // Now you have the following symbols:
318+
* // const unsigned char <prefix>IconData[];
319+
* // const unsigned char *const <prefix>IconEnd;
320+
* // const unsigned int <prefix>IconSize;
321+
* @endcode
322+
*
323+
* @warning This must be used in global scope
324+
* @warning The identifiers may be different if INCBIN_STYLE is not default
325+
*
326+
* To externally reference the data included by this in another translation unit
327+
* please @see INCBIN_EXTERN.
328+
*/
329+
#ifdef _MSC_VER
330+
#define INCBIN(NAME, FILENAME) \
331+
INCBIN_EXTERN(NAME)
332+
#else
333+
#define INCBIN(NAME, FILENAME) \
334+
__asm__(INCBIN_SECTION \
335+
INCBIN_GLOBAL_LABELS(NAME, DATA) \
336+
INCBIN_ALIGN_HOST \
337+
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) ":\n" \
338+
INCBIN_MACRO " \"" FILENAME "\"\n" \
339+
INCBIN_GLOBAL_LABELS(NAME, END) \
340+
INCBIN_ALIGN_BYTE \
341+
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) ":\n" \
342+
INCBIN_BYTE "1\n" \
343+
INCBIN_GLOBAL_LABELS(NAME, SIZE) \
344+
INCBIN_ALIGN_HOST \
345+
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(SIZE) ":\n" \
346+
INCBIN_INT INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) " - " \
347+
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) "\n" \
348+
); \
349+
INCBIN_EXTERN(NAME)
350+
351+
#endif
352+
#endif

0 commit comments

Comments
 (0)