Hello everyone,
I'm new here, and if I did/said something wrong, please point out instead of throwing stones at me :-)
I'm currently developing stuffs with winelibs, and when building a shared lib with winegcc, I find the generated file is weirdly large. The example below illustrates my problem.
// this is a.c __attribute__((cdecl)) void *test() { return 0; }
// and this is a.spec @ cdecl test()
Then I compiled them using 'winegcc a.c a.spec -shared -fPIC -m32', and then found the resulting file a.out.so is about 70KB in size: [pengyu@pengyu-Studio-1747 tmp]$ls a.out.so -l -rwxr-xr-x 1 pengyu users 75893 Feb 17 19:16 a.out.so
By analyzing the file I found in a.out.so there is an extremely large section .init with size of nearly 70KB. That's weird since a normal .init section is quite small. Though I know wine would do its initialization here, but 70KB is still too large I think. And after disassembling and also viewing the file with hexadecimal viewer, I found nearly all contents of .init section of a.out.so is filled with zero bits. Is this a bug or feature? Since .init section is read/execute only, I didn't see any benefit from these filling zeros. Can anybody make some explanations please? And, is there any methods to remove these zeros in the generated shared object and get a smaller file?
Regards, Pengyu
Pengyu CHEN cpy.prefers.you@gmail.com wrote:
Then I compiled them using 'winegcc a.c a.spec -shared -fPIC -m32', and then found the resulting file a.out.so is about 70KB in size: [pengyu@pengyu-Studio-1747 tmp]$ls a.out.so -l -rwxr-xr-x 1 pengyu users 75893 Feb 17 19:16 a.out.so
PE header needs to be aligned in a 64k boundary, and compiler fills remaining space with zeros.
On Fri, Feb 17, 2012 at 9:48 PM, Dmitry Timoshkov dmitry@baikal.ru wrote:
PE header needs to be aligned in a 64k boundary, and compiler fills remaining space with zeros.
Thank you Dmitry, and now I'm clear with that. Yet another question here. I've just check the msdn page and found 64K is actually the maximum possible value of SectionAlignment and FileAlignment, then why must we choose the maximum one or it is just like this?
Pengyu CHEN cpy.prefers.you@gmail.com wrote:
PE header needs to be aligned in a 64k boundary, and compiler fills remaining space with zeros.
Thank you Dmitry, and now I'm clear with that. Yet another question here. I've just check the msdn page and found 64K is actually the maximum possible value of SectionAlignment and FileAlignment, then why must we choose the maximum one or it is just like this?
PE header marks the beginning of a PE module in memory, and it needs to be aligned on allocation granularity.
On Fri, Feb 17, 2012 at 10:28 PM, Dmitry Timoshkov dmitry@baikal.ru wrote:
PE header marks the beginning of a PE module in memory, and it needs to be aligned on allocation granularity.
So it is.. Then thank you again Dmitry. :-)