On Jun 24, 2014, at 7:23 AM, Andrew Fish <[email protected]> wrote:

> The PE/COFF executable will have a TEXT section for code, and a DATA section 
> for things like globals. PE/COFF has the concept of file size and the virtual 
> size of the image. If virtual size of the section is larger than the file 
> size of the section the data is copied from the file to memory, and the rest 
> of the section is filled with zeros. So in C you have Data and the end of the 
> DATA is the BSS. The BSS is all zeros so it does not have to be part of the 
> image. Uninitialized globals and static locals should be placed in the BSS, 
> as well anything manually set to zero.
> 
> So I would expect this to be in the PE/COFF image:
> UINT8 Abc[1024*1024*8] = { 1 };
> 
> I would expect these to be in the BSS, and not in the PE/COFF file:
> UINT8 Abc[1024*1024*8] = { 0 };
> UINT8 Abc[1024*1024*8] ;
> 

Forgot to mention if you are writing a PEIM, or any code that executes in place 
(XIP code runs from ROM) you need to pay attention to what could happen with 
the C BSS. In general to execute from a PE/COFF image you want the virtual and 
file addresses (and sizes) to line up. If they don’t line up your global is not 
where you think it is. 

Thanks,

Andrew Fish
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to