konrad-kruczynski / elfsharp

Pure managed C# library for reading ELF, UImage, Mach-O binaries.
https://elfsharp.it
Other
159 stars 57 forks source link

ELF file is unknown version #1

Closed akerd closed 13 years ago

akerd commented 13 years ago

Hi konrad, I just tried to download and use the current version of your ElfShap library, but when I try to open a valid ELF I get the error "Given ELF file is of unknown version 16777216."

I know that there are different version of ELF / DWARF so maybe this is an issue. Unfortunately I cannot provide you the ELF file, but if you give me some indications I would be happy to help.

konrad-kruczynski commented 13 years ago

Because of the number, you provided in the exception, this looks like endianess or (rather) 64-bit elf issue (aligment). Currently only 32-bit, native endian ELFs can be read. I have introduced check for that to repository and also new binary version on webpage. Could you test it and tell me what exception you get?

akerd commented 13 years ago

I tested the new version and now it returns me the exception "Given ELF is of different endianess than your machine."

The ELF I was parsing in this case was created by an 8-bit micro-controller compiler that uses bigEndian architecture, so it seems now that the message is congruent.

It would be really nice supporting also this memory organization so, instead of throwing the exception, can you manage both types? I see that you use framework BitConverter, but if you need, I could provide you a similar function that has endianess as additional parameters and supports both formats.

konrad-kruczynski commented 13 years ago

I was planning to use Jon Skeet's EndianBinaryReader from MiscUtil which supports big and little endian. This is not much work and something should be released this or tomorrow evening. I also plan to support some more exotic endianess like the middle endian (I think old ABI ARM used it somewhere).

akerd commented 13 years ago

Great, I know Jon Skeet and his high reputation but I didn't know the MiscUtil; I will take a look to it, it seems really interesting. Take your time, in the meanwhile I will test some 32-bit little endianess ELF files.

konrad-kruczynski commented 13 years ago

I have just pushed new version to repository and also new binary to webpage. Please test it and tell me whether it worked properly. I've tested it on the OpenRisc Linux kernel (which is big endian), but one never knows ;)

akerd commented 13 years ago

Hi konrad, sorry for the delay. I have just been able to test your new version, and it seems that is working well. Or at least it parses the different section headers. I think we can close here the issue and in case I will open another one if I find different problems.

Thank you for the fast and great support.

konrad-kruczynski commented 13 years ago

You're welcome.