From 7f8800eeb15ef2db9dbe43b91db194b0e0d0e53f Mon Sep 17 00:00:00 2001 From: svenbarth Date: Sat, 19 Oct 2019 15:41:37 +0000 Subject: [PATCH] + add a method to TObjData to retrieve the TSectionProcBits and TSectionFlags values for a given section type git-svn-id: trunk@43266 - --- compiler/ogbase.pas | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index 964754af5e..45aabd8ad0 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -397,6 +397,7 @@ interface function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;virtual;abstract; class function sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;virtual; function sectiontype2align(atype:TAsmSectiontype):longint;virtual; + class procedure sectiontype2progbitsandflags(atype:TAsmSectiontype;out progbits:TSectionProgbits;out flags:TSectionFlags);virtual; function createsection(atype:TAsmSectionType;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection;virtual; function createsection(atype:TAsmSectionType;secflags:TSectionFlags;aprogbits:TSectionProgbits;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection;virtual; function createsection(const aname:string;aalign:longint;aoptions:TObjSectionOptions;DiscardDuplicate:boolean=true):TObjSection;virtual; @@ -1308,6 +1309,29 @@ implementation end; + class procedure TObjData.sectiontype2progbitsandflags(atype:TAsmSectiontype;out progbits:TSectionProgbits;out flags:TSectionFlags); + var + options : TObjSectionOptions; + begin + { this is essentially the inverse of the createsection overload that takes + both progbits and flags as parameters } + options:=sectiontype2options(atype); + flags:=[]; + if oso_load in options then + include(flags,SF_A); + if oso_write in options then + include(flags,SF_W); + if oso_executable in options then + include(flags,SF_X); + if not (oso_data in options) then + progbits:=SPB_NOBITS + else if oso_note in options then + progbits:=SPB_NOTE + else if oso_arm_attributes in options then + progbits:=SPB_ARM_ATTRIBUTES; + end; + + function TObjData.createsection(atype:TAsmSectionType;const aname:string;aorder:TAsmSectionOrder):TObjSection; begin result:=createsection(sectionname(atype,aname,aorder),sectiontype2align(atype),sectiontype2options(atype));