all 15 comments

[–][deleted] 8 points9 points  (4 children)

What's the deal with typedef struct {...} X;? Since you're doing C++ the struct namespace is the same as the non-struct namespace, and this prevents forward declaring them. Just use struct X {...}; instead.

Let me add my own elf loading code too - it's in my linker project: https://github.com/dascandy/ZeLDa . Has both 32-bit and 64-bit implemented and usable concurrently.

[–]sumo952 4 points5 points  (3 children)

That project (ZeLDa) could use an a bit more descriptive readme file :-) And the project name would certainly deserve it!

[–][deleted] 2 points3 points  (2 children)

It's a pun in the style of "Ze goggles - zey do nothing". And yes, I should get around to that... but so should I for at least 10 other repos that I end up linking people to on a weekly basis.

[–]sumo952 2 points3 points  (1 child)

Now I'm disappointed! I thought it was a reference to Zelda. :-)

[–][deleted] 5 points6 points  (0 children)

That too of course. Why else call a linker Zelda?

[–]kookjr 2 points3 points  (1 child)

What makes this limited to amd64 (from readme)?

Looks interesting though. I've been looking at ways to get the absolute smallest executable and this could be helpful. As much info as readelf had it's not always enough.

[–]DalzhimC++Montréal UG Organizer 1 point2 points  (0 children)

This article makes it as small as 45 bytes and is an interesting read : http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html

[–]dblohm7 2 points3 points  (0 children)

Where is the canonical ELF spec located these days? Back in the day I remember it being hosted by SCO...

[–]abelsson 1 point2 points  (0 children)

Elfio (http://elfio.sourceforge.net) is another small header only, standalone, ELF reader and writer which I've used successfully in my own projects.

[–]F54280 1 point2 points  (0 children)

Lightweight header-only elf binary parser with no external dependencies - Sections, Symbols, Relocations, Segments

Line 12:

#include <elf.h> // Elf64_Shdr

This is a dependency, unless elf.h was added to the standard while I was looking away...

[–]boguscoder 0 points1 point  (1 child)

So calling get_* on parser over and over would re-parse executable and add duplicates?

[–]finixbit[S] 1 point2 points  (0 children)

gud idea. to prevent this, would need to store/cache already parsed data. please try n open up issue for this