Commit Graph

68848 Commits

Author SHA1 Message Date
Nikolay Nikolov
cd93050d7e * set the size of AT_WASM_GLOBAL symbols to 1 2024-01-01 18:10:20 +02:00
Nikolay Nikolov
ef796906e9 + wasm internal obj reader: add globals to a '.wasm_globals' object section 2024-01-01 18:03:02 +02:00
Nikolay Nikolov
2eae62a6e8 * define the __stack_pointer symbol in a different way, so it doesn't crash during linking 2024-01-01 17:54:59 +02:00
Nikolay Nikolov
167c7bc565 + create relocations for R_WASM_GLOBAL_INDEX_LEB entires in the wasm object reader 2024-01-01 17:46:51 +02:00
Nikolay Nikolov
9ee13f2937 + also define non-imported SYMTAB_GLOBAL symbols in the wasm internal object reader 2024-01-01 17:40:31 +02:00
Nikolay Nikolov
408e388af3 + wasm internal linker: internally define the '__stack_pointer' global symbol 2024-01-01 17:36:52 +02:00
Nikolay Nikolov
880d0333b0 + wasm internal object reader: process SYMTAB_GLOBAL import entries 2024-01-01 17:25:56 +02:00
Nikolay Nikolov
e6a68b28b6 * wasm internal linker: produce an error if an R_WASM_SECTION_OFFSET_I32 or an
R_WASM_TAG_INDEX_LEB relocations is encountered - these aren't implemented,
  and are not required for 'hello, world', so will be done later.
2024-01-01 17:12:07 +02:00
Nikolay Nikolov
4208fc79c7 + implemented R_WASM_MEMORY_ADDR_SLEB and R_WASM_TABLE_INDEX_SLEB relocations in the wasm internal linker 2024-01-01 17:08:36 +02:00
Nikolay Nikolov
b440f57739 + implemented R_WASM_MEMORY_ADDR_LEB relocations in the wasm internal linker 2024-01-01 17:04:35 +02:00
Nikolay Nikolov
5771245d74 + create the Table and Elem sections in the wasm exe writer 2024-01-01 16:56:53 +02:00
Nikolay Nikolov
7a228bccfc + implement R_WASM_TABLE_INDEX_I32 relocations in the wasm internal linker 2024-01-01 16:41:03 +02:00
Nikolay Nikolov
1b2d29ea1a + implemented R_WASM_MEMORY_ADDR_I32 relocations in the wasm internal linker 2024-01-01 16:13:11 +02:00
Nikolay Nikolov
12d7d271d6 + write the data section in the wasm internal linker exe writer 2024-01-01 15:58:17 +02:00
Nikolay Nikolov
1e89579766 + WASI internal linker: implemented GetCodeSize, GetDataSize and GetBssSize. 2024-01-01 15:32:28 +02:00
Nikolay Nikolov
b361b41a86 + webassembly internal linker: create separate exe sections for .rodata and .bss 2024-01-01 14:56:33 +02:00
Nikolay Nikolov
dc4689ba1b * wasm internal linker: start the data section at offset 0, as WebAssembly is a Harvard architecture. 2024-01-01 14:44:44 +02:00
Nikolay Nikolov
69ce966691 + implemented RELOC_TYPE_INDEX_LEB relocations in the wasm internal linker 2024-01-01 14:35:10 +02:00
Nikolay Nikolov
0b3238bcd3 * refactor: invert if condition and else statement (reducing the nesting level), because then terminates the function. No functional changes. 2024-01-01 14:04:29 +02:00
Nikolay Nikolov
5845bb9095 * produce an internal error, instead of a warning in case of RELOC_FUNCTION_INDEX_LEB pointing to a function with missing ExeFunctionIndex 2024-01-01 14:03:03 +02:00
Nikolay Nikolov
50986967f5 + wasm internal linker: fill ExeFunctionIndex of alias code symbols as well 2024-01-01 14:01:43 +02:00
Nikolay Nikolov
cf79ca16b4 * only set MainFuncSymbol of code sections to the main (non-alias) symbol 2024-01-01 13:44:36 +02:00
Nikolay Nikolov
c453bac7ad + report an error in case a wasm object file has a code section, without a main symbol 2024-01-01 13:42:24 +02:00
Nikolay Nikolov
e1d56a9944 * wasm internal linker: use the main symbol (without WASM_SYM_EXPLICIT_NAME,
i.e. not an alias) to define code section names in the wasm object reader.
  For example, the section for the INITHEAP function is now called:
    .text.n_SYSTEM_$$_INITHEAP
  instead of
    .text.n__FPC_InitHeap
  (which is based on an explicit alias for the function - '_FPC_InitHeap')
