Browse Source

[PATCH 064/188] adding asm symbol information

From ec452f59689819ca9c1e31f13baef371ebb8d972 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Tue, 3 Mar 2020 16:56:20 -0500

git-svn-id: branches/wasm@46060 -
nickysn 5 years ago
parent
commit
f513a5556e
2 changed files with 40 additions and 0 deletions
  1. 16 0
      utils/wasmbin/wasmmodule.pas
  2. 24 0
      utils/wasmbin/watparser.pas

+ 16 - 0
utils/wasmbin/wasmmodule.pas

@@ -6,6 +6,19 @@ uses
   Classes, SysUtils, wasmbin, wasmbincode;
 
 type
+  TLinkBind = (lbUndefined = 0
+               ,lbWeak
+               ,lbLocal
+               ,lbForHost
+               );
+
+  TLinkInfo = record
+    Name        : string;
+    Binding     : TLinkBind;
+    isHidden    : Boolean;
+    isUndefined : Boolean;
+    NoStrip     : Boolean;
+  end;
 
   { TWasmParam }
 
@@ -28,6 +41,9 @@ type
   public
     typeNum : Integer; // if Idx < 0 then type is declared from typeDef
     typeIdx : string;  // if typeID='' then type is declared from typeDef
+
+    // linking information
+    LinkInfo : TLinkInfo;
     constructor Create;
     destructor Destroy; override;
     function AddResult(tp: byte = 0): TWasmParam;

+ 24 - 0
utils/wasmbin/watparser.pas

@@ -61,6 +61,7 @@ type
     count : integer;
     procedure Push(const AName, AValue: string);
     procedure Clear;
+    procedure ToLinkInfo(var AInfo: TLinkInfo);
   end;
 
 const
@@ -428,6 +429,29 @@ begin
   count:=0;
 end;
 
+procedure TAsmSymList.ToLinkInfo(var AInfo: TLinkInfo);
+var
+  i : integer;
+begin
+  for i:=0 to count-1 do begin
+    if syms[i].name = '.name' then
+      AInfo.Name := syms[i].value
+    else if syms[i].name = '.weak' then
+      AInfo.Binding := lbWeak
+    else if syms[i].name = '.local' then
+      AInfo.Binding := lbLocal
+    else if syms[i].name = '.hidden' then
+      Ainfo.isHidden := true
+    else if syms[i].name = '.undef' then
+      AInfo.isUndefined := true
+    else if syms[i].name = '.strong' then
+      AInfo.NoStrip := true
+    else if syms[i].name = '.forhost' then
+      AInfo.Binding := lbForHost;
+  end;
+
+end;
+
 { EParserError }
 
 constructor EParserError.Create(const amsg: string; aofs: integer);