|Looking for a.out file compare firstname.lastname@example.org (Charles (C.) Eagan) (1993-09-21)|
|Re: Looking for a.out file compare email@example.com (1993-09-22)|
|From:||firstname.lastname@example.org (david d `zoo' zuhn)|
|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
david d 'zoo' zuhn
Return to the
Search the comp.compilers archives again.