Browse Source

+ started parsing of custom sections - known custom sections are dispatched to
a specialized parsing function for each of them, while unknown custom sections
(currently the ones, not produced by FPC) produce an error

Nikolay Nikolov 1 year ago
parent
commit
5a5abe2419
1 changed files with 39 additions and 0 deletions
  1. 39 0
      compiler/ogwasm.pas

+ 39 - 0
compiler/ogwasm.pas

@@ -2225,8 +2225,47 @@ implementation
           DataCount: uint32;
           DataCount: uint32;
 
 
         function ReadCustomSection: Boolean;
         function ReadCustomSection: Boolean;
+
+          function ReadRelocationSection: Boolean;
+            begin
+              Result:=False;
+            end;
+
+          function ReadLinkingSection: Boolean;
+            begin
+              Result:=False;
+            end;
+
+          function ReadProducersSection: Boolean;
+            begin
+              Result:=False;
+            end;
+
+          function ReadTargetFeaturesSection: Boolean;
+            begin
+              Result:=False;
+            end;
+
+          const
+            RelocationSectionPrefix = 'reloc.';
+          var
+            SectionName: ansistring;
           begin
           begin
             Result:=False;
             Result:=False;
+            ReadName(SectionName);
+            if Copy(SectionName,1,Length(RelocationSectionPrefix)) = RelocationSectionPrefix then
+              Result:=ReadRelocationSection
+            else
+              case SectionName of
+                'linking':
+                  Result:=ReadLinkingSection;
+                'producers':
+                  Result:=ReadProducersSection;
+                'target_features':
+                  Result:=ReadTargetFeaturesSection;
+                else
+                  InputError('Unsupported custom section: ''' + SectionName + '''');
+              end;
           end;
           end;
 
 
         function ReadTypeSection: Boolean;
         function ReadTypeSection: Boolean;