runtime identification of compiler through executable - Aix

This is a discussion on runtime identification of compiler through executable - Aix ; Is there is any tool on AIX which can tell me by looking at the executable that what was the complier to make that executable...

+ Reply to Thread
Results 1 to 9 of 9

Thread: runtime identification of compiler through executable

  1. runtime identification of compiler through executable

    Is there is any tool on AIX which can tell me by looking at the
    executable that what was the complier to make that executable


  2. Re: runtime identification of compiler through executable


    shankha wrote:
    > Is there is any tool on AIX which can tell me by looking at the
    > executable that what was the complier to make that executable


    You can try a couple of things, but I am not sure it will give you
    exactly what you are looking for:

    The "file" command will tell you if a program is executable, but does
    not give you the specifics such as indicating that the exceutable was
    written in C or Perl or Korn or whatever.

    You could try the "strings" command, which may help. It sometimes list
    the compiler at the top, or the libraries used.

    For example, the first ten lines of this "kornsample" script shows it
    was compiled using a package called Shell-Lock (It is a Korn Shell
    script):

    # strings kornsample|head
    H: Too many args
    : No read permission
    awk
    @(#)shell-lock
    1.6.2.2
    ?BBOF
    KTYPPa
    +40;3?
    9;4/|^|
    j^o89&o.)00


    In the "csample" program below, you can see a library "threads_init.c"
    and its original path. This suggests it was a C source, and the path
    may suggest whether Visual Age or some other C compiler was used.

    # strings csample |head
    @(#)61
    1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos510
    7/11/00 12:04:
    14
    hea2
    bat#
    aba2
    info
    jobs
    qmv1
    hea3
    srch


    Hope this helps

    Steve


  3. Re: runtime identification of compiler through executable

    I don' t think there is a way to tell that
    a certain compiler has created an executable.

    Now, you can tell what an executable has been linked against
    by using "dump -H" or ("dump -n" for alot of verbose output
    including symbols in libraries that are referenced)

    You can also tell what source files have been used for an
    executable (If they followed the sccs file format) by using "what"

    Hope this helps,
    -Casey

    steven_nospam at Yahoo! Canada wrote:
    > shankha wrote:
    > > Is there is any tool on AIX which can tell me by looking at the
    > > executable that what was the complier to make that executable

    >
    > You can try a couple of things, but I am not sure it will give you
    > exactly what you are looking for:
    >
    > The "file" command will tell you if a program is executable, but does
    > not give you the specifics such as indicating that the exceutable was
    > written in C or Perl or Korn or whatever.
    >
    > You could try the "strings" command, which may help. It sometimes list
    > the compiler at the top, or the libraries used.
    >
    > For example, the first ten lines of this "kornsample" script shows it
    > was compiled using a package called Shell-Lock (It is a Korn Shell
    > script):
    >
    > # strings kornsample|head
    > H: Too many args
    > : No read permission
    > awk
    > @(#)shell-lock
    > 1.6.2.2
    > ?BBOF
    > KTYPPa
    > +40;3?
    > 9;4/|^|
    > j^o89&o.)00
    >
    >
    > In the "csample" program below, you can see a library "threads_init.c"
    > and its original path. This suggests it was a C source, and the path
    > may suggest whether Visual Age or some other C compiler was used.
    >
    > # strings csample |head
    > @(#)61
    > 1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos510
    > 7/11/00 12:04:
    > 14
    > hea2
    > bat#
    > aba2
    > info
    > jobs
    > qmv1
    > hea3
    > srch
    >
    >
    > Hope this helps
    >
    > Steve



  4. Re: runtime identification of compiler through executable

    i need to use this information in a source file ...
    caseyjbrotherton@gmail.com wrote:
    > I don' t think there is a way to tell that
    > a certain compiler has created an executable.
    >
    > Now, you can tell what an executable has been linked against
    > by using "dump -H" or ("dump -n" for alot of verbose output
    > including symbols in libraries that are referenced)
    >
    > You can also tell what source files have been used for an
    > executable (If they followed the sccs file format) by using "what"
    >
    > Hope this helps,
    > -Casey
    >
    > steven_nospam at Yahoo! Canada wrote:
    > > shankha wrote:
    > > > Is there is any tool on AIX which can tell me by looking at the
    > > > executable that what was the complier to make that executable

    > >
    > > You can try a couple of things, but I am not sure it will give you
    > > exactly what you are looking for:
    > >
    > > The "file" command will tell you if a program is executable, but does
    > > not give you the specifics such as indicating that the exceutable was
    > > written in C or Perl or Korn or whatever.
    > >
    > > You could try the "strings" command, which may help. It sometimes list
    > > the compiler at the top, or the libraries used.
    > >
    > > For example, the first ten lines of this "kornsample" script shows it
    > > was compiled using a package called Shell-Lock (It is a Korn Shell
    > > script):
    > >
    > > # strings kornsample|head
    > > H: Too many args
    > > : No read permission
    > > awk
    > > @(#)shell-lock
    > > 1.6.2.2
    > > ?BBOF
    > > KTYPPa
    > > +40;3?
    > > 9;4/|^|
    > > j^o89&o.)00
    > >
    > >
    > > In the "csample" program below, you can see a library "threads_init.c"
    > > and its original path. This suggests it was a C source, and the path
    > > may suggest whether Visual Age or some other C compiler was used.
    > >
    > > # strings csample |head
    > > @(#)61
    > > 1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos510
    > > 7/11/00 12:04:
    > > 14
    > > hea2
    > > bat#
    > > aba2
    > > info
    > > jobs
    > > qmv1
    > > hea3
    > > srch
    > >
    > >
    > > Hope this helps
    > >
    > > Steve



  5. Re: runtime identification of compiler through executable

    caseyjbrotherton@gmail.com wrote:
    > I don' t think there is a way to tell that
    > a certain compiler has created an executable.


    If the executable hasn't been stripped, dump -tv (to look at the
    regular symbol table) will show you .file entries placed by
    the xlc/xlC compilers. This information includes version number,
    although not necessarily more detail than version/release.

    There are so few compilers available for AIX that you can
    usually figure out if it was the XL compilers (via
    strings and dump) or gcc/g++ (via dump -Hv and looking at the
    dependent modules).

    Mostly, it's about derivation heuristics.


  6. Re: runtime identification of compiler through executable

    i want to use this information in c code .. like if compiler=gcc then
    do some few things
    Gary R. Hook wrote:
    > caseyjbrotherton@gmail.com wrote:
    > > I don' t think there is a way to tell that
    > > a certain compiler has created an executable.

    >
    > If the executable hasn't been stripped, dump -tv (to look at the
    > regular symbol table) will show you .file entries placed by
    > the xlc/xlC compilers. This information includes version number,
    > although not necessarily more detail than version/release.
    >
    > There are so few compilers available for AIX that you can
    > usually figure out if it was the XL compilers (via
    > strings and dump) or gcc/g++ (via dump -Hv and looking at the
    > dependent modules).
    >
    > Mostly, it's about derivation heuristics.



  7. Re: runtime identification of compiler through executable

    shankha wrote:
    > i want to use this information in c code .. like if compiler=gcc then
    > do some few things


    That's not a runtime assessment, it's a compile time assessment.
    Just require your builder to use -DGCC or -DXLC and
    use #ifdef GCC/etc in your code.

  8. Re: runtime identification of compiler through executable

    okay sorry .. i was not able to explain my problem

    suppose there is a executable
    gcc -g -o test test.c

    then when i do myproduct test ..

    inside that i want to find some way to find out if it was gcc or not
    and then set some boolean variable setgcc

    and then write something like
    if(setgcc)
    do this
    else
    do this
    inside my code
    i do want to pass any compile time options
    Gary R. Hook wrote:
    > shankha wrote:
    > > i want to use this information in c code .. like if compiler=gcc then
    > > do some few things

    >
    > That's not a runtime assessment, it's a compile time assessment.
    > Just require your builder to use -DGCC or -DXLC and
    > use #ifdef GCC/etc in your code.



  9. Re: runtime identification of compiler through executable

    shankha wrote:
    > okay sorry .. i was not able to explain my problem
    >
    > suppose there is a executable
    > gcc -g -o test test.c
    >
    > then when i do myproduct test ..
    >
    > inside that i want to find some way to find out if it was gcc or not
    > and then set some boolean variable setgcc


    Aside from heuristics that are based upon the symbol table or other
    information, there's no reliable method to figure out how an
    executable was constructed.

+ Reply to Thread