Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
Hi all. I've an ELF file (exec)...i'm interested in getting a the function prototype of the "myfunc"... can you help me?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    9

    get the function's prototype from elf file


    Hi all.
    I've an ELF file (exec)...i'm interested in getting a the function prototype of the "myfunc"...
    can you help me?

  2. #2
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    152
    You can't retrieve the function prototype from an ELF file, with the possible exception of doing it through disassembly, but that would be tricky and error-prone.

    You need a header file, really.

  3. #3
    Just Joined!
    Join Date
    Apr 2010
    Posts
    9
    a header file? i have only the elf file....

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    It depends upon whether or not it has been stripped of debugging information. Is it a .o, .a, .so, or is it an executable file?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Just Joined!
    Join Date
    Apr 2010
    Posts
    9
    it's an exec file...i solved the problem....simply: the file is compiled with -g option so i can use a gdb "call" to see the prototype of my function :P

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    Quote Originally Posted by np2k View Post
    it's an exec file...i solved the problem....simply: the file is compiled with -g option so i can use a gdb "call" to see the prototype of my function :P
    Actually, an executable is not ELF - it is binary code. However, that would have been my suggestion, to use gdb, if you confirmed that. It's good that you figured that approach out on your own.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #7
    Just Joined!
    Join Date
    Apr 2010
    Posts
    9
    Quote Originally Posted by Rubberman View Post
    Actually, an executable is not ELF - it is binary code.
    what? the exec's format is not ELF?

    Code:
    np2k@serena:~/Desktop$ file something.smt 
    something.smt: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked
    (uses shared libs), for GNU/Linux 2.6.15, stripped
    From wiki:
    In computing, the Executable and Linkable Format (ELF, formerly called Extensible Linking Format) is a common standard file format for executables, object code, shared libraries, and core dumps
    I'm confused

  8. #8
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    152
    Quote Originally Posted by np2k View Post
    what? the exec's format is not ELF?
    Yeah, I'm not quite sure what Rubberman's getting at - the standard file format for executables on a modern Linux system is indeed ELF, which is designed to be used for shared libraries, object files and executables.

  9. #9
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    ELF is an intermediate format that is platform-neutral. The linker will take the ELF modules and convert them to binary machine-executable code. COFF (Common Object File Format) is another, older intermediate format that served the same purposes as ELF. It's possible (perhaps even likely) that the system loader can convert ELF modules dynamically to machine code. Since shared libraries are generally (on Linux at least) ELF modules, this actually makes sense. So, you executable may have been an ELF module. Without looking at it I can't say for sure.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  10. #10
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    Quote Originally Posted by JohnGraham View Post
    Yeah, I'm not quite sure what Rubberman's getting at - the standard file format for executables on a modern Linux system is indeed ELF, which is designed to be used for shared libraries, object files and executables.
    Yes, they generally are, but they don't have to be, and in fact if a program is fully linked statically (no shared libraries) I don't think the resulting binary is ELF. Of course, I'm always happy to be disabused of my ignorance...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •