Răsfoiți Sursa

* Added on option to implement library based smartlinking of the dead stripable vectorized lists (e.g. resource strings index). By default smartlinking of such lists only supported when the section based smartlinking (tf_smartlink_sections) is enabled for a target.

git-svn-id: trunk@46479 -
yury 5 ani în urmă
părinte
comite
764227193a
3 a modificat fișierele cu 36 adăugiri și 20 ștergeri
  1. 31 12
      compiler/aasmcnst.pas
  2. 3 6
      compiler/cresstr.pas
  3. 2 2
      compiler/llvm/nllvmtcon.pas

+ 31 - 12
compiler/aasmcnst.pas

@@ -295,6 +295,8 @@ type
      { get a label in the middle of an internal data section (no dead
      { get a label in the middle of an internal data section (no dead
        stripping) }
        stripping) }
      function get_internal_data_section_internal_label: tasmlabel; virtual;
      function get_internal_data_section_internal_label: tasmlabel; virtual;
+     { adds a new entry to current_module.linkorderedsymbols }
+     procedure add_link_ordered_symbol(sym: tasmsymbol; const secname: TSymStr); virtual;
 
 
      { easy access to the top level aggregate information instance }
      { easy access to the top level aggregate information instance }
      property curagginfo: taggregateinformation read getcurragginfo;
      property curagginfo: taggregateinformation read getcurragginfo;
@@ -336,11 +338,13 @@ type
      procedure insert_marked_aggregate_alignment(def: tdef); virtual; abstract;
      procedure insert_marked_aggregate_alignment(def: tdef); virtual; abstract;
      class function get_vectorized_dead_strip_section_symbol(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions; start: boolean): tasmsymbol; virtual;
      class function get_vectorized_dead_strip_section_symbol(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions; start: boolean): tasmsymbol; virtual;
     public
     public
-     class function get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; out secname: TSymStr): boolean; virtual;
+     class function get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; options: ttcasmlistoptions; out secname: TSymStr): boolean; virtual;
      { get the start/end symbol for a dead stripable vectorized section, such
      { get the start/end symbol for a dead stripable vectorized section, such
        as the resourcestring data of a unit }
        as the resourcestring data of a unit }
      class function get_vectorized_dead_strip_section_symbol_start(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions): tasmsymbol; virtual;
      class function get_vectorized_dead_strip_section_symbol_start(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions): tasmsymbol; virtual;
      class function get_vectorized_dead_strip_section_symbol_end(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions): tasmsymbol; virtual;
      class function get_vectorized_dead_strip_section_symbol_end(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions): tasmsymbol; virtual;
+     { returns true if smartlinking of the dead stripable vectorized lists is supported }
+     class function is_smartlink_vectorized_dead_strip: boolean; virtual;
 
 
      class function get_dynstring_rec_name(typ: tstringtype; winlike: boolean; len: asizeint): TSymStr;
      class function get_dynstring_rec_name(typ: tstringtype; winlike: boolean; len: asizeint): TSymStr;
      class function get_dynstring_rec(typ: tstringtype; winlike: boolean; len: asizeint): trecorddef;
      class function get_dynstring_rec(typ: tstringtype; winlike: boolean; len: asizeint): trecorddef;
@@ -918,6 +922,12 @@ implementation
      end;
      end;
 
 
 
 
+   procedure ttai_typedconstbuilder.add_link_ordered_symbol(sym: tasmsymbol; const secname: TSymStr);
+     begin
+       current_module.linkorderedsymbols.concat(sym.Name);
+     end;
+
+
    function ttai_typedconstbuilder.aggregate_kind(def: tdef): ttypedconstkind;
    function ttai_typedconstbuilder.aggregate_kind(def: tdef): ttypedconstkind;
      begin
      begin
        if (def.typ in [recorddef,filedef,variantdef]) or
        if (def.typ in [recorddef,filedef,variantdef]) or
@@ -977,14 +987,7 @@ implementation
            new_section(prelist,section,secname,alignment);
            new_section(prelist,section,secname,alignment);
          end
          end
        else if tcalo_new_section in options then
        else if tcalo_new_section in options then
-         begin
-           { insert ait_cutobject for smart-linking on targets
-             that do not support smarlinking based on sections,
-             like msdos }
-           if not (tf_smartlink_sections in target_info.flags) then
-             maybe_new_object_file(prelist);
-           new_section(prelist,section,secname,alignment);
-         end
+         new_section(prelist,section,secname,alignment)
        else
        else
          prelist.concat(cai_align.Create(alignment));
          prelist.concat(cai_align.Create(alignment));
 
 
@@ -1069,7 +1072,7 @@ implementation
      begin
      begin
        fvectorized_finalize_called:=true;
        fvectorized_finalize_called:=true;
        sym:=nil;
        sym:=nil;
-       customsecname:=get_vectorized_dead_strip_custom_section_name(basename,st,secname);
+       customsecname:=get_vectorized_dead_strip_custom_section_name(basename,st,options,secname);
        if customsecname then
        if customsecname then
          sectype:=sec_user
          sectype:=sec_user
        else
        else
@@ -1110,7 +1113,17 @@ implementation
              secname:=make_mangledname(basename,st,'2_'+itemname);
              secname:=make_mangledname(basename,st,'2_'+itemname);
            exclude(options,tcalo_vectorized_dead_strip_item);
            exclude(options,tcalo_vectorized_dead_strip_item);
          end;
          end;
