flat assembler
Message board for the users of flat assembler.

Index > Windows > coff help

Author
Thread Post new topic Reply to topic
b1528932



Joined: 21 May 2010
Posts: 287
b1528932 19 Oct 2010, 16:54
i am writing now my own compiler, and i have more than few questions about file ehaders.

- I want it to work on windows and unix. I have coff pdf in front of my eyes and i semi understand it, however i cant find anything regarding elf format.
Where will i find it?


- What is coff object file?
i understand that header look likt: MZ/COFF/PE/DD/SS/rest
MZ - dos header
COFF - coff header staritng with PE
PE - optional header
DD - part of optional header, but even more optional
ss - section headers

why PE is optional?


- there is ambiguity in size of optional header.
SizeOfOptionalHeader, and NumberOfRvaAndSizes.
Whats the diffrence?
All that can change (excluding pe+, wich has diffrent header) are ammount of data directories. Why 2 fields describe 1 thing?
Post 19 Oct 2010, 16:54
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 19 Oct 2010, 18:08
b1528932,

Optional header can be present in COFF (MS PE/COFF spec contradicts itself on that matter: description for SizeOfOptionalHeader insists on value 0 for COFF, yet in the next subchapter it says "An object file can have an optional header, but generally this header has no function in an object file except to increase its size.")

While it seems superfluous to have both SizeOfOptionalHeader and NumberOfRvaAndSizes, it allows COFF parser to successfully skip optional header without parsing it (PE32/PE32+/PE32++/etc.)
Post 19 Oct 2010, 18:08
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 22 Oct 2010, 17:39
For information on ELF format, the wikipedia article is a starting point, with overview and links to multiple resources. If you're implementing ELF support, you might want to dive into GNU Binutils sources, and you'll likely want to use binutils to verify/examine your generated object files as you go.

Might also want to check out the BSD LibElf - I haven't had a look at it myself, but in general I find BSD code to be better written than a lot of GNU stuff. I messed around a bit with GNU binutils several years ago, and it wasn't exactly super pretty Smile

The Portable Executable format is a bit of a mess - not so much from it's specification, but more in that different versions of Windows have slightly different requirements for what it considers to be a well-formed executable - and then there's the issue of anti-malware software going apeshit heuristic crazy on "non-standard" files.
Post 22 Oct 2010, 17:39
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.