Commit Graph

124 Commits

Author SHA1 Message Date
Nikolay Nikolov
e7f6da4cb0 * the 'linking' section is a section, not a subsection. Fix error messages. 2023-12-26 15:07:42 +02:00
Nikolay Nikolov
9063c3c0ed + parse the linking custom section by splitting it into subsections and call subfunctions (dummy for now) for each subsection 2023-12-26 15:06:03 +02:00
Nikolay Nikolov
8802c7d489 + parse and check the version of the 'linking' section 2023-12-26 14:42:51 +02:00
Nikolay Nikolov
5a5abe2419 + started parsing of custom sections - known custom sections are dispatched to
a specialized parsing function for each of them, while unknown custom sections
  (currently the ones, not produced by FPC) produce an error
2023-12-26 14:32:34 +02:00
Nikolay Nikolov
2ae98a7363 + read the code entries count from the code section 2023-12-26 13:57:55 +02:00
Nikolay Nikolov
7d41f5eb92 + added code section duplicate check in wasm object reader 2023-12-26 13:49:40 +02:00
Nikolay Nikolov
b2861bacdd - removed the repeated section bounds check in the section parsing code,
because now all reads go through the read function, which does section bounds
  checking on every read
2023-12-26 13:42:07 +02:00
Nikolay Nikolov
8591f1218c + added section bounds checking to the read function, used inside TWasmObjInput.ReadObjData.ReadSection 2023-12-26 13:40:26 +02:00
Nikolay Nikolov
16c18e845f - removed the TObjectReader parameter from ReadUleb, ReadUleb32 and ReadName 2023-12-26 13:24:29 +02:00
Nikolay Nikolov
01d97bea00 - rm commented out code 2023-12-26 13:13:42 +02:00
Nikolay Nikolov
36fe4cf43d * the ReadUleb, ReadUleb32 and ReadName methods moved to be local functions inside TWasmObjInput.ReadObjData.ReadSection 2023-12-26 13:12:44 +02:00
Nikolay Nikolov
c9b407508a * use ReadUleb32 in more places 2023-12-26 12:46:06 +02:00
Nikolay Nikolov
621699acca + introduced ReadUleb32 to avoid code repetition of the >high(uint32) checks 2023-12-26 11:43:49 +02:00
Nikolay Nikolov
bcb7c069fb + parse the data count section 2023-12-26 10:25:20 +02:00
Nikolay Nikolov
f87a66f1e6 + parse the rest of the function section 2023-12-24 16:56:28 +02:00
Nikolay Nikolov
c7880e7bd1 + read the functions count from the functions section 2023-12-24 16:53:05 +02:00
Nikolay Nikolov
be56b641d7 + function section duplicate check 2023-12-24 16:51:23 +02:00
Nikolay Nikolov
e81b062e2d + WebAssembly object reader: implemented parsing of the import section 2023-12-24 16:35:39 +02:00
Nikolay Nikolov
e6a3aa3450 + import section duplicate check 2023-12-24 16:35:39 +02:00
Nikolay Nikolov
3bc6340424 - removed TODO comment 2023-12-24 15:28:01 +02:00
Nikolay Nikolov
01dbc63735 + input error message in case the type section size is unexpected/wrong 2023-12-24 15:04:22 +02:00
Nikolay Nikolov
a08c937beb + Wasm internal linker, object reader: implemented parsing of the type section 2023-12-24 14:57:16 +02:00
Nikolay Nikolov
90e7b2be56 + added functions for reading the different types of Wasm object sections 2023-12-24 14:12:53 +02:00
Nikolay Nikolov
54eb8de658 * write a WebAssembly header in TWasmExeOutput.writeData 2023-12-24 12:42:29 +02:00
Nikolay Nikolov
6bead20fc3 * set CObjData in the TWasmExeOutput constructor 2023-12-24 12:35:50 +02:00
Nikolay Nikolov
5a61f51b3c + added TWasmExeOutput class (not implemented, yet) 2023-11-17 00:12:18 +02:00
Nikolay Nikolov
d98d0c5e62 + started implementing TWasmObjInput.ReadObjData 2023-11-15 17:58:15 +02:00
Nikolay Nikolov
b9668a88c6 + implemented TWasmObjInput.CanReadObjData: checks for WASM header and version 2023-11-15 01:55:12 +02:00
Nikolay Nikolov
bc727f9fb2 + added TWasmObjInput class. To be used in the WASM internal linker. Not doing anything, yet. 2023-11-15 01:39:39 +02:00
Nikolay Nikolov
322befbf56 + added mutable globals to the target switches section 2023-06-17 17:00:36 +03:00
Nikolay Nikolov
9b4366e4f6 + support externref and funcref WebAssembly globals in the internal object writer 2023-06-11 10:41:56 +03:00
Nikolay Nikolov
dd13b46088 * use WasmCustomSectionName to obtain the debug section names in MaybeWriteDebugSection and MaybeAddDebugSectionToSymbolTable 2022-08-03 23:11:44 +03:00
Nikolay Nikolov
efd92fba01 + introduced TWasmCustomDebugSectionType 2022-08-03 23:04:53 +03:00
Nikolay Nikolov
cc260eb7b2 * wasm32 obj writer: use Data.ObjSectionList.Find to find the debug section by name in MaybeWriteDebugSection 2022-08-03 22:02:19 +03:00
Nikolay Nikolov
e959422753 * wasm32 obj writer: do the relocations before writing the code, data and debug sections 2022-08-03 20:56:44 +03:00
Nikolay Nikolov
edf5fce7e3 * wasm32 obj writer: determine the section number for the datacount, code, data and debug sections ahead of time (before writing the sections) 2022-08-03 20:51:58 +03:00
Nikolay Nikolov
b5a71086e8 * wasm32 obj writer: moved the writing of the data sections ahead 2022-08-03 20:44:11 +03:00
Nikolay Nikolov
2a196899bc * wasm32 obj writer: writing the debug section symbols to the symbol table moved before the writing of the debug sections themselves 2022-08-03 20:36:50 +03:00
Nikolay Nikolov
65b4425672 + support declaring wasm globals in the WebAssembly internal object writer 2022-07-31 19:28:09 +03:00
Nikolay Nikolov
5604bd951e * an attempt to fix WebAssembly debug info section relocations 2022-07-22 02:26:00 +03:00
Nikolay Nikolov
63c8e458bb * workaround crash when generating WebAssembly DWARF debug info for threadvars, while multithreading is turned off 2022-07-16 19:31:14 +03:00
Nikolay Nikolov
fcadc80163 * don't write R_WASM_TABLE_INDEX_I32 relocations, always use R_WASM_FUNCTION_OFFSET_I32 in debug sections 2022-07-16 19:08:06 +03:00
Nikolay Nikolov
972a9df031 + always (even when multithreading is off) create a "target features" section
in the WebAssembly object writer, since we still require some (very commonly
  supported) extensions, even without multithreading
2022-07-16 07:42:53 +03:00
Nikolay Nikolov
bf17a84dd2 + implemented the R_WASM_FUNCTION_OFFSET_I32 relocation in the WebAssembly object writer 2022-07-16 04:34:15 +03:00
Nikolay Nikolov
6a94d2683b + emit WASM DWARF debug info relocations 2022-07-16 04:19:50 +03:00
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