[llvm-dev] Support/COFF.h NumberOfSections size-mismatch inside "header"-struct

Rohleder, Roman (Contractor) via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 19 08:11:57 PDT 2015


Hello everyone,

while working on a simple PE-Parser, using the llvm/Support/COFF.h Header, to validate if a given File is a PE-File and to read the Machine Field I was experiencing some troubles.

It seemed the Fields were somehow misaligned and I could pinpoint the source of the misalignment to be the "NumberOfSections" field inside the "header"-struct (a.k.a. IMAGE_FILE_HEADER in winnt.h).

It is defined as "int32_t" in COFF.h, while in winnt.h it is defined as "WORD" and in the "Microsoft Portable Executable and Common Object File Format Specification", which is also cited on top of the COFF.h, also defines the Field to be 2 Bytes in Size.

A simple change to "uint16_t" did the trick.

Correct me if I am wrong, or if I was using it wrongly somehow.

Kind Regards
Roman

-- 
______________________________________________________________

The information contained in this electronic mail transmission 
may be privileged and confidential, and therefore, protected 
from disclosure. If you have received this communication in 
error, please notify us immediately by replying to this 
message and deleting it from your computer without copying 
or disclosing it.
______________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151019/241201af/attachment.html>


More information about the llvm-dev mailing list