From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: [edk2-devel] static data in dxe_runtime modules To: Roman Kagan ,devel@edk2.groups.io From: "Andrew Fish" X-Originating-Location: US (17.44.23.92) X-Originating-Platform: Mac Safari 12.1 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Fri, 02 Aug 2019 16:54:35 -0700 References: <20190801191621.GB14235@rkaganb.sw.ru> In-Reply-To: <20190801191621.GB14235@rkaganb.sw.ru> Message-ID: <26878.1564790075636681597@groups.io> Content-Type: multipart/alternative; boundary="W2nKT81WAM2vS7aDd8jV" --W2nKT81WAM2vS7aDd8jV Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Roman, Sorry for the top post, as my email client seems to have eating your email= . 1) In C static scopes the visibility of the symbol from a compiler linker = point of view, but the static and non-static globals are going to be stored= in the same section of the image. On macOS clang the only difference is th= e static global does not also have a .globl assembly directive to make the = label visible outside the scope of the module. In general Runtime Drivers will gather data that is only available at boot= time and store this data in globals, so you can't clear out part of the im= age on fix-up as that would break a lot of other stuff. 2) The corrrect answer would be to fixup any pointers needed at runtime vi= a RuntimeCryptLibAddressChangeEvent(). On option would be to have an array = of the addresses of the static variables and have RuntimeCryptLibAddressCha= ngeEvent() walk that and fixup the Physical addresses to virtual addresses = by calling EfiConvertPointer(). Thanks, Andrew Fish --W2nKT81WAM2vS7aDd8jV Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Roman,

Sorry for the top post, as my email client seems to have = eating your email.

1) In C static scopes the visibility of the s= ymbol from a compiler linker point of view, but the static and non-static g= lobals are going to be stored in the same section of the image. On macOS cl= ang the only difference is the static global does not also have a .globl as= sembly directive to make the label visible outside the scope of the module.=  

In general Runtime Drivers will gather data that is only = available at boot time and store this data in globals, so you can't clear o= ut part of the image on fix-up as that would break a lot of other stuff.&nb= sp;

2) The corrrect answer would be to fixup any pointers needed= at runtime via RuntimeCryptLib= AddressChangeEvent(). On option would be to have an array of the addresses = of the static variables and have RuntimeCryptLibAddressChangeEvent() walk that and fixup the Physical ad= dresses to virtual addresses by calling EfiConvertPointer().
Thanks,

Andrew Fish --W2nKT81WAM2vS7aDd8jV--