2
0
Эх сурвалжийг харах

Extend the ttypedconstbuilder's dead_stripe_section handling (get_vectorized_dead_strip_section_symbol() and finalize_vectorized_dead_strip_asmlist()) with the ability to
- register a symbol in the unit's public or extern asm symbol list
- add an indirect symbol when defining the symbol
- use an indirect symbol instead of the direct one
This will be needed to correctly handle resourcestrings for packages

git-svn-id: trunk@34182 -

svenbarth 9 жил өмнө
parent
commit
4df4449933

+ 48 - 15
compiler/aasmcnst.pas

@@ -128,10 +128,24 @@ type
      { end of the above list }
      { end of the above list }
      tcalo_vectorized_dead_strip_end,
      tcalo_vectorized_dead_strip_end,
      { symbol should be weakle defined }
      { symbol should be weakle defined }
-     tcalo_weak
+     tcalo_weak,
+     { symbol should be registered with the unit's public assembler symbols }
+     tcalo_is_public_asm,
+     { symbol should be declared with AT_DATA_FORCEINDIRECT }
+     tcalo_data_force_indirect
    );
    );
    ttcasmlistoptions = set of ttcasmlistoption;
    ttcasmlistoptions = set of ttcasmlistoption;
 
 
+   ttcdeadstripsectionsymboloption = (
+     { define the symbol }
+     tcdssso_define,
+     { register the assembler symbol either with the public or extern assembler
+       symbols of the unit }
+     tcdssso_register_asmsym,
+     { use the indirect symbol }
+     tcdssso_use_indirect
+   );
+  ttcdeadstripsectionsymboloptions = set of ttcdeadstripsectionsymboloption;
 
 
    { information about aggregates we are parsing }
    { information about aggregates we are parsing }
    taggregateinformation = class
    taggregateinformation = class
@@ -313,13 +327,13 @@ type
        the anonymous record, and insert the alignment once it's finished }
        the anonymous record, and insert the alignment once it's finished }
      procedure mark_anon_aggregate_alignment; virtual; abstract;
      procedure mark_anon_aggregate_alignment; virtual; abstract;
      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; define, 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; 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; define: boolean): tasmsymbol; virtual;
