Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing 2 Obj files

Status
Not open for further replies.

CCprog

Programmer
Feb 6, 2003
2
US
Hi,
I took 2 exactly same C files, gave a diff name to each

eg. of C code.
main()
{
int i,j,k=0;
for(i=0;i<10;i++)
for(j=0;j<10;j++)
k++;
return 0;
}

now i compiled these with &quot;cc -c&quot; option and compared the obj files with &quot;diff&quot; and &quot;cmp&quot; utilities in linux and i got differences.

NOW FOR THE QUESTIONS

1. why are the compiled output files differnt for this
although the code is exactly the same?what can be the
reason for this?

2. are there any utilities which can be used to compare the
similarity of two obj files??

thanks
 
For linux, and possibly other *nixes there is objdump:
man 1 objdump

HTH
 
Hi,
some compilers instatiate the date time stamp in the object file and most all encode the name of the .c file into the object file.


therefore it is hard to compare .obj files without taking these into account.

you might want to try

strings -a obj1.o > /tmp/obj1
strings -a obj2.o > /tmp/obj2

and then diff the strings and see if the date time stamp or the file names show up in the diffs.

----
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top