0

I have a question about executables and C.

If you had to know the content (the version of each .c file written in a commentary) of an executable BUT you just have the executable, you don't have the sources. How do you proceed ?

I've seen the "nm" command, cuting what I want with "cut" I can have in output the .c files but I can't read the versions inside because I don't have the source files. I've also seen the "objdump" command but I can't try it under AIX (of course ...) is there an equivalent? Is this possible with objdump to know what I want to?

Thx for your help and attention :)

Ežekiel
  • 15
  • 6
  • What do you mean by 'version of a .c' file? – Zsigmond Lőrinczy Sep 16 '15 at 19:01
  • With SVN when I have compiled my version of the executable, I want to recover the versions of .c files linked in the executable. – Ežekiel Sep 17 '15 at 07:29
  • Neither the compiler nor the linker knows or cares about SVN versions (the same goes for RCS/CVS) – Zsigmond Lőrinczy Sep 17 '15 at 16:29
  • I know, but I wanted to say that the number of the file's version (it's linked to SVN then) will be written inside of the .c file. You may be see what I mean now ^^ – Ežekiel Sep 18 '15 at 09:10
  • define a char array with the contents of the $version variable – user3629249 Sep 19 '15 at 07:34
  • Possible duplicate of [What is the equivalent command for objdump in IBM AIX](https://stackoverflow.com/questions/16546846/what-is-the-equivalent-command-for-objdump-in-ibm-aix) – jww Sep 09 '17 at 08:55

3 Answers3

0

You cannot get source back from a compiled executable. There is a variety of information you can get from it though. For instance, you can get the size of the data, bss, and text sections (through the size) command. You can also install the Linux utils for AIX which will give you more tools that can shed light on your executable (see What is the equivalent command for objdump in IBM AIX). Recent AIX binaries are in a format called XCOFF64 or XCOFF32 (both have good articles on wikipedia).

Community
  • 1
  • 1
Ram Rajamony
  • 1,717
  • 15
  • 17
  • The configuration control system, like SVN, will still have the original source available as a specific version. if that version is available within the object/executable file, then it is easy to go to SVN and request that specific version. – user3629249 Sep 19 '15 at 07:37
0

It sounds like you're describing the what(1) and ident(1) commands, used to find file versions embedded as strings in an executable.

Those strings, containing @(#) or $Id, were inserted into source code files by the version control systems, SCCS and RCS, of olden times.

0

I've found a way to do what I wanted to. Using the '#pragma comment(user, "comment")' line (I didn't knew this one) it writes at compilation and link this "comment" in the end of the binary file, so I include this line on each .c file. With a the parsing of the executable, I'm able to recover the versions of each files with only the binary.

Thanks for your help again and your time :) .

Ežekiel
  • 15
  • 6
  • (Hopefully you won't forget updating this "comment" in your files. I know I would.) – Zsigmond Lőrinczy Sep 19 '15 at 18:11
  • You can parse the executable with `strings my_exe_file` – Walter A Sep 19 '15 at 19:48
  • Walter A, I tried but the last line who contains the commentary isn't recognized as a "string" and it does not works, I already tried ^^ then I put symbols at the begining and the end, I cat -v , tr the symbol as '\n', grep the lines with the pattern "VERSION_OF" (it's always written in the comment). That's how I proceed. – Ežekiel Sep 21 '15 at 07:21