Nikolay Nikolov
90305b6032
+ write the actual DWARF debug sections in the WebAssembly object writer. The relocations aren't ready, yet, though.
2022-07-16 02:13:42 +03:00
Nikolay Nikolov
b82af25e63
* fixed crashes with the WebAssembly internal object writer, when debug info is enabled. The debug info itself is not yet written to the file, though.
2022-07-16 01:40:21 +03:00
Nikolay Nikolov
a9698b6f6e
+ introduced TWasmObjSection.IsDebug
2022-07-16 00:54:11 +03:00
Nikolay Nikolov
4db653998b
+ generate proper WebAssembly threadvar access when multithreading is turned on
2022-07-14 02:39:07 +03:00
Nikolay Nikolov
fa5575ea54
+ prefix the threadvar sections with '.tbss' when WASM multithreading is enabled
2022-07-13 23:27:30 +03:00
Nikolay Nikolov
2606cef21f
+ set the TLS flag for threadvar sections when WASM threads are enabled
2022-07-13 23:19:48 +03:00
Nikolay Nikolov
7cd082ba5f
+ produce a target_features section when compiling with -CTwasmthreads
2022-05-28 04:04:02 +03:00
Nikolay Nikolov
1dd80d596d
+ added a 'producers' custom section to WebAssembly object modules, containing the FPC version
2022-05-28 03:33:04 +03:00
Nikolay Nikolov
ee89b7c9ec
* fixed warning
2022-05-28 00:47:23 +03:00
Nikolay Nikolov
0c6287894b
* the WebAssembly internal assembler renamed WASM (previously it was OMF, which was the ID of the MS-DOS .obj writer, which I forgot to rename)
2022-05-26 14:12:10 +03:00
Pierre Muller
7c21b37105
Avoid some range check error and convert internalerror into error messages
2022-05-26 00:28:47 +02:00
Pierre Muller
c9e8bfd118
Add internalerror if ogwasm tries to write unset Func/Global or TagIndex of TWasmObjSymbol
2022-02-11 22:19:43 +00:00
Nikolay Nikolov
cdf1ceca76
* emit a weak symbol for the exception tag, since that's what the LLVM linker
...
wants to treat them as shared between .o files
2021-09-28 02:52:40 +03:00
Nikolay Nikolov
b463f2a141
+ added support for exception tags and for the 'throw' and 'catch' instructions
...
in the wasm internal assembler and object writer
2021-09-27 21:44:09 +03:00
Nikolay Nikolov
b46c010f82
+ also support immutable wasm globals in the wasm assembler writer (both internal and external)
2021-09-27 05:40:26 +03:00
Nikolay Nikolov
7b31549119
* the data section is now only written by the internal wasm object writer, when
...
there are data segments in the module
2021-09-27 05:17:20 +03:00
Nikolay Nikolov
e85aff2b96
* combined TWasmObjSymbol.ImportIndex and .FuncIndex into just .FuncIndex,
...
because there's no point in having them separate, and the name ImportIndex
is misleading, as there are multiple import indices (they are separate for
functions, globals, tables, memories, etc.)
2021-09-27 04:53:35 +03:00
Nikolay Nikolov
2bce4d36db
+ proper support for WASM globals in the internal object writer - emit
...
relocations, generate a Global section, if they are declared in the object
file, etc.
2021-09-27 04:24:49 +03:00
Nikolay Nikolov
5ad2d47e23
* track wasm global types in the internal object writer
2021-09-27 03:03:57 +03:00
Nikolay Nikolov
0bb781c928
* omit writing the export section if there are no exported functions from
...
the module. This reduces object file size slightly for modules without
exports.
2021-09-26 23:14:52 +03:00
Nikolay Nikolov
d37117c460
* use an incrementing counter variable to determine the numbers for the code
...
and data section, so they can be used in the relocation section, without
hardcoding them as constants. This will automatically adjust the numbers
when we add more sections, or when we make writing some of the sections
optional.
2021-09-26 23:10:55 +03:00
Nikolay Nikolov
77b898fe45
* use objsym.size to determine the code size of the function (instead of
...
writing until the end of the section) in the wasm internal object writer.
This removes the extra padding of 'unreachable' instructions at the end of
each function (which are zeroes, added for alignment - they are harmless,
but are unnecessary and cause a slight increase of the size of the
resulting binaries), after the final 'return' instruction of the function.
2021-09-26 22:21:34 +03:00
Nikolay Nikolov
2102fbdc97
- removed debug writelns from the wasm internal object writer
2021-09-26 20:13:35 +03:00
Nikolay Nikolov
99c84da071
+ generate the export section in the wasm internal obj writer
2021-09-26 20:02:48 +03:00
Nikolay Nikolov
abf831c430
+ fixed the addend in the relocations that point to data
2021-09-26 11:12:08 +03:00
Nikolay Nikolov
c881d05793
* fixed bug in the code, generated for the RELOC_FUNCTION_INDEX_LEB
...
relocation
2021-09-26 10:29:17 +03:00
Nikolay Nikolov
07461d0fc3
* made the constructor of TObjSymbol virtual, so it can be overriden
2021-09-26 10:17:19 +03:00
Nikolay Nikolov
efd5831742
* generate an internal error if an attempt is made to emit a
...
R_WASM_MEMORY_ADDR_LEB relocation, that points to code, instead of
data
2021-09-26 09:42:12 +03:00
Nikolay Nikolov
392ca81c20
+ add threadvar symbols to the symbol table
2021-09-26 09:40:28 +03:00
Nikolay Nikolov
d7b141d70e
+ implemented the if, loop and else instructions
2021-09-26 07:45:14 +03:00
Nikolay Nikolov
ea401ccc82
+ support writing R_WASM_MEMORY_ADDR_I32 relocations
2021-09-26 06:27:02 +03:00
Nikolay Nikolov
7f5250bf46
+ implemented support for R_WASM_TABLE_INDEX_SLEB relocations
2021-09-26 06:22:41 +03:00
Nikolay Nikolov
9fa2e2934b
+ support the call_indirect instruction and the R_WASM_TYPE_INDEX_LEB
...
relocation that it requires in the internal wasm object writer
2021-09-26 06:03:18 +03:00
Nikolay Nikolov
bd6bbb6cf4
+ support writing imports from a different module in the wasm binary object writer
2021-09-26 05:36:51 +03:00
Nikolay Nikolov
238d09d875
+ support writing RELOC_FUNCTION_INDEX_LEB relocations to non-external functions
2021-09-26 05:15:50 +03:00
Nikolay Nikolov
bf5048cb5e
+ support generating R_WASM_TABLE_INDEX_I32 relocations
2021-09-26 04:46:46 +03:00
Nikolay Nikolov
acdb65c2a3
+ support tai_symbolpair in the wasm internal obj writer, so that the
...
PASCALMAIN alias of main can be created
2021-09-26 04:19:16 +03:00
Nikolay Nikolov
6e7e632682
* fixed another warning
2021-09-26 03:16:01 +03:00
Nikolay Nikolov
4ebf857ffc
* fixed warning
2021-09-26 03:05:00 +03:00
Nikolay Nikolov
b913133152
+ implemented leb and sleb relocations to data symbols
2021-09-26 02:23:31 +03:00
Nikolay Nikolov
67cbb7032e
+ fully implemented the RELOC_FUNCTION_INDEX_LEB relocations
2021-09-26 00:45:52 +03:00
Nikolay Nikolov
4e4910cb84
+ write the relocation tables for the code and data sections (empty for now)
2021-09-25 23:47:30 +03:00
Nikolay Nikolov
217b3ea3cc
+ write the segment info (names and alignment) to the linking custom section
2021-09-25 23:30:43 +03:00
Nikolay Nikolov
5066a7eb24
+ also write the data symbols to the symbol table
2021-09-25 23:20:15 +03:00
Nikolay Nikolov
ad8ed4b48d
+ write the non-external functions to the symbol table as well
2021-09-25 23:03:09 +03:00
Nikolay Nikolov
2d2906205b
+ write the externals to the symbol table
2021-09-25 22:45:47 +03:00
Nikolay Nikolov
8c57d20abc
+ write the linking section (empty for now)
2021-09-25 19:19:12 +03:00
Nikolay Nikolov
12496a638b
+ add relocation objects for the RELOC_FUNCTION_INDEX_LEB relocation to
...
the relocation list. They are not written to the object file, yet.
2021-09-25 18:37:10 +03:00
Nikolay Nikolov
a5d1ce26a0
+ partial implementation of emitting RELOC_FUNCTION_INDEX_LEB relocations
2021-09-25 18:24:27 +03:00
Nikolay Nikolov
cbf444bbbe
+ write the actual function code in the code section
2021-09-25 18:08:01 +03:00
Nikolay Nikolov
dbb6f95ea7
* replaced TWasmObjData(Data) with FData in TWasmObjOutput.writeData
2021-09-25 17:49:19 +03:00
Nikolay Nikolov
6d1df899e6
+ write the code section (still, without the actual function code, but with
...
the correct locals)
2021-09-25 17:41:42 +03:00
Nikolay Nikolov
e924dd0d16
+ generate and write the functions table in the wasm binary module,
...
produced by the internal obj writer
2021-09-25 16:53:00 +03:00
Nikolay Nikolov
7e53fecd09
+ handle tai_local in the internal asm writer and store the locals in the
...
wasm obj extra symbol data object
2021-09-25 16:00:09 +03:00
Nikolay Nikolov
050519f16f
+ handle the import_module and import_name directives in the internal
...
assembler and store them as obj symbol extra data
2021-09-25 15:44:35 +03:00
Nikolay Nikolov
4ef2a88946
+ added method TWasmObjData.AddOrCreateObjSymbolExtraData
2021-09-25 15:35:28 +03:00
Nikolay Nikolov
27675967f8
* store the funcname to functype index in a TFPHashObjectList, instead of
...
TFPHashList with the index converted to pointer, which was a hack and didn't
allow adding more fields, which we would need to do for e.g. import_module
and import_name
2021-09-25 15:24:30 +03:00
Nikolay Nikolov
72a49b68ce
* fixed the writing of the external functions in the import table
2021-09-25 00:39:03 +03:00
Nikolay Nikolov
4ca39cf07d
+ write the import functions in the wasm binary writer
2021-09-23 17:11:24 +03:00
Nikolay Nikolov
78af12b584
+ added function name to functype hashlist in the wasm objdata class
2021-09-23 16:19:15 +03:00
Nikolay Nikolov
a58368d20d
+ avoid duplicate functypes in the types section of the wasm module we produce
2021-09-20 19:33:48 +03:00
Nikolay Nikolov
bb0155141a
* fixed warning
2021-09-20 04:25:40 +03:00
Nikolay Nikolov
92592be8e4
+ print more symbol properties to the console
2021-09-20 04:16:25 +03:00
Nikolay Nikolov
628fcb9b1c
+ create the Type wasm section
2021-09-20 03:43:23 +03:00
Nikolay Nikolov
3c3120845a
* fixed crash when writing a binary wasm module with a .bss section
2021-09-20 03:07:00 +03:00
Nikolay Nikolov
455f603c8c
+ debug print the obj symbols to the console
2021-09-20 00:14:45 +03:00
Nikolay Nikolov
12796d176d
+ added the indirect function table to the imports section
2021-09-20 00:05:28 +03:00
Nikolay Nikolov
905f0b1f78
+ add the __stack_pointer global import
2021-09-19 23:56:32 +03:00
Nikolay Nikolov
e8c3f5d6b0
+ create the data section and the first entry of the import section
2021-09-19 23:43:45 +03:00
Nikolay Nikolov
2563cb6daa
+ start writing the wasm sections. The DataCount section is the first section to be implemented.
2021-09-19 22:46:54 +03:00
Nikolay Nikolov
e45d8578e8
+ count the number of segments and assign segment indices to the wasm sections
2021-09-19 21:04:55 +03:00
Nikolay Nikolov
eea8f32772
+ introduced TWasmObjSection.IsCode and .IsData
2021-09-19 20:56:06 +03:00
Nikolay Nikolov
698b5de389
+ added TWasmObjSection class
2021-09-19 20:51:33 +03:00
Nikolay Nikolov
429454c8f4
+ write some debug info to the console in the wasm obj writer
2021-09-19 20:47:20 +03:00
Nikolay Nikolov
c200bf5311
* fixed TWasmObjData.sectionname_gas
2021-09-19 19:41:27 +03:00
Nikolay Nikolov
fd4d6b8fc3
+ write the wasm binary module header and version
2021-09-19 19:33:33 +03:00
Nikolay Nikolov
ffc5131087
+ implemented TWasmObjData.sectionname
2021-09-19 19:24:16 +03:00
Nikolay Nikolov
59ea39ce75
+ started the wasmbase unit (similar to elfbase and omfbase)
2021-09-19 18:49:50 +03:00
Nikolay Nikolov
cc314e61a2
+ started working on the WebAssembly internal assembler
2021-09-19 16:17:09 +03:00