-     class function get_vectorized_dead_strip_section_symbol_end(const basename: string; st: tsymtable; define: boolean): 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_dynstring_rec_name(typ: tstringtype; winlike: boolean; len: asizeint): string;
      class function get_dynstring_rec_name(typ: tstringtype; winlike: boolean; len: asizeint): string;
      { the datalist parameter specifies where the data for the string constant
      { the datalist parameter specifies where the data for the string constant
@@ -964,7 +978,9 @@ implementation
        sym: tasmsymbol;
        sym: tasmsymbol;
        secname: TSymStr;
        secname: TSymStr;
        sectype: TAsmSectiontype;
        sectype: TAsmSectiontype;
+       asmtype : TAsmsymtype;
        customsecname: boolean;
        customsecname: boolean;
+       dsopts : ttcdeadstripsectionsymboloptions;
      begin
      begin
        fvectorized_finalize_called:=true;
        fvectorized_finalize_called:=true;
        sym:=nil;
        sym:=nil;
@@ -973,12 +989,15 @@ implementation
          sectype:=sec_user
          sectype:=sec_user
        else
        else
          sectype:=sec_data;
          sectype:=sec_data;
+       dsopts:=[tcdssso_define];
+       if tcalo_is_public_asm in options then
+         include(dsopts,tcdssso_register_asmsym);
        if tcalo_vectorized_dead_strip_start in options then
        if tcalo_vectorized_dead_strip_start in options then
          begin
          begin
            { the start and end names are predefined }
            { the start and end names are predefined }
            if itemname<>'' then
            if itemname<>'' then
              internalerror(2015110801);
              internalerror(2015110801);
-           sym:=get_vectorized_dead_strip_section_symbol_start(basename,st,true);
+           sym:=get_vectorized_dead_strip_section_symbol_start(basename,st,dsopts);
            if not customsecname then
            if not customsecname then
              secname:=make_mangledname(basename,st,'1_START');
              secname:=make_mangledname(basename,st,'1_START');
          end
          end
@@ -987,13 +1006,19 @@ implementation
            { the start and end names are predefined }
            { the start and end names are predefined }
            if itemname<>'' then
            if itemname<>'' then
              internalerror(2015110802);
              internalerror(2015110802);
-           sym:=get_vectorized_dead_strip_section_symbol_end(basename,st,true);
+           sym:=get_vectorized_dead_strip_section_symbol_end(basename,st,dsopts);
            if not customsecname then
            if not customsecname then
              secname:=make_mangledname(basename,st,'3_END');
              secname:=make_mangledname(basename,st,'3_END');
          end
          end
        else if tcalo_vectorized_dead_strip_item in options then
        else if tcalo_vectorized_dead_strip_item in options then
          begin
          begin
-           sym:=current_asmdata.DefineAsmSymbol(make_mangledname(basename,st,itemname),AB_GLOBAL,AT_DATA,def);
+           if tcalo_data_force_indirect in options then
+             asmtype:=AT_DATA_FORCEINDIRECT
+           else
+             asmtype:=AT_DATA;
+           sym:=current_asmdata.DefineAsmSymbol(make_mangledname(basename,st,itemname),AB_GLOBAL,asmtype,def);
+           if tcalo_is_public_asm in options then
+             current_module.add_public_asmsym(sym);
            if not customsecname then
            if not customsecname then
              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);
@@ -1373,7 +1398,7 @@ implementation
      end;
      end;
 
 
 
 
-   class function ttai_typedconstbuilder.get_vectorized_dead_strip_section_symbol(const basename: string; st: tsymtable; define, start: boolean): tasmsymbol;
+   class function ttai_typedconstbuilder.get_vectorized_dead_strip_section_symbol(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions; start: boolean): tasmsymbol;
      var
      var
        name: TSymStr;
        name: TSymStr;
      begin
      begin
@@ -1381,10 +1406,18 @@ implementation
          name:=make_mangledname(basename,st,'START')
          name:=make_mangledname(basename,st,'START')
        else
        else
          name:=make_mangledname(basename,st,'END');
          name:=make_mangledname(basename,st,'END');
-       if define then
-         result:=current_asmdata.DefineAsmSymbol(name,AB_GLOBAL,AT_DATA,voidpointertype)
+       if tcdssso_define in options then
+         begin
+           result:=current_asmdata.DefineAsmSymbol(name,AB_GLOBAL,AT_DATA,voidpointertype);
+           if tcdssso_register_asmsym in options then
+             current_module.add_public_asmsym(result);
+         end
        else
        else
-         result:=current_asmdata.RefAsmSymbol(name,AT_DATA)
+         begin
+           result:=current_asmdata.RefAsmSymbol(name,AT_DATA,tcdssso_use_indirect in options);
+           if tcdssso_register_asmsym in options then
+             current_module.add_extern_asmsym(result);
+         end;
      end;
      end;
 
 
 
 
@@ -1394,15 +1427,15 @@ implementation
      end;
      end;
 
 
 
 
-   class function ttai_typedconstbuilder.get_vectorized_dead_strip_section_symbol_start(const basename: string; st: tsymtable; define: boolean): tasmsymbol;
+   class function ttai_typedconstbuilder.get_vectorized_dead_strip_section_symbol_start(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions): tasmsymbol;
      begin
      begin
-       result:=get_vectorized_dead_strip_section_symbol(basename,st,define,true);
+       result:=get_vectorized_dead_strip_section_symbol(basename,st,options,true);
      end;
      end;
 
 
 
 
-   class function ttai_typedconstbuilder.get_vectorized_dead_strip_section_symbol_end(const basename: string; st: tsymtable; define: boolean): tasmsymbol;
+   class function ttai_typedconstbuilder.get_vectorized_dead_strip_section_symbol_end(const basename: string; st: tsymtable; options: ttcdeadstripsectionsymboloptions): tasmsymbol;
      begin
      begin
-       result:=get_vectorized_dead_strip_section_symbol(basename,st,define,false);
+       result:=get_vectorized_dead_strip_section_symbol(basename,st,options,false);
      end;
      end;
 
 
 
 

+ 2 - 2
compiler/ngenutil.pas

@@ -1250,11 +1250,11 @@ implementation
           If (hp.flags and uf_has_resourcestrings)=uf_has_resourcestrings then
           If (hp.flags and uf_has_resourcestrings)=uf_has_resourcestrings then
             begin
             begin
               tcb.emit_tai(Tai_const.Create_sym(
               tcb.emit_tai(Tai_const.Create_sym(
-                ctai_typedconstbuilder.get_vectorized_dead_strip_section_symbol_start('RESSTR',hp.localsymtable,false)),
+                ctai_typedconstbuilder.get_vectorized_dead_strip_section_symbol_start('RESSTR',hp.localsymtable,[])),
                 voidpointertype
                 voidpointertype
               );
               );
               tcb.emit_tai(Tai_const.Create_sym(
               tcb.emit_tai(Tai_const.Create_sym(
-                ctai_typedconstbuilder.get_vectorized_dead_strip_section_symbol_end('RESSTR',hp.localsymtable,false)),
+                ctai_typedconstbuilder.get_vectorized_dead_strip_section_symbol_end('RESSTR',hp.localsymtable,[])),
                 voidpointertype
                 voidpointertype
               );
               );
               inc(count);
               inc(count);