diff --git a/compiler/ogomf.pas b/compiler/ogomf.pas index 535a253212..85948913ae 100644 --- a/compiler/ogomf.pas +++ b/compiler/ogomf.pas @@ -643,7 +643,7 @@ implementation TOmfObjSection(Result).FUse:=suUse32; TOmfObjSection(Result).SizeLimit:=high(longword); end; - primary_group:=omf_section_primary_group(atype); + primary_group:=omf_section_primary_group(atype,aname); if primary_group<>'' then begin { find the primary group, if it already exists, else create it } diff --git a/compiler/omfbase.pas b/compiler/omfbase.pas index 169ce0b948..87ad0de42a 100644 --- a/compiler/omfbase.pas +++ b/compiler/omfbase.pas @@ -1263,14 +1263,15 @@ interface { returns whether the specified section type belongs to the group DGROUP in the current memory model. DGROUP is the segment group pointed by DS } function section_belongs_to_dgroup(atype:TAsmSectiontype): Boolean; - function omf_section_primary_group(atype:TAsmSectiontype):string; + function omf_section_primary_group(atype:TAsmSectiontype;const aname:string):string; implementation uses cutils,globtype,globals, cpuinfo, - verbose; + verbose, + fmodule; { TOmfOrderedNameCollection } @@ -2873,11 +2874,28 @@ implementation {$endif i8086} end; - function omf_section_primary_group(atype: TAsmSectiontype): string; + function omf_section_primary_group(atype: TAsmSectiontype;const aname:string): string; begin {$ifdef i8086} if section_belongs_to_dgroup(atype) then result:='DGROUP' + else if create_smartlink_sections and (aname<>'') then + begin + case omf_segclass(atype) of + 'CODE': + if current_settings.x86memorymodel in x86_far_code_models then + begin + if cs_huge_code in current_settings.moduleswitches then + result:='' + else + result:='CGROUP_'+current_module.modulename^; + end + else + result:='CGROUP'; + else + result:=''; + end; + end else result:=''; {$else i8086} diff --git a/compiler/x86/agx86nsm.pas b/compiler/x86/agx86nsm.pas index 451fbea1be..e2377286f4 100644 --- a/compiler/x86/agx86nsm.pas +++ b/compiler/x86/agx86nsm.pas @@ -596,7 +596,7 @@ interface writer.AsmWrite(' class='+omf_segclass(atype)+ ' align='+tostr(omf_sectiontype2align(atype))); TX86NasmSection.Create(FSections,secname); - secgroup:=omf_section_primary_group(atype); + secgroup:=omf_section_primary_group(atype,aname); if secgroup<>'' then AddSegmentToGroup(secgroup,secname); end;