bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/25029] Invalid PE file caused by discarded .rdata section


From: address@hidden
Subject: [Bug ld/25029] Invalid PE file caused by discarded .rdata section
Date: Fri, 11 Oct 2019 08:11:44 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=25029

--- Comment #3 from Florin Saftoiu <address@hidden> ---
Hi Nick,

Thanks for your reply.

You're right about the entry point, it is correct. But Windows still wouldn't
run my program so I took another look at the file.

The problem is in fact with the SizeOfImage and SizeOfHeaders fields.
If I call the data section .rdata, then I get a SizeOfImage of 0x4000 and a
SizeOfHeaders of 0x200 which is correct.
But if I call the data section .data, then I get a SizeOfImage of 0x3000 and a
SizeOfHeaders of 0x400.

Microsoft says
(https://docs.microsoft.com/en-us/windows/win32/debug/pe-format?redirectedfrom=MSDN#optional-header-image-only)
that SizeOfImage should be "The size (in bytes) of the image, including all
headers, as the image is loaded in memory. It must be a multiple of
SectionAlignment." and SizeOfHeaders should be "The combined size of an MS-DOS
stub, PE header, and section headers rounded up to a multiple of
FileAlignment."

It seems that ld considers the empty 512 bytes, from the discarded .rdata
section, as part of the header. I've no hypothesis about why the SizeOfImage is
messed up.

Hope this helps.

Best regards,
Florin

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]