Re: Binary File Differences: When Do Differences Matter?



Henry Townsend <henry.townsend@xxxxxxxx> wrote:
Dan Foster wrote:
In article <xPNFf.1$F5.0@xxxxxxxxxxxxxxxxxxxxxxxx>, Robert Halonen
<halork@xxxxxxxxx> wrote:
We will soon be building our software system on new hardware (same
make/model, just new boxes). I have noticed that even on our existing
hardware, building the exact same software from the same source will
give differing binary files, some even with minor file size
differences.

If sources and makefiles hasn't changed, then it's probably compiler
changes -- usually bugfixes or better optimized code generation.

Actually it's trickier than that. I'm currently struggling with the same
issue as the OP. I've always thought that Solaris ELF binaries were
"stable" - i.e. that a file compiled on the same machine twice with the
same cmdline and environment a few minutes apart would generate
identical bits each time. But from a test, this seems to be true when
compilation and linking is done via the gcc toolchain but *not* with Sun
Studio 11.

I just tracked this a little further. Turns out gcc generates nonvarying
binaries with or without the -g flag whereas Sun Studio ("cc") generates
identical output without -g, but when -g is turned on the checksum
changes from build to build. See below:

% cc -o hello hello.c && cksum hello
123815386 6888 hello
% cc -o hello hello.c && cksum hello
123815386 6888 hello

% cc -g -o hello hello.c && cksum hello
3486775769 7556 hello
% cc -g -o hello hello.c && cksum hello
1243289241 7556 hello

Can anyone tell us the answer? Does Sun Studio insert a date stamp into
the debug data or what? And is there a way to suppress that?

This probably is due to the globalization prefix.
No documented and supported way to suppress that.
An undocumented and unsupported -W0,-noglobal will prevent this
but doing so will break dbx's break-and-continue (for -g case) and -xipo.

I am not sure what the Solaris equivalent to objdump -d -S might be, but
mentioned the GNU version here so that someone may be able to offer the
Solaris equivalent.

There's no exact equivalence,
though er_src (part of Performance Analyzer in Studio) can do objdump -S
but most of other objdump functionality can be found in elfdump.
--
#pragma ident "Seongbae Park, compiler, http://blogs.sun.com/seongbae/";
.