-       current_module.linkorderedsymbols.concat(sym.Name);
+       add_link_ordered_symbol(sym,secname);
+       if is_smartlink_vectorized_dead_strip then
+         options:=options+[tcalo_new_section,tcalo_make_dead_strippable]
+       else
+         begin
+           { if smartlinking of vectorized lists is not supported,
+             put the whole list into a single section. }
+           options:=options-[tcalo_new_section,tcalo_make_dead_strippable];
+           if tcalo_vectorized_dead_strip_start in options then
+             include(options,tcalo_new_section);
+         end;
        finalize_asmlist(sym,def,sectype,secname,alignment,options);
        finalize_asmlist(sym,def,sectype,secname,alignment,options);
      end;
      end;
 
 
@@ -1547,7 +1560,7 @@ implementation
      end;
      end;
 
 
 
 
-   class function ttai_typedconstbuilder.get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; out secname: TSymStr): boolean;
+   class function ttai_typedconstbuilder.get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; options: ttcasmlistoptions; out secname: TSymStr): boolean;
      begin
      begin
        result:=false;
        result:=false;
      end;
      end;
@@ -1565,6 +1578,12 @@ implementation
      end;
      end;
 
 
 
 
+   class function ttai_typedconstbuilder.is_smartlink_vectorized_dead_strip: boolean;
+     begin
+       result:=tf_smartlink_sections in target_info.flags;
+     end;
+
+
    class function ttai_typedconstbuilder.get_dynstring_rec_name(typ: tstringtype; winlike: boolean; len: asizeint): TSymStr;
    class function ttai_typedconstbuilder.get_dynstring_rec_name(typ: tstringtype; winlike: boolean; len: asizeint): TSymStr;
      begin
      begin
        case typ of
        case typ of

+ 3 - 6
compiler/cresstr.pas

@@ -139,10 +139,7 @@ uses
       begin
       begin
         resstrdef:=search_system_type('TRESOURCESTRINGRECORD').typedef;
         resstrdef:=search_system_type('TRESOURCESTRINGRECORD').typedef;
 
 
-        { Put resourcestrings in a new objectfile. Putting it in multiple files
-          makes the linking too dependent on the linker script requiring a SORT(*) for
-          the data sections }
-        tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section,tcalo_vectorized_dead_strip_start,tcalo_data_force_indirect,tcalo_is_public_asm]);
+        tcb:=ctai_typedconstbuilder.create([tcalo_vectorized_dead_strip_start,tcalo_data_force_indirect,tcalo_is_public_asm]);
         { Write unitname entry }
         { Write unitname entry }
         tcb.maybe_begin_aggregate(resstrdef);
         tcb.maybe_begin_aggregate(resstrdef);
         namelab:=tcb.emit_ansistring_const(current_asmdata.asmlists[al_const],@current_module.localsymtable.name^[1],length(current_module.localsymtable.name^),getansistringcodepage);
         namelab:=tcb.emit_ansistring_const(current_asmdata.asmlists[al_const],@current_module.localsymtable.name^[1],length(current_module.localsymtable.name^),getansistringcodepage);
@@ -162,7 +159,7 @@ uses
         R:=TResourceStringItem(List.First);
         R:=TResourceStringItem(List.First);
         while assigned(R) do
         while assigned(R) do
           begin
           begin
-            tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_vectorized_dead_strip_item,tcalo_data_force_indirect]);
+            tcb:=ctai_typedconstbuilder.create([tcalo_vectorized_dead_strip_item,tcalo_data_force_indirect]);
             if assigned(R.value) and (R.len<>0) then
             if assigned(R.value) and (R.len<>0) then
               valuelab:=tcb.emit_ansistring_const(current_asmdata.asmlists[al_const],R.Value,R.Len,getansistringcodepage)
               valuelab:=tcb.emit_ansistring_const(current_asmdata.asmlists[al_const],R.Value,R.Len,getansistringcodepage)
             else
             else
@@ -194,7 +191,7 @@ uses
             R:=TResourceStringItem(R.Next);
             R:=TResourceStringItem(R.Next);
             tcb.free;
             tcb.free;
           end;
           end;
-        tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_vectorized_dead_strip_end,tcalo_data_force_indirect,tcalo_is_public_asm]);
+        tcb:=ctai_typedconstbuilder.create([tcalo_vectorized_dead_strip_end,tcalo_data_force_indirect,tcalo_is_public_asm]);
         tcb.begin_anonymous_record(internaltypeprefixName[itp_emptyrec],
         tcb.begin_anonymous_record(internaltypeprefixName[itp_emptyrec],
           default_settings.packrecords,sizeof(pint),
           default_settings.packrecords,sizeof(pint),
           targetinfos[target_info.system]^.alignment.recordalignmin);
           targetinfos[target_info.system]^.alignment.recordalignmin);

+ 2 - 2
compiler/llvm/nllvmtcon.pas

@@ -113,7 +113,7 @@ interface
       procedure queue_emit_asmsym(sym: tasmsymbol; def: tdef); override;
       procedure queue_emit_asmsym(sym: tasmsymbol; def: tdef); override;
       procedure queue_emit_ordconst(value: int64; def: tdef); override;
       procedure queue_emit_ordconst(value: int64; def: tdef); override;
 
 
-      class function get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; out secname: TSymStr): boolean; override;
+      class function get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; options: ttcasmlistoptions; out secname: TSymStr): boolean; override;
 
 
       function emit_placeholder(def: tdef): ttypedconstplaceholder; override;
       function emit_placeholder(def: tdef): ttypedconstplaceholder; override;
 
 
@@ -845,7 +845,7 @@ implementation
     end;
     end;
 
 
 
 
-  class function tllvmtai_typedconstbuilder.get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; out secname: TSymStr): boolean;
+  class function tllvmtai_typedconstbuilder.get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; options: ttcasmlistoptions; out secname: TSymStr): boolean;
     begin
     begin
       result:=inherited;
       result:=inherited;
       if result then
       if result then