On Jun 23, 2014, at 8:32 PM, Alex <[email protected]> wrote:
> Dear sirs,
> I have one question about using UDK2014 develop efi ap,who can help me
> explain this ?
> I apply a global array size is 64k(like UINT8 ABC[64*1024];), then build the
> Souece Code, and the generate efi file size will more than 64k. Also, if the
> array size is 8M, the generate efi file size will more than 8M.
> but if I use AllocateZeroPool apply an memory pool(64K size), and I free
> this pool after use, the generated efi file
> size will be smaller, 20k for example.
> I think the global variable array will be allocate when efi ap running,
The global variable is not allocated in C, it is part of the BSS in the DATA
section of the PE/COFF image. The BSS is set to zero when the PE/COFF image is
loaded into memory.
> and have no relationship with the generated efi ap file.
> Who can help me explain this ?
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] ;
If you are seeing BSS end up in the PE/COFF image what compiler are you using?
How is the PE/COFF image being created?
Thanks,
Andrew Fish
PS This is the code that zeros the BSS when the PE/COFF image gets loaded.
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
//
// If raw size is less then virtual size, zero fill the remaining
//
if (Size < Section->Misc.VirtualSize) {
ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);
}
> Thank you very much!
> ------------------------------------------------------------------------------
> 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
------------------------------------------------------------------------------
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