LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   disassembling and reading C code from executable (https://www.linuxquestions.org/questions/programming-9/disassembling-and-reading-c-code-from-executable-753248/)

Tordne 09-07-2009 03:50 AM

disassembling and reading C code from executable
 
I'm quite new in programming, wrote a few programs.... But i want to get some ideas of the experts....

So I thought that linux was free and that we were able to read all the source codes.
But all the executables are binary files.
I tried lxr (that doesn't seem to work)
I tried ht that is unreadable for me...
I tried dissy just the same unreadble stuff....
I tried a program disassembler (where I first had to include a few headers in some files.... and still the output stays unreadable)

Please take me out of my misery and can someone tell me how I can open a binary executable (modified or not!) in emacs....

Thanks

graemef 09-07-2009 04:08 AM

You just need to download the source files.

johnsfine 09-07-2009 06:46 AM

Quote:

Originally Posted by graemef (Post 3672779)
You just need to download the source files.

Looking at the first post, one would guess Tordne won't know how to do that.

1) You need to know the package name for the program whose sources you want to see.

2) You need to have the right deb-src repository in sources.list

3) Use the command
apt-get source package


I expect most Ubuntu users do package management in Synaptic, so doing things directly with apt may be new.

For item (1) you often can get that info by doing a search in Synaptic. If that doesn't tell you the package you want, there is an apt-file search command you could install and learn to use, but it is easier to use the online search at:
http://packages.ubuntu.com/
Scroll down to where it says Search the contents of packages

For item (2), you could use the settings/Repositories menu choice in Synaptic or you could more easily directly edit /etc/apt/sources.list (as root). You will see lines that begin with deb and for each of those you will want another line that is identical except that it begins with deb-src

Tordne 09-07-2009 07:44 AM

Quote:

Originally Posted by johnsfine (Post 3672909)
Looking at the first post, one would guess Tordne won't know how to do that.

thanks, and you're right. I didn't know...
I never needed them untill now...
But now I know...

Thanks...

PS: Now I can start writing some code in a certain standard.
My last program was quite messy after 1400 lines...

graemef 09-07-2009 08:33 AM

Quote:

Originally Posted by johnsfine (Post 3672909)
Looking at the first post, one would guess Tordne won't know how to do that.

...nor did I in Ubuntu ;)


All times are GMT -5. The time now is 07:54 PM.