-2

I am using cmp command in x86 processor and is working properly (binary files are generated using gcc) but while using it in arm cortex a9, it does not give proper output (binaries are generated using cross gcc)

board specific binaries while comparing in X86 machine using cmp command, produces proper output.

X-86 machine:

say I got 2 files a.bin, b.bin (should be same while comparing using cmp)

cmp a.bin b.bin

and its proper.

Arm cortex A9:

a.bin, b.bin

cmp a.bin b.bin

here also it must be same.

but it generates a mismatch.


any clue please !!

San
  • 905
  • 3
  • 16
  • 33
  • Are the versions of `gcc` the same. Run `gcc -v` on both and post the output. Also, are you calling them identically? See also: [binary changes each build](http://stackoverflow.com/questions/4140329/binary-object-file-changing-in-each-build). – artless noise May 31 '13 at 16:26
  • is this a exe vs elf thing? elf and other formats sometimes gcc and other compilers put a time stamp from compile time which is pretty easy to see if byte compare the files. some formats it may not. if they are supposedly raw binary files with no elf/coff/exe like wrapper then see tangrs answer, there is no reason to expect two binaries to match even with two tools that share the same parent name (gcc, msvc, etc). – old_timer May 31 '13 at 19:03
  • please show/list the differences. – old_timer May 31 '13 at 19:03

1 Answers1

0

Your question isn't very clear and is a little vague so I'll take a stab in the dark and assume that you're asking why the same source code compiles to different files.

Although a compiled program (assuming no UB or portability issues) will be functionally the same no matter what compiler is used, the program on the binary level won't necessarily be.

Different optimization levels will generate different files for example. The compiler may embed build dates into the file. Different compilers will arrange the code differently.

These are all reasons why you may be getting different outputs for the 'same' program.

tangrs
  • 9,709
  • 1
  • 38
  • 53