Browse Source

* wasm internal linker: skip the element section when reading object files. This fixes linking with object modules, produced by the external assembler.

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

+ 21 - 0
compiler/ogwasm.pas

@@ -2366,6 +2366,7 @@ implementation
         FunctionSectionRead: Boolean = false;
         GlobalSectionRead: Boolean = false;
         ExportSectionRead: Boolean = false;
+        ElementSectionRead: Boolean = false;
         CodeSectionRead: Boolean = false;
         DataSectionRead: Boolean = false;
         DataCountSectionRead: Boolean = false;
@@ -3646,6 +3647,20 @@ implementation
             Result:=True;
           end;
 
+        function ReadElementSection: Boolean;
+          begin
+            Result:=False;
+            if ElementSectionRead then
+              begin
+                InputError('Element section is duplicated');
+                exit;
+              end;
+            ElementSectionRead:=True;
+            { We skip the element section for now }
+            { TODO: implement reading it (and linking of tables) }
+            Result:=True;
+          end;
+
         function ReadCodeSection: Boolean;
           var
             CodeEntriesCount: uint32;
@@ -3910,6 +3925,12 @@ implementation
                   InputError('Error reading the export section');
                   exit;
                 end;
+            Byte(wsiElement):
+              if not ReadElementSection then
+                begin
+                  InputError('Error reading the element section');
+                  exit;
+                end;
             Byte(wsiCode):
               if not ReadCodeSection then
                 begin