Browse Source

+ support writing R_WASM_GLOBAL_INDEX_I32 relocations in the WebAssembly internal object writer

Nikolay Nikolov 11 months ago
parent
commit
9799c6a5ec
1 changed files with 10 additions and 0 deletions
  1. 10 0
      compiler/ogwasm.pas

+ 10 - 0
compiler/ogwasm.pas

@@ -1609,6 +1609,16 @@ implementation
                             WriteUleb(relout,FuncSym.SymbolIndex);
                           WriteSleb(relout,objrel.Addend+objrel.symbol.address);  { addend to add to the address }
                         end
+                      else if assigned(objrel.symbol) and (objrel.symbol.typ=AT_WASM_GLOBAL) then
+                        begin
+                          Inc(relcount^);
+                          WriteByte(relout,Ord(R_WASM_GLOBAL_INDEX_I32));
+                          WriteUleb(relout,objrel.DataOffset+objsec.FileSectionOfs);
+			  if (TWasmObjSymbol(objrel.symbol).SymbolIndex<0) then
+                            message1(asmw_e_illegal_unset_index,objrel.symbol.name)
+                          else
+                            WriteUleb(relout,TWasmObjSymbol(objrel.symbol).SymbolIndex);
+                        end
                       else
                         begin
                           Inc(relcount^);