Browse Source

+ partial implementation of emitting RELOC_FUNCTION_INDEX_LEB relocations

Nikolay Nikolov 3 years ago
parent
commit
a5d1ce26a0
1 changed files with 18 additions and 0 deletions
  1. 18 0
      compiler/ogwasm.pas

+ 18 - 0
compiler/ogwasm.pas

@@ -328,7 +328,25 @@ implementation
 
 
     procedure TWasmObjData.writeReloc(Data: TRelocDataInt; len: aword;
     procedure TWasmObjData.writeReloc(Data: TRelocDataInt; len: aword;
         p: TObjSymbol; Reloctype: TObjRelocationType);
         p: TObjSymbol; Reloctype: TObjRelocationType);
+      const
+        leb_zero: array[0..4] of byte=($80,$80,$80,$80,$00);
       begin
       begin
+        case Reloctype of
+          RELOC_FUNCTION_INDEX_LEB:
+            begin
+              if Data<>0 then
+                internalerror(2021092502);
+              if len<>5 then
+                internalerror(2021092503);
+              writebytes(leb_zero,5);
+            end;
+          RELOC_ABSOLUTE:
+            begin
+              { todo... }
+            end;
+          else
+            internalerror(2021092501);
+        end;
       end;
       end;
 
 
     function TWasmObjData.AddOrCreateObjSymbolExtraData(const symname: TSymStr): TWasmObjSymbolExtraData;
     function TWasmObjData.AddOrCreateObjSymbolExtraData(const symname: TSymStr): TWasmObjSymbolExtraData;