2024-01-01 13:35:23 +02:00
Nikolay Nikolov
7747e1f6c8 + wasm internal linker: write the functions, defined in the current module in the linker map file 2024-01-01 13:20:28 +02:00
Nikolay Nikolov
409de5ac96 + write the import function indexes in the linker map file 2024-01-01 13:13:48 +02:00
Nikolay Nikolov
1c1dbaf776 + partial implementation of RELOC_FUNCTION_INDEX_LEB relocations in the wasm internal linker 2024-01-01 01:05:49 +02:00
Nikolay Nikolov
f4f6a16796 + fill the memory section in the wasm exe writer 2024-01-01 00:39:14 +02:00
Nikolay Nikolov
507e9eb20a + added check for the ExeFunctionIndex inside WriteCodeSegments 2024-01-01 00:15:27 +02:00
Nikolay Nikolov
88a42c3ee0 + write the type indexes correctly 2023-12-31 23:50:53 +02:00
Nikolay Nikolov
f5dbd38b7e * extracted the import preparation to a separate method TWasmExeOutput.PrepareImports 2023-12-31 23:39:26 +02:00
Nikolay Nikolov
946fc370e9 * set TWasmObjSection.MainFuncSymbol in the wasm object reader 2023-12-31 23:32:51 +02:00
Nikolay Nikolov
ac0c187b56 + WebAssembly exe writer: write the code section 2023-12-31 23:29:33 +02:00
Nikolay Nikolov
d9a67bb16d + generate the import section in the wasm exe writer 2023-12-31 22:52:03 +02:00
Nikolay Nikolov
2c72b62a0e + generate and write the Type section in the WebAssembly internal exe writer 2023-12-31 22:47:07 +02:00
Nikolay Nikolov
3c4a1087f3 * writing of the type wasm object section extracted to a method TWasmFuncTypeTable.WriteTo, so it can be reused in the exe writer 2023-12-31 22:43:44 +02:00
Nikolay Nikolov
a387accf81 * WriteWasmBasicType and WriteWasmResultType converted to global functions to allow reuse in the exe writer 2023-12-31 22:39:35 +02:00
Nikolay Nikolov
5583781f47 + initialize TWasmExeOutput.FWasmSections 2023-12-31 22:36:45 +02:00
Nikolay Nikolov
7d6158d5f4 + added and implemented TWasmExeOutput.WriteWasmSection 2023-12-31 22:35:44 +02:00
Nikolay Nikolov
c342a5f473 * converted some helper methods from TWasmObjOutput to global functions, so they can be reused in the exe writer 2023-12-31 22:28:53 +02:00
Nikolay Nikolov
b2f31c4112 + added a section array to the wasm exe writer 2023-12-31 22:27:05 +02:00
Nikolay Nikolov
16c4e0300c + WebAssembly internal linker, exe writer: keep track of exe import functions. Add and fill TWasmObjSymbolLinkingData.ExeFunctionIndex 2023-12-31 22:17:51 +02:00
Nikolay Nikolov
da8ccd64ef + also write the functype of imported functions in the linker map file 2023-12-31 21:50:18 +02:00
Nikolay Nikolov
52f0ec579e + added TWasmFuncType.ToString implementation 2023-12-31 21:49:35 +02:00
Nikolay Nikolov
4f4beb6225 + store the functype in TWasmObjSymbolLinkingData 2023-12-31 21:40:34 +02:00
Nikolay Nikolov
880eb3658a + process the module imports and write them to the map file in TWasmExeOutput.AfterUnusedSectionRemoval 2023-12-31 21:27:21 +02:00
Nikolay Nikolov
541bd66a6c + implemented TWasmExeOutput.GenerateLibraryImports 2023-12-31 21:04:04 +02:00
Nikolay Nikolov
b88b8efbce + WebAssembly object reader: create symbols for imports that have the
WASM_SYM_EXPLICIT_NAME flag set. Save the import module and name info inside
  a new field TWasmObjSymbol.LinkingData.
2023-12-31 20:39:01 +02:00
Nikolay Nikolov
f83223c8b2 * SymbolTable.ObjSym type changed from TObjSymbol to TWasmObjSymbol 2023-12-31 20:28:44 +02:00
Nikolay Nikolov
f30a41359d + added a TWasmFuncTypeTable instance to TWasmExeOutput 2023-12-31 16:50:00 +02:00