Browse Source

+ implemented R_WASM_MEMORY_ADDR_SLEB and R_WASM_TABLE_INDEX_SLEB relocations in the wasm internal linker

Nikolay Nikolov 1 year ago
parent
commit
4208fc79c7
1 changed files with 21 additions and 0 deletions
  1. 21 0
      compiler/ogwasm.pas

+ 21 - 0
compiler/ogwasm.pas

@@ -4314,6 +4314,27 @@ implementation
                       objsec.Data.seek(objreloc.DataOffset);
                       WriteUleb5(objsec.Data,UInt32((objsym.offset+objsym.objsection.MemPos)+objreloc.Addend));
                     end;
+                  RELOC_MEMORY_ADDR_OR_TABLE_INDEX_SLEB:
+                    begin
+                      case objsym.typ of
+                        AT_FUNCTION:
+                          begin
+                            if objsym.LinkingData.ExeFunctionIndex=-1 then
+                              internalerror(2024010103);
+                            if objsym.LinkingData.ExeIndirectFunctionTableIndex=-1 then
+                              objsym.LinkingData.ExeIndirectFunctionTableIndex:=AddOrGetIndirectFunctionTableIndex(objsym.LinkingData.ExeFunctionIndex);
+                            objsec.Data.seek(objreloc.DataOffset);
+                            WriteSleb5(objsec.Data,Int32(objsym.LinkingData.ExeIndirectFunctionTableIndex));
+                          end;
+                        AT_DATA:
+                          begin
+                            objsec.Data.seek(objreloc.DataOffset);
+                            WriteSleb5(objsec.Data,Int32((objsym.offset+objsym.objsection.MemPos)+objreloc.Addend));
+                          end;
+                        else
+                          internalerror(2024010110);
+                      end;
+                    end;
                   else
                     Writeln('Symbol relocation not yet implemented! ', objreloc.typ);
                 end;