konrad-kruczynski / elfsharp

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

Reading Mach-O binary #76

Closed eddynaka closed 3 years ago

eddynaka commented 3 years ago

Hi,

I have been trying to read a mach-o binary.

Looking at the tests, I got the segments, for example, and I understood how to fetch the data inside it. But there are things that I couldn't locate:

Just to let you know, I generated a sample using the following command in a Mac:

gcc -Wall -O2 hello.c -g -o hello
gcc -Wall -O2 hello.c -g -dwarf-5 -o hello5

thank you!

konrad-kruczynski commented 3 years ago

Hi Eddy, What do you mean by retrieving a command line? The arguments? Those are generally tied to a given execution, not to the binary per se.

As for the second question: nope, this is not safe in general. Segment can contain a lot different data, strings can only be part of it. To extract strings from a binary file, you can use strings program.

eddynaka commented 3 years ago

HI @konrad-kruczynski , for an ELF binary, if we load it correctly, we can see the command line that generated the binary. My question is: is it possible to do the same in the mach-o?

konrad-kruczynski commented 3 years ago

Ok, that command line. I don't have any knowledge about that though.

konrad-kruczynski commented 3 years ago

I'm closing the issue now, please reopen if necessary.