Re: Looking for a.out file compare

zoo@cygnus.com (david d `zoo' zuhn)
Wed, 22 Sep 1993 18:55:17 GMT

          From comp.compilers

Related articles
Looking for a.out file compare ceagan@bnr.ca (Charles (C.) Eagan) (1993-09-21)
Re: Looking for a.out file compare zoo@cygnus.com (1993-09-22)
| List of all articles for this month |

Newsgroups: comp.compilers
From: zoo@cygnus.com (david d `zoo' zuhn)
Keywords: linker
Organization: Compilers Central
References: 93-09-081
Date: Wed, 22 Sep 1993 18:55:17 GMT

>> I am investigating methods for comparing a.out (and b.out) format files in
>> an attempt to determine if they are functionally identical.


>> Two identical sets of C++ files can produce a different (a la cmp) .o file
>> because of things like preprocessor macros __FILE__, __LINE__, __DATE__
>> and __TIME__ and the fact that the include paths may change between
>> instances. All this info is found in the .o file.


>> [GCC does something like this using a simple hack that throws away the
>> beginning of each file and compares the rest. Seems to work OK. -John]


The simple hack that GCC doesn't always do the right thing by this. For
example, if you compile the same file with the same options, but from two
different source directories, the source directory information gets
stashed into the .o and produces dis-similar files, even though the
functional content is the same.


While the hack is useful for a limited set of problems, I think that what
was requested was something more.


What I'd do, if I were to write such a program, would be to use the BFD
library (which is used in the GNU binutils, assembler, and debugger).
This provides access to the parts of an object file on a functional level,
instead of having to know all about the .o file formats. Input the
executable code for each .o file, strip away debugging information, and do
your comparison there.


Using BFD will also make this work for any object file format that BFD
supports.


    david d 'zoo' zuhn
        cygnus support
        zoo@cygnus.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.