Преглед на файлове

* support specifying the name of an internal data section

git-svn-id: branches/hlcgllvm@30341 -
Jonas Maebe преди 10 години
родител
ревизия
6ed273eec5
променени са 2 файла, в които са добавени 14 реда и са изтрити 6 реда
  1. 12 4
      compiler/aasmcnst.pas
  2. 2 2
      compiler/ngtcon.pas

+ 12 - 4
compiler/aasmcnst.pas

@@ -243,8 +243,9 @@ type
      { returns a builder for generating data that is only referrenced by the
        typed constant date we are currently generating (e.g. string data for a
        pchar constant). Also returns the label that will be placed at the start
-       of that data. list is the tasmlist to which the data will be }
-     procedure start_internal_data_builder(list: tasmlist; sectype: TAsmSectiontype; out tcb: ttai_typedconstbuilder; out l: tasmlabel);
+       of that data. list is the tasmlist to which the data will be added.
+       secname can be empty to use a default }
+     procedure start_internal_data_builder(list: tasmlist; sectype: TAsmSectiontype; const secname: TSymStr; out tcb: ttai_typedconstbuilder; out l: tasmlabel);
      { finish a previously started internal data builder, including
        concatenating all generated data to the provided list and freeing the
        builder }
@@ -836,7 +837,7 @@ implementation
      end;
 
 
-   procedure ttai_typedconstbuilder.start_internal_data_builder(list: tasmlist; sectype: TAsmSectiontype; out tcb: ttai_typedconstbuilder; out l: tasmlabel);
+   procedure ttai_typedconstbuilder.start_internal_data_builder(list: tasmlist; sectype: TAsmSectiontype; const secname: TSymStr; out tcb: ttai_typedconstbuilder; out l: tasmlabel);
      var
        options: ttcasmlistoptions;
        foundsec: longint;
@@ -913,7 +914,14 @@ implementation
            current_asmdata.getlocaldatalabel(l);
        { first section of this kind -> set name }
        if finternal_data_section_info[foundsec].secname='' then
-         finternal_data_section_info[foundsec].secname:=l.Name;
+         if secname='' then
+           finternal_data_section_info[foundsec].secname:=l.Name
+         else
+           finternal_data_section_info[foundsec].secname:=secname
+       { if the name is specified multiple times, it must match }
+       else if (secname<>'') and
+               (finternal_data_section_info[foundsec].secname<>secname) then
+         internalerror(2015032401);
        tcb:=ttai_typedconstbuilderclass(classtype).create(options);
      end;
 

+ 2 - 2
compiler/ngtcon.pas

@@ -804,7 +804,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
             begin
               { create a tcb for the string data (it's placed in a separate
                 asmlist) }
-              ftcb.start_internal_data_builder(fdatalist,sec_rodata,datatcb,ll);
+              ftcb.start_internal_data_builder(fdatalist,sec_rodata,'',datatcb,ll);
               if node.nodetype=stringconstn then
                 varalign:=size_2_align(tstringconstnode(node).len)
               else
@@ -862,7 +862,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                    begin
                      { create a tcb for the string data (it's placed in a separate
                        asmlist) }
-                     ftcb.start_internal_data_builder(fdatalist,sec_rodata,datatcb,ll);
+                     ftcb.start_internal_data_builder(fdatalist,sec_rodata,'',datatcb,ll);
                      datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
                      { include terminating #0 }