From 4a855b140a025dfd23b022c42e413d4ef10ad953 Mon Sep 17 00:00:00 2001 From: nickysn Date: Fri, 4 Sep 2015 13:16:45 +0000 Subject: [PATCH] + support mixing initialized and bss data in the same object section (only in case the section options contain the new option 'oso_sparse_data') in the internal object writer (needed for the huge memory model) git-svn-id: trunk@31503 - --- compiler/assemble.pas | 3 ++- compiler/ogbase.pas | 11 +++++++++-- compiler/ogomf.pas | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/compiler/assemble.pas b/compiler/assemble.pas index 55efbaec5a..7bbb3a2fe9 100644 --- a/compiler/assemble.pas +++ b/compiler/assemble.pas @@ -1413,7 +1413,8 @@ Implementation end; ait_datablock : begin - if (oso_data in ObjData.CurrObjSec.secoptions) then + if (oso_data in ObjData.CurrObjSec.secoptions) and + not (oso_sparse_data in ObjData.CurrObjSec.secoptions) then Message(asmw_e_alloc_data_only_in_bss); {$ifdef USE_COMM_IN_BSS} if writingpackages and diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index 4b826365da..133932f066 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -157,7 +157,9 @@ interface { Must be cloned when writing separate debug file } oso_debug_copy, { Has relocations with explicit addends (ELF-specific) } - oso_rela_relocs + oso_rela_relocs, + { Supports bss-like allocation of data, even though it is written in file (i.e. also has oso_Data) } + oso_sparse_data ); TObjSectionOptions = set of TObjSectionOption; @@ -968,7 +970,10 @@ implementation if (qword(size)+l)>high(size) then SectionTooLargeError; {$endif} - inc(size,l); + if oso_sparse_data in SecOptions then + WriteZeros(l) + else + inc(size,l); end; @@ -1366,6 +1371,8 @@ implementation Size:=0; Datapos:=0; mempos:=0; + if assigned(Data) then + Data.reset; end; end; diff --git a/compiler/ogomf.pas b/compiler/ogomf.pas index 699cc77350..be59a7e6a4 100644 --- a/compiler/ogomf.pas +++ b/compiler/ogomf.pas @@ -100,6 +100,7 @@ interface class function CodeSectionName(const aname:string): string; public constructor create(const n:string);override; + function sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;override; function sectiontype2align(atype:TAsmSectiontype):shortint;override; function sectiontype2class(atype:TAsmSectiontype):string; function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override; @@ -507,6 +508,15 @@ implementation CObjSection:=TOmfObjSection; end; + function TOmfObjData.sectiontype2options(atype: TAsmSectiontype): TObjSectionOptions; + begin + Result:=inherited sectiontype2options(atype); + { in the huge memory model, BSS data is actually written in the regular + FAR_DATA segment of the module } + if sectiontype2class(atype)='FAR_DATA' then + Result:=Result+[oso_data,oso_sparse_data]; + end; + function TOmfObjData.sectiontype2align(atype: TAsmSectiontype): shortint; begin Result:=omf_sectiontype2align(atype);