فهرست منبع

* omf segment class names moved to a const array in omfbase, so they can be used
(in the future) in the nasm asm writer as well

git-svn-id: trunk@31483 -

nickysn 10 سال پیش
والد
کامیت
2e6d462ff6
3فایلهای تغییر یافته به همراه88 افزوده شده و 23 حذف شده
  1. 1 1
      compiler/ogbase.pas
  2. 18 22
      compiler/ogomf.pas
  3. 69 0
      compiler/omfbase.pas

+ 1 - 1
compiler/ogbase.pas

@@ -322,7 +322,7 @@ interface
        function  sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;virtual;abstract;
        function  sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;virtual;abstract;
        function  sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;virtual;
        function  sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;virtual;
        function  sectiontype2align(atype:TAsmSectiontype):shortint;virtual;
        function  sectiontype2align(atype:TAsmSectiontype):shortint;virtual;
-       function  createsection(atype:TAsmSectionType;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection;
+       function  createsection(atype:TAsmSectionType;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection;virtual;
        function  createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions;DiscardDuplicate:boolean=true):TObjSection;virtual;
        function  createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions;DiscardDuplicate:boolean=true):TObjSection;virtual;
        function  createsectiongroup(const aname:string):TObjSectionGroup;
        function  createsectiongroup(const aname:string):TObjSectionGroup;
        procedure CreateDebugSections;virtual;
        procedure CreateDebugSections;virtual;

+ 18 - 22
compiler/ogomf.pas

@@ -101,7 +101,9 @@ interface
       public
       public
         constructor create(const n:string);override;
         constructor create(const n:string);override;
         function sectiontype2align(atype:TAsmSectiontype):shortint;override;
         function sectiontype2align(atype:TAsmSectiontype):shortint;override;
+        function sectiontype2class(atype:TAsmSectiontype):string;
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
+        function createsection(atype:TAsmSectionType;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection;override;
         procedure writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
         procedure writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
       end;
       end;
 
 
@@ -474,45 +476,28 @@ implementation
         FCombination:=scPublic;
         FCombination:=scPublic;
         FUse:=suUse16;
         FUse:=suUse16;
         if oso_executable in Aoptions then
         if oso_executable in Aoptions then
-          begin
-            FClassName:='CODE';
-            dgroup:=(current_settings.x86memorymodel=mm_tiny);
-          end
+          dgroup:=(current_settings.x86memorymodel=mm_tiny)
         else if Aname='stack' then
         else if Aname='stack' then
           begin
           begin
-            FClassName:='STACK';
             FCombination:=scStack;
             FCombination:=scStack;
             dgroup:=current_settings.x86memorymodel in (x86_near_data_models-[mm_tiny]);
             dgroup:=current_settings.x86memorymodel in (x86_near_data_models-[mm_tiny]);
           end
           end
         else if Aname='heap' then
         else if Aname='heap' then
-          begin
-            FClassName:='HEAP';
-            dgroup:=current_settings.x86memorymodel in x86_near_data_models;
-          end
+          dgroup:=current_settings.x86memorymodel in x86_near_data_models
         else if Aname='bss' then
         else if Aname='bss' then
-          begin
-            FClassName:='BSS';
-            dgroup:=true;
-          end
+          dgroup:=true
         else if Aname='data' then
         else if Aname='data' then
-          begin
-            FClassName:='DATA';
-            dgroup:=true;
-          end
+          dgroup:=true
         else if (Aname='debug_frame') or
         else if (Aname='debug_frame') or
                 (Aname='debug_info') or
                 (Aname='debug_info') or
                 (Aname='debug_line') or
                 (Aname='debug_line') or
                 (Aname='debug_abbrev') then
                 (Aname='debug_abbrev') then
           begin
           begin
-            FClassName:='DWARF';
             FUse:=suUse32;
             FUse:=suUse32;
             dgroup:=false;
             dgroup:=false;
           end
           end
         else
         else
-          begin
-            FClassName:='DATA';
-            dgroup:=true;
-          end;
+          dgroup:=true;
         if dgroup then
         if dgroup then
           FPrimaryGroup:='DGROUP'
           FPrimaryGroup:='DGROUP'
         else
         else
@@ -581,6 +566,11 @@ implementation
         end;
         end;
       end;
       end;
 
 
+    function TOmfObjData.sectiontype2class(atype: TAsmSectiontype): string;
+      begin
+        Result:=omf_segclass[atype];
+      end;
+
     function TOmfObjData.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
     function TOmfObjData.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
       begin
       begin
         if (atype=sec_user) then
         if (atype=sec_user) then
@@ -591,6 +581,12 @@ implementation
           Result:=omf_secnames[atype];
           Result:=omf_secnames[atype];
       end;
       end;
 
 
+    function TOmfObjData.createsection(atype: TAsmSectionType; const aname: string; aorder: TAsmSectionOrder): TObjSection;
+      begin
+        Result:=inherited createsection(atype, aname, aorder);
+        TOmfObjSection(Result).FClassName:=sectiontype2class(atype);
+      end;
+
     procedure TOmfObjData.writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
     procedure TOmfObjData.writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
       var
       var
         objreloc: TOmfRelocation;
         objreloc: TOmfRelocation;

+ 69 - 0
compiler/omfbase.pas

@@ -88,6 +88,75 @@ interface
       'stack',
       'stack',
       'heap'
       'heap'
     );
     );
