diff --git a/compiler/aggas.pas b/compiler/aggas.pas index c044fe32af..90abc0902e 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -258,7 +258,7 @@ implementation '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata', '.eh_frame', '.debug_frame','.debug_info','.debug_line','.debug_abbrev', - 'fpc.resptrs', + '.fpc', '.toc' ); secnames_pic : array[TAsmSectiontype] of string[17] = ('', @@ -274,7 +274,7 @@ implementation '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata', '.eh_frame', '.debug_frame','.debug_info','.debug_line','.debug_abbrev', - 'fpc.resptrs', + '.fpc', '.toc' ); var @@ -286,6 +286,12 @@ implementation secname:=secnames_pic[atype] else secname:=secnames[atype]; + + if (atype=sec_fpc) and (Copy(aname,1,3)='res') then + begin + result:=secname+'.'+aname; + exit; + end; if (atype=sec_threadvar) and (target_info.system=system_i386_win32) then @@ -336,7 +342,8 @@ implementation AsmWrite(s); case atype of sec_fpc : - AsmWrite(', "a", @progbits'); + if aname = 'resptrs' then + AsmWrite(', "a", @progbits'); sec_stub : begin case target_info.system of diff --git a/compiler/dbgstabs.pas b/compiler/dbgstabs.pas index 213dd8132b..8484f12fcd 100644 --- a/compiler/dbgstabs.pas +++ b/compiler/dbgstabs.pas @@ -1529,10 +1529,10 @@ implementation hp : tmodule; dbgtable : tai_symbol; begin - { Reference all DEBUGINFO sections from the main .text section } + { Reference all DEBUGINFO sections from the main .fpc section } if (target_info.system=system_powerpc_macos) then exit; - list.concat(Tai_section.create(sec_data,'',0)); + list.concat(Tai_section.create(sec_fpc,'links',0)); { make sure the debuginfo doesn't get stripped out } if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then begin diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index bbcf96364e..5dee796cb2 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -233,7 +233,7 @@ interface function sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;virtual; function sectiontype2align(atype:TAsmSectiontype):shortint;virtual; function createsection(atype:TAsmSectionType;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection; - function createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions):TObjSection;virtual; + function createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions;DiscardDuplicate:boolean=true):TObjSection;virtual; procedure CreateDebugSections;virtual; function findsection(const aname:string):TObjSection; procedure setsection(asec:TObjSection); @@ -873,9 +873,12 @@ implementation end; - function TObjData.createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions):TObjSection; + function TObjData.createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions;DiscardDuplicate:boolean):TObjSection; begin - result:=TObjSection(FObjSectionList.Find(aname)); + if DiscardDuplicate then + result:=TObjSection(FObjSectionList.Find(aname)) + else + result:=nil; if not assigned(result) then begin result:=CObjSection.create(FObjSectionList,aname,aalign,aoptions); @@ -2204,12 +2207,12 @@ implementation begin exesec:=TExeSection(ExeSections[i]); if not(oso_keep in exesec.SecOptions) and - ( - (exesec.ObjSectionlist.count=0) or ( - (cs_link_strip in current_settings.globalswitches) and - (oso_debug in exesec.SecOptions) - ) + (exesec.ObjSectionlist.count=0) or + ( + (cs_link_strip in current_settings.globalswitches) and + (oso_debug in exesec.SecOptions) + ) ) then begin Comment(V_Debug,'Deleting empty section '+exesec.name); @@ -2316,7 +2319,11 @@ implementation if oso_debug in objsec.secoptions then objsec.Used:=true; if (oso_keep in objsec.secoptions) then - AddToObjSectionWorkList(objsec); + begin + AddToObjSectionWorkList(objsec); + if objsec.name='.fpc.n_links' then + objsec.Used:=false; + end; end; end; AddToObjSectionWorkList(entrysym.exesymbol.objsymbol.objsection); diff --git a/compiler/ogcoff.pas b/compiler/ogcoff.pas index 940913de6b..bc846762bd 100644 --- a/compiler/ogcoff.pas +++ b/compiler/ogcoff.pas @@ -1795,9 +1795,10 @@ const pemagic : array[0..3] of byte = ( if (Copy(secname,1,6)='.idata') or (Copy(secname,1,6)='.edata') or (Copy(secname,1,5)='.rsrc') or - (Copy(secname,1,6)='.pdata') then + (Copy(secname,1,6)='.pdata') or + (Copy(secname,1,4)='.fpc') then include(secoptions,oso_keep); - objsec:=TCoffObjSection(createsection(secname,secalign,secoptions)); + objsec:=TCoffObjSection(createsection(secname,secalign,secoptions,false)); FSecTbl^[i]:=objsec; if not win32 then objsec.mempos:=sechdr.rvaofs; diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index bdc7132017..f1df9d1d26 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -378,8 +378,8 @@ implementation {$ENDIF POWERPC} begin maybe_new_object_file(current_asmdata.asmlists[al_globals]); - { Insert Ident of the compiler in the main .data section } - current_asmdata.asmlists[al_globals].concat(Tai_section.create(sec_data,'',0)); + { Insert Ident of the compiler in the .fpc.version section } + current_asmdata.asmlists[al_globals].concat(Tai_section.create(sec_fpc,'version',0)); current_asmdata.asmlists[al_globals].concat(Tai_align.Create(const_align(32))); current_asmdata.asmlists[al_globals].concat(Tai_string.Create('FPC '+full_version_string+ ' ['+date_string+'] for '+target_cpu_string+' - '+target_info.shortname)); @@ -1451,7 +1451,7 @@ implementation if islibrary or (target_info.system in system_unit_program_exports) then exportlib.generatelib; - { Reference all DEBUGINFO sections from the main .text section } + { Reference all DEBUGINFO sections from the main .fpc section } if (cs_debuginfo in current_settings.moduleswitches) then debuginfo.referencesections(current_asmdata.asmlists[al_procedures]); diff --git a/compiler/systems/t_gba.pas b/compiler/systems/t_gba.pas index 274a0a1c0b..25ba234372 100644 --- a/compiler/systems/t_gba.pas +++ b/compiler/systems/t_gba.pas @@ -366,6 +366,7 @@ begin add('*(.data)'); add('*(.data.*)'); add('*(.gnu.linkonce.d*)'); + add('*(.fpc*)'); add('CONSTRUCTORS'); add('. = ALIGN(4);'); add('} >iwram = 0xff'); diff --git a/compiler/systems/t_go32v2.pas b/compiler/systems/t_go32v2.pas index cbd22a5e60..fab538c2b6 100644 --- a/compiler/systems/t_go32v2.pas +++ b/compiler/systems/t_go32v2.pas @@ -190,6 +190,7 @@ begin ScriptRes.Add(' *(.dtor)'); ScriptRes.Add(' djgpp_last_dtor = . ;'); ScriptRes.Add(' *(.data)'); + ScriptRes.Add(' *(.fpc*)'); ScriptRes.Add(' *(.gcc_exc)'); ScriptRes.Add(' ___EH_FRAME_BEGIN__ = . ;'); ScriptRes.Add(' *(.eh_fram)'); diff --git a/compiler/systems/t_linux.pas b/compiler/systems/t_linux.pas index 092bdbcd9b..a1040b145a 100644 --- a/compiler/systems/t_linux.pas +++ b/compiler/systems/t_linux.pas @@ -574,6 +574,7 @@ begin add(' .data :'); add(' {'); add(' *(.data .data.* .gnu.linkonce.d.*)'); + add(' KEEP (*(.fpc .fpc.version .fpc.links))'); add(' KEEP (*(.gnu.linkonce.d.*personality*))'); add(' }'); add(' _edata = .;'); diff --git a/compiler/systems/t_win.pas b/compiler/systems/t_win.pas index 8fcd723a04..2039720f8f 100644 --- a/compiler/systems/t_win.pas +++ b/compiler/systems/t_win.pas @@ -958,6 +958,7 @@ implementation Concat('EXESECTION .data'); Concat(' SYMBOL __data_start__'); Concat(' OBJSECTION .data*'); + Concat(' OBJSECTION .fpc*'); Concat(' SYMBOL edata'); Concat(' SYMBOL __data_end__'); Concat('ENDEXESECTION'); @@ -1158,7 +1159,7 @@ implementation Add(' .data BLOCK(__section_alignment__) :'); Add(' {'); Add(' __data_start__ = . ;'); - add(' *(.data .data.* .gnu.linkonce.d.*)'); + add(' *(.data .data.* .gnu.linkonce.d.* .fpc*)'); Add(' *(.data2)'); Add(' *(SORT(.data$*))'); Add(' __data_end__ = . ;'); diff --git a/utils/fpcres/elfres.pas b/utils/fpcres/elfres.pas index b96a5eebfc..47e3171dec 100644 --- a/utils/fpcres/elfres.pas +++ b/utils/fpcres/elfres.pas @@ -27,7 +27,7 @@ though. Format used for the various resource sections: - fpc.resptrs: This section is contained in resptrs.o and always linked to the executable by + .fpc.resptrs: This section is contained in resptrs.o and always linked to the executable by FPC. It containes an exported label fpcrespointers, which is used at runtime to find the resptrs section in memory. The resptrs contains pointers to all the sections and their sizes. These are updated in a post-precessing step by the @@ -38,15 +38,15 @@ Format used for the various resource sections: The second integer (32/64 Bit) value in this section contains the number of resources. After this follows a version-defined number of TFPCResourceSectionInfo entries. - fpc.ressym: Contains the resource names. This simply is a stream of zero-terminated strings. + .fpc.ressym: Contains the resource names. This simply is a stream of zero-terminated strings. Only textual names are supported, numeric IDs get autoconverted to #ID's. The reshash table has got a byte index into ressym to quickly get that data if needed - fpc.reshash: n TFPCResourceInfo records. (number of entries is defined in fpc.resptrs) - fpc.resdata: Contains the plain resource data stream. A byte index into the data stream + .fpc.reshash: n TFPCResourceInfo records. (number of entries is defined in fpc.resptrs) + .fpc.resdata: Contains the plain resource data stream. A byte index into the data stream is given for each resource entry in TResourceInfo - fpc.resspare: An empty section which is resized to make room if the size of any of the previous + .fpc.resspare: An empty section which is resized to make room if the size of any of the previous sections gets changed. NOT USED IN VERSION 1 (SIZE WILL BE 0) - fpc.resstr: This section is completely seperated from the rest and contains a block of + .fpc.resstr: This section is completely seperated from the rest and contains a block of resourcestrings in internal FPC format. resptr TFPCResourceSectionInfo list for FPC resources version 1: @@ -78,8 +78,8 @@ const fpcres2elf_version=1; // Do not change the following consts, they are dummy tables to generate an .o that makes ld happy const shstrtab = #0+'.symtab'+#0+'.strtab'+#0+'.shstrtab'+#0+'.text'+#0+'.data'+#0+ - '.bss'+#0+'fpc.ressym'+#0+'fpc.resstr'+#0+'fpc.reshash'+#0+ - 'fpc.resdata'+#0+'fpc.resspare'+#0+#0; + '.bss'+#0+'.fpc.ressym'+#0+'.fpc.resstr'+#0+'.fpc.reshash'+#0+ + '.fpc.resdata'+#0+'.fpc.resspare'+#0+#0; symtab = #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00+ #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$03#$00#$01#$00+ #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$03#$00#$02#$00+ @@ -545,7 +545,7 @@ begin SectionHeader.sh_entsize:=0; FSectionStream.Write(SectionHeader,sizeOf(SectionHeader)); - // fpc.ressym + // .fpc.ressym SectionHeader.sh_name:=$2C; SectionHeader.sh_type:=1; // PROGBITS SectionHeader.sh_flags:=2; // A @@ -558,8 +558,8 @@ begin SectionHeader.sh_entsize:=0; FSectionStream.Write(SectionHeader,sizeOf(SectionHeader)); - // fpc.resstr - SectionHeader.sh_name:=$37; + // .fpc.resstr + SectionHeader.sh_name:=$38; SectionHeader.sh_type:=1; // PROGBITS SectionHeader.sh_flags:=2; // A SectionHeader.sh_addr:=0; @@ -571,8 +571,8 @@ begin SectionHeader.sh_entsize:=0; FSectionStream.Write(SectionHeader,sizeOf(SectionHeader)); - // fpc.reshash - SectionHeader.sh_name:=$42; + // .fpc.reshash + SectionHeader.sh_name:=$44; SectionHeader.sh_type:=1; // PROGBITS SectionHeader.sh_flags:=2; // A SectionHeader.sh_addr:=0; @@ -584,8 +584,8 @@ begin SectionHeader.sh_entsize:=0; FSectionStream.Write(SectionHeader,sizeOf(SectionHeader)); - // fpc.resdata - SectionHeader.sh_name:=$4e; + // .fpc.resdata + SectionHeader.sh_name:=$51; SectionHeader.sh_type:=1; // PROGBITS SectionHeader.sh_flags:=2; // A SectionHeader.sh_addr:=0; @@ -597,9 +597,9 @@ begin SectionHeader.sh_entsize:=0; FSectionStream.Write(SectionHeader,sizeOf(SectionHeader)); - // fpc.resspare + // .fpc.resspare // Not used in V1 - SectionHeader.sh_name:=$5a; + SectionHeader.sh_name:=$5f; SectionHeader.sh_type:=8; // NOBITS SectionHeader.sh_flags:=2; // A SectionHeader.sh_addr:=0; diff --git a/utils/fpcres/elfresfix.pas b/utils/fpcres/elfresfix.pas index 4d82b3bca7..e7b2155893 100644 --- a/utils/fpcres/elfresfix.pas +++ b/utils/fpcres/elfresfix.pas @@ -16,7 +16,7 @@ { *********************************************************************** } { -This tool will update the fpc.resptrs section of an ELF executable to point +This tool will update the .fpc.resptrs section of an ELF executable to point to the various resource sections in the file. This is done so that the FPC RTL at runtime is able to get pointers to these sections. @@ -206,12 +206,12 @@ begin SectionName:=copy(strtab,SectionHeaders[i].sh_name+1,32); SectionName:=copy(SectionName,1,pos(#0,SectionName)-1); DoVerbose(SProcessingSection+SectionName); - sn:=Copy(SectionName,1,4); + sn:=Copy(SectionName,1,5); // FPC section ? - if (sn='fpc.') then + if (sn='.fpc.') then begin sn:=SectionName; - Delete(SN,1,4); + Delete(SN,1,5); if SN='resptrs' then begin ResPtrsSection:=i;