PE vs ELF

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.

PE or ELF? Which is the best?

PE is faster
23
26%
ELF is faster
26
29%
With PE you save more memory
12
13%
With ELF you save more memory
29
32%
 
Total votes: 90

User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

PE vs ELF

Post by Jeko »

Which are pros and cons of PE and ELF file formats when they are used for executables, shared libraries and device drivers?

Vote and give your opinion!
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: PE vs ELF

Post by JamesM »

The differences between them are far too intricate to be shown in such a large-grained vote. I'm at work at the moment, but may post more about it later.
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Re: PE vs ELF

Post by Laksen »

Can't speak for PE, but so far ELF has been a pain in the @$$. I got it working but it wasn't pleasant at all
http://j-software.dk | JPasKernel - My Object Pascal kernel
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Re: PE vs ELF

Post by inflater »

What's faster? Binary! 8)
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: PE vs ELF

Post by Combuster »

Time to beat Brynet-Inc to the point :D
Neither is faster. Or ELF is faster because PE is for windows and windows is slow.
Neither is smaller, or ELF is smaller because everything written for windows is bloatware.
Therefore, I want to cast magic missile at this poll. :twisted:

I prefer ELF, because its better documented, better supported, and free from several "features" that are only relevant to windows environments. That said, I have written code to deal with executables for both formats, and the ELF format is IMO much easier to deal with. However, I can't vote that.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

Re: PE vs ELF

Post by zhak »

a new executable file format may be implemented for new OS. for example the one that takes all good (or necessary) from both pe and elf with all the unnecessary stuff wiped out. But to choose between pe and elf... I prefer elf. but all my executables are still plain binary :)
blackcatcoder
Member
Member
Posts: 132
Joined: Wed Nov 03, 2004 12:00 am
Location: Austria
Contact:

Re: PE vs ELF

Post by blackcatcoder »

I must admit Combuster, I also got ELF32 and ELF64 working, it's documented very good, and it has a clear structure.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: PE vs ELF

Post by Solar »

zhak wrote:a new executable file format may be implemented for new OS.
...requiring work on all parts of the toolchain involved to support the new format.

I'd vote "ELF is faster" because it will allow you to solve the format issues fastest (due to available documentation and tools), but I doubt that's what the OP had in mind. ;)
Every good solution is obvious once you've found it.
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Re: PE vs ELF

Post by leledumbo »

If only ELF has an extension ... (so I don't have to parse each file just to know what it contains. Read: UNIX stupify)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: PE vs ELF

Post by Solar »

Well, extension or not is entirely up to you, isn't it? I think extension-less-ness is quite neat. Who cares if it's a ELF exe, a Perl script or a Java application, as long as it starts correctly? (And the loader has to load 'em anyway, so whether it has to look into the filename or the first couple of bytes of the file itself doesn't matter.) A filename extension is redundant information, and we know what that implies...
Every good solution is obvious once you've found it.
User avatar
elderK
Member
Member
Posts: 190
Joined: Mon Dec 11, 2006 10:54 am
Location: Dunedin, New Zealand
Contact:

Re: PE vs ELF

Post by elderK »

While my perspective may be somewhat biased or even incorrect, I'm pitching in my 2c ...

1) PE Speed vs. ELF Speed
It highly depends on situation and, context. A PE loaded precisely where it was meant to be loaded (ie: .dll, somewhere in memory, where it wanted to be originally) will execute faster than an ELF loaded to the same place. HOWEVER, Rebasing a PE is horribly slow (ie: putting .dll somewhere else, where it wasnt intended).

edit: decent explanation :: http://en.wikipedia.org/wiki/Portable_Executable

Also, from what I can discern, .dlls arent quite as sharable as ELF Shared Objects. An ELF Shared Object can be in many address spaces, simultaneously, mapped
at completely different regions in each address space (thanks to the .got.plt, .got). Not to mention relocating an ELF is faster.

2) PE Memory vs. ELF Memory
Lately I've been doing a lot of work, investigating both formats for my crazy project (yes, I'm elderK). Anywho, sure, ELF has a lot of stuff crammed into it. 80% of that stuff you can strip. The remaining 20% can be reclaimed after loading the binary, in some way, without compromising sharability.

I'm not sure if that can be said for PE but then again, I havent researched PE as heavily as I have ELF.

3) Laksen "Can't speak for PE, but so far ELF has been a pain in the @$$. I got it working but it wasn't pleasant at all".
I remember talking to you #osdev on Freenode. If I remember correctly, your method of loading ELFs was simply loading the Relocatable files (.o).
Of course that will be a pain in the @$$ - very little of it is in the state in which it would normally be! All of the symbols are NOT linked to addresses.
Just a whole bunch of fixups to be performed. AFAIK, For Relocatable Objects (.o), The tracking required exceeds that for Executable / Shared Objects.

4) Finally, to end my "ELF is cool!" spiel, You can create Position-Independent-Executables, too. So you can relocate anything you like!

Oh, and for those who want to see how difficult ELF really is, complete with Dynamic Linking, keep your eyes peeled. I'll release a small program sometime
soon. Basically, my collection of prototype loaders/linkers (created whilst investigating ELF, to gain familiarity). Public domain, of course. If it helps anyone at all, that'd be awesome.

~zeii / elderK
User avatar
cr2
Member
Member
Posts: 162
Joined: Fri Jun 27, 2008 8:05 pm
Location: ND, USA

Re: PE vs ELF

Post by cr2 »

One error in your polling:

You can vote both "PE is faster" and "ELF is faster"; and it will still work.

Potential Solution:
Change your polling information so that you may only choose 1 option, and change the potential answers accordingly:
  • PE is both faster and it saves more memory
  • PE is faster and ELF saves more memory
  • ELF is both faster and it saves more memory
  • ELF is faster and PE saves more memory
OS-LUX V0.0
Working on...
Memory management: the Pool
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: PE vs ELF

Post by Brendan »

Hi,
Jeko wrote:Which are pros and cons of PE and ELF file formats when they are used for executables, shared libraries and device drivers?
PE: Designed by Microsoft for Windows. Really useful for executable files on Windows clones.

ELF: Designed by SCO for Unix System V. Really useful for executable files on Unix clones.

BCOS_NFF: Being designed by me for my OS. Really useful for all native (for my OS) file types including (but not limited to) executable files for my OS. Consists of a generic header (file size, magic number, checksum/CRC, file type ID) that is identical for all native file types, optionally followed by an extended header that depends on the file type ID in the generic header. :D


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: PE vs ELF

Post by thepowersgang »

I was designing a format based on the HTMA (Html Application) idea in Windows XP and Vista.
Would composing an app in XML be an idea?
XML header only maybe?
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: PE vs ELF

Post by ru2aqare »

Jeko wrote:Which are pros and cons of PE and ELF file formats when they are used for executables, shared libraries and device drivers?

Vote and give your opinion!
For me, the PE format looks much more simple. It is true that relocating an image (shared library) is required when the image cannot shared between two processes, but I don't think it is *that* slow (AMD64 has even RIP-relative addressing, which makes some of the relocations go away). Of course you have to watch out for some differing fields between PE and PE+ when targeting the x64 platform. And it has some Windows-specific stuff, all of which can safely be ignored.

On the other hand, I still want to develop an ELF loader for my OS (why not?), but it has some concepts unfamiliar to the average Windows developer. Windows does not have a GOT or a PLT, neither all those tricky relocation calculations associated with it... It is true that documentation exists for the format, but it does not explain what is a GOT or a PLT (at least I could not find an explanation).

Bottom line: if you want something simple and fast, develop a custom image format for your OS.
Post Reply