This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc binary output differs whether it is built from *.o or *.a


Alexandre Beaugy <beaugy.a@free.fr> writes:

> Then, how does gcc behaves at link time? How did it handles static
> libraries? Or, how perhaps, the linker behaves? Does gcc pass it a
> list of object files to link (considering it previously extracted the
> files from the ar archive)? Why does some binaries, linked with static
> libs, have a constant checksum, where others cannot consecutively have
> the same checksum twice, with the same C sources?

gcc's behaviour at link time is to pass the arguments to the linker,
with some prepended files and some appended files and libraries.

When using an archive, the main effect on the linker is the order of
the symbols in the archive symbol map.  You can see the archive symbol
map using nm --print-armap on the archive.  The order of the symbols
in the archive symbol map is determined by the order in which the
objects are passed to the ar program when creating the archive.

I assume you are using precisely the same ld and ar programs in all
cases, otherwise all bets are off.

By the way, as of binutils 2.20 GNU ar supports a D modifier to
generate a deterministic archive, which should always be bitwise
identical given the same inputs.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]