Przeglądaj źródła

+ custom section name support for llvm

git-svn-id: trunk@32400 -
Jonas Maebe 9 lat temu
rodzic
commit
91e8f4c439

+ 10 - 0
compiler/llvm/aasmllvm.pas

@@ -165,9 +165,11 @@ interface
       sec: TAsmSectiontype;
       alignment: shortint;
       flags: taillvmdeclflags;
+      secname: TSymStr;
       constructor createdecl(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
       constructor createdef(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
       constructor createtls(_namesym: tasmsymbol; _def: tdef; _alignment: shortint);
+      procedure setsecname(const name: TSymStr);
       destructor destroy; override;
     end;
 
@@ -221,6 +223,14 @@ uses
       end;
 
 
+    procedure taillvmdecl.setsecname(const name: TSymStr);
+      begin
+        if sec<>sec_user then
+          internalerror(2015111501);
+        secname:=name;
+      end;
+
+
     destructor taillvmdecl.destroy;
       begin
         initdata.free;

+ 7 - 0
compiler/llvm/agllvm.pas

@@ -1001,6 +1001,13 @@ implementation
                         end;
                       dec(fdecllevel);
                     end;
+                  { custom section name? }
+                  if taillvmdecl(hp).sec=sec_user then
+                    begin
+                      writer.AsmWrite(', section "');
+                      writer.AsmWrite(taillvmdecl(hp).secname);
+                      writer.AsmWrite('"');
+                    end;
                   { alignment }
                   writer.AsmWrite(', align ');
                   writer.AsmWriteln(tostr(taillvmdecl(hp).alignment));

+ 2 - 3
compiler/llvm/nllvmtcon.pas

@@ -162,13 +162,12 @@ implementation
       newasmlist: tasmlist;
       decl: taillvmdecl;
     begin
-      { todo }
-      if section = sec_user then
-        internalerror(2014052904);
       newasmlist:=tasmlist.create;
       { llvm declaration with as initialisation data all the elements from the
         original asmlist }
       decl:=taillvmdecl.createdef(sym,def,fasmlist,section,alignment);
+      if section=sec_user then
+        decl.setsecname(secname);
       if tcalo_is_lab in options then
         include(decl.flags,ldf_unnamed_addr);
       { TODO: tcalo_no_dead_strip: add to @llvm.user meta-variable }