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: Same source generates different object code for gcc 4.1.2


sudhakar govindavajhala <sudhakarg79spam@gmail.com> writes:

> I am wondering why code generated by the same gcc 4.1.2 compiler on
> the same source and the same machine generates different codes at
> different times.  I find this behavior very odd.  Could someone please
> add me some perspective on this?

In gcc 4.1 doing a #include of <iostream.h> causes your object file to
include a global constructor.  That global constructor would normally be
given a name associated with the first global symbol in your object
file.  Since your object file does not have any global symbols, the
constructor is given a randomly chosen name in the hopes of avoiding
collisions (the name also includes the name of the file you are
compiling).  You can see this if you run "readelf -s --wide" on your
object files.  That randomly chosen name will be different each time the
compiler is run (unless of course you use the -frandom-seed option).

This works differently in current mainline and the objects files are now
consistently identical.

Ian


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