Browse Source

* split the sections strings into groups and add comments about the importance
of the section order and grouping. No functional changes.

Nikolay Nikolov 1 year ago
parent
commit
6f8655ecc9
1 changed files with 13 additions and 1 deletions
  1. 13 1
      compiler/systems/t_wasi.pas

+ 13 - 1
compiler/systems/t_wasi.pas

@@ -304,7 +304,19 @@ begin
   LinkScript.Concat('  OBJSECTION .wasm_globals.*');
   LinkScript.Concat('  OBJSECTION .wasm_globals.*');
   LinkScript.Concat('ENDEXESECTION');
   LinkScript.Concat('ENDEXESECTION');
 
 
-  ScriptAddGenericSections('.wasm_tags,.text,.rodata,.data,fpc.resources,fpc.reshandles,.bss,.debug_frame,.debug_info,.debug_line,.debug_abbrev,.debug_aranges,.debug_ranges,.debug_str');
+  { WebAssembly is a Harvard architecture, with multiple address spaces, so it
+    is important to keep the sections grouped, and keep the first section in
+    each group intact (otherwise, TWasmExeOutput.MemPos_ExeSection in ogwasm.pas
+    needs to be updated) }
+  ScriptAddGenericSections(
+    { tags (used by WebAssembly native exceptions) }
+    '.wasm_tags,'+
+    { code }
+    '.text,'+
+    { data (initialized data first, uninitialized data later) }
+    '.rodata,.data,fpc.resources,fpc.reshandles,.bss,'+
+    { debug info }
+    '.debug_frame,.debug_info,.debug_line,.debug_abbrev,.debug_aranges,.debug_ranges,.debug_str');
 end;
 end;
 
 
 function TInternalLinkerWasi.GetDataSize(aExeOutput: TExeOutput): QWord;
 function TInternalLinkerWasi.GetDataSize(aExeOutput: TExeOutput): QWord;