Linkage order for compiler-generated code?

Chris Johns chrisj at rtems.org
Thu Aug 23 01:54:06 UTC 2007


Phil Torre wrote:
> 
> We build our powerpc-targeted RTEMS code on either Cygwin or Linux,
> as suits the particular developer.  A while back, I made sure that
> we could obtain a bit-identical image from the same source, regardless
> of build host.  I just went back to revisit that assumption, and found
> that it was false.
> 

Your mileage may vary here. I help chase a similar sort of issue with the 
Coldfire for the same gcc version on different versions of Windows. It turned 
out MS had change the sort function and this changed the way some registers 
where being placed on the stack and this changed the code. Both sort routines 
where correct and the generated code was correct.

> 
> Does anyone know what controls the order that the extra functions get
> linked in?

Is it the order of the files linked and therefore depends on the file system ?

It could also be the order of the objects in the library that provides those 
functions being linked in.

You might be able to control this with a linker command file, eg try and list 
the specific functions in the correct section. I have never done this so do 
not know if it is possible.

>  (This is more appropriate to the gcc list, but I can't
> find anything even relevant there.)
> 

You may find binutils is more appropriate, ie ar and ld.

The compiler is free to change the order of these things and still be correct. 
People often embed a date and time into systems and this also effects the CRC. 
In past system where this sort of thing is important we have written into the 
validation procedure exclusion regions and then diff'ed the images. The CRC 
was not the compared.

Regards
Chris



More information about the users mailing list