+    { OMF segment class names for the object sections, produced by the FPC code generator }
+    omf_segclass : array[TAsmSectiontype] of string[length('DWARF')] = ('',
+      {user} 'DATA',
+      {code} 'CODE',
+      {data} 'DATA',
+      {rodata} 'DATA',
+      {rodata_norel} 'DATA',
+      {bss} 'BSS',
+      {threadvar} 'DATA',
+      {pdata} 'DATA',
+      {stub} 'CODE',
+      {data_nonlazy} 'DATA',
+      {data_lazy} 'DATA',
+      {init_func} 'DATA',
+      {term_func} 'DATA',
+      {stab} 'DATA',
+      {stabstr} 'DATA',
+      {idata2} 'DATA',
+      {idata4} 'DATA',
+      {idata5} 'DATA',
+      {idata6} 'DATA',
+      {idata7} 'DATA',
+      {edata} 'DATA',
+      {eh_frame} 'DATA',
+      {debug_frame} 'DWARF',
+      {debug_info} 'DWARF',
+      {debug_line} 'DWARF',
+      {debug_abbrev} 'DWARF',
+      {fpc} 'DATA',
+      {toc} 'DATA',
+      {init} 'CODE',
+      {fini} 'CODE',
+      {objc_class} 'DATA',
+      {objc_meta_class} 'DATA',
+      {objc_cat_cls_meth} 'DATA',
+      {objc_cat_inst_meth} 'DATA',
+      {objc_protocol} 'DATA',
+      {objc_string_object} 'DATA',
+      {objc_cls_meth} 'DATA',
+      {objc_inst_meth} 'DATA',
+      {objc_cls_refs} 'DATA',
+      {objc_message_refs} 'DATA',
+      {objc_symbols} 'DATA',
+      {objc_category} 'DATA',
+      {objc_class_vars} 'DATA',
+      {objc_instance_vars} 'DATA',
+      {objc_module_info} 'DATA',
+      {objc_class_names} 'DATA',
+      {objc_meth_var_types} 'DATA',
+      {objc_meth_var_names} 'DATA',
+      {objc_selector_strs} 'DATA',
+      {objc_protocol_ext} 'DATA',
+      {objc_class_ext} 'DATA',
+      {objc_property} 'DATA',
+      {objc_image_info} 'DATA',
+      {objc_cstring_object} 'DATA',
+      {objc_sel_fixup} 'DATA',
+      {objc_data} 'DATA',
+      {objc_const} 'DATA',
+      {objc_sup_refs} 'DATA',
+      {data_coalesced} 'DATA',
+      {objc_classlist} 'DATA',
+      {objc_nlclasslist} 'DATA',
+      {objc_catlist} 'DATA',
+      {objc_nlcatlist} 'DATA',
+      {objc_protolist} 'DATA',
+      {stack} 'STACK',
+      {heap} 'HEAP'
+    );
 
 
     { OMF record types }
     { OMF record types }
     RT_THEADR    = $80;  { Translator Header Record }
     RT_THEADR    = $80;  { Translator Header Record }