Browse Source

(Note to self: always include the root of the working copy in the commit when dealing with merges -.-)
Merged revision(s) 28793, 28903, 31951 from branches/svenbarth/packages:
psub.pas, read_proc:
* don't generate assembler symbols for compiler internal code
........
Ensure that unneeded initialization/finalization procedures don't leave assembler symbols.

ncgutil.pas:
+ new function release_proc_symbol which removes all assembler symbols of a procdef
pmodules.pas, proc_unit:
* if the initialization or finalization procedure is empty also remove their assembler symbols so they are exported
........
Ensure that readonly sections that need relocations are indeed declared as such.
Thanks to Jonas for this.

ncgvmt.pas, TVMTWriter:
* writeinterfaceids: use sec_rodata instead of sec_rodata_norel

........

git-svn-id: trunk@32982 -

svenbarth 9 years ago
parent
commit
557f74cdbd
4 changed files with 26 additions and 5 deletions
  1. 17 0
      compiler/ncgutil.pas
  2. 2 2
      compiler/ncgvmt.pas
  3. 6 2
      compiler/pmodules.pas
  4. 1 1
      compiler/psub.pas

+ 17 - 0
compiler/ncgutil.pas

@@ -76,6 +76,7 @@ interface
 
 
     function  has_alias_name(pd:tprocdef;const s:string):boolean;
     function  has_alias_name(pd:tprocdef;const s:string):boolean;
     procedure alloc_proc_symbol(pd: tprocdef);
     procedure alloc_proc_symbol(pd: tprocdef);
+    procedure release_proc_symbol(pd:tprocdef);
     procedure gen_proc_entry_code(list:TAsmList);
     procedure gen_proc_entry_code(list:TAsmList);
     procedure gen_proc_exit_code(list:TAsmList);
     procedure gen_proc_exit_code(list:TAsmList);
     procedure gen_stack_check_size_para(list:TAsmList);
     procedure gen_stack_check_size_para(list:TAsmList);
@@ -1363,6 +1364,22 @@ implementation
       end;
       end;
 
 
 
 
+    procedure release_proc_symbol(pd:tprocdef);
+      var
+        idx : longint;
+        item : TCmdStrListItem;
+      begin
+        item:=TCmdStrListItem(pd.aliasnames.first);
+        while assigned(item) do
+          begin
+            idx:=current_asmdata.AsmSymbolDict.findindexof(item.str);
+            if idx>=0 then
+              current_asmdata.AsmSymbolDict.Delete(idx);
+            item:=TCmdStrListItem(item.next);
+          end;
+      end;
+
+
     procedure gen_proc_entry_code(list:TAsmList);
     procedure gen_proc_entry_code(list:TAsmList);
       var
       var
         hitemp,
         hitemp,

+ 2 - 2
compiler/ncgvmt.pas

@@ -905,7 +905,7 @@ implementation
           list.concatlist(tcb.get_final_asmlist(
           list.concatlist(tcb.get_final_asmlist(
             current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
             current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
             rec_tguid,
             rec_tguid,
-            sec_rodata_norel,
+            sec_rodata,
             s,
             s,
             const_align(sizeof(pint))));
             const_align(sizeof(pint))));
           tcb.free;
           tcb.free;
@@ -916,7 +916,7 @@ implementation
       list.concatlist(tcb.get_final_asmlist(
       list.concatlist(tcb.get_final_asmlist(
         current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
         current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
         def,
         def,
-        sec_rodata_norel,
+        sec_rodata,
         s,
         s,
         sizeof(pint)));
         sizeof(pint)));
       tcb.free;
       tcb.free;

+ 6 - 2
compiler/pmodules.pas

@@ -1164,7 +1164,9 @@ type
                  init_procinfo.code:=cnodeutils.wrap_proc_body(init_procinfo.procdef,init_procinfo.code);
                  init_procinfo.code:=cnodeutils.wrap_proc_body(init_procinfo.procdef,init_procinfo.code);
                  init_procinfo.generate_code;
                  init_procinfo.generate_code;
                  current_module.flags:=current_module.flags or uf_init;
                  current_module.flags:=current_module.flags or uf_init;
-               end;
+               end
+             else
+               release_proc_symbol(init_procinfo.procdef);
              init_procinfo.resetprocdef;
              init_procinfo.resetprocdef;
              release_main_proc(init_procinfo);
              release_main_proc(init_procinfo);
            end;
            end;
@@ -1177,7 +1179,9 @@ type
                  finalize_procinfo.code:=cnodeutils.wrap_proc_body(finalize_procinfo.procdef,finalize_procinfo.code);
                  finalize_procinfo.code:=cnodeutils.wrap_proc_body(finalize_procinfo.procdef,finalize_procinfo.code);
                  finalize_procinfo.generate_code;
                  finalize_procinfo.generate_code;
                  current_module.flags:=current_module.flags or uf_finalize;
                  current_module.flags:=current_module.flags or uf_finalize;
-               end;
+               end
+             else
+               release_proc_symbol(finalize_procinfo.procdef);
              finalize_procinfo.resetprocdef;
              finalize_procinfo.resetprocdef;
              release_main_proc(finalize_procinfo);
              release_main_proc(finalize_procinfo);
            end;
            end;

+ 1 - 1
compiler/psub.pas

@@ -2202,7 +2202,7 @@ implementation
          { treated as references to external symbols, needed for darwin.   }
          { treated as references to external symbols, needed for darwin.   }
 
 
          { make sure we don't change the binding of real external symbols }
          { make sure we don't change the binding of real external symbols }
-         if ([po_external,po_weakexternal]*pd.procoptions)=[] then
+         if (([po_external,po_weakexternal]*pd.procoptions)=[]) and (pocall_internproc<>pd.proccalloption) then
            begin
            begin
              if (po_global in pd.procoptions) or
              if (po_global in pd.procoptions) or
                 (cs_profile in current_settings.moduleswitches) then
                 (cs_profile in current_settings.moduleswitches) then