This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: 3.3.1 - random bytes in object files
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gschafer at zip dot com dot au
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 08 Aug 2003 10:11:13 +0200 (CEST)
- Subject: Re: 3.3.1 - random bytes in object files
- Reply-to: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
Hi Greg,
you wrote:
> Hi
>
> Should I always expect the exact same bytes in my compiled object files?
>
> I would have thought "yes". And this has always been the case up until now.
> While testing out 3.3.1 I noticed that my installations of libstdc++ were
> not identical.
>
> I've managed to narrow it down and the cause seems to be due to
> -ffunction-sections
>
> This is taken from libstdc++/src/io-inst.cc
>
> ----------
> #include <ios>
> #include <iomanip>
> #include <iostream>
>
> namespace std
> {
> // basic_ios
> template class basic_ios<char>;
> #ifdef _GLIBCPP_USE_WCHAR_T
> template class basic_ios<wchar_t>;
> #endif
>
> // iomanip
> template class _Setfill<char>;
> template _Setfill<char> setfill(char);
> #ifdef _GLIBCPP_USE_WCHAR_T
> template class _Setfill<wchar_t>;
> template _Setfill<wchar_t> setfill(wchar_t);
> #endif
>
> // iostream
> template class basic_iostream<char>;
> #ifdef _GLIBCPP_USE_WCHAR_T
> template class basic_iostream<wchar_t>;
> #endif
> } // namespace std
> ----------
>
> $ g++ -ffunction-sections -c io-inst.cc -o io-inst.o
> $ mv io-inst.o io-inst.o.XXX
> $ g++ -ffunction-sections -c io-inst.cc -o io-inst.o
> $ strip io-inst.o*
> $ cmp -lb io-inst.o.XXX io-inst.o
> 19646 170 x 70 8
> 19647 121 Q 144 d
> 19648 121 Q 122 R
> 19649 145 e 105 E
> 19650 64 4 127 W
>
> Diffing objdump output shows me this:-
>
> -132 .text._GLOBAL__I__ZNKSt8ios_base6getlocEvio_inst.ccxQQe4a 0000001c
> 00000000 00000000 00002590 2**1
> +132 .text._GLOBAL__I__ZNKSt8ios_base6getlocEvio_inst.cc8dREWa 0000001c
> 00000000 00000000 00002590 2**1
>
> -RELOCATION RECORDS FOR
> [.text._GLOBAL__I__ZNKSt8ios_base6getlocEvio_inst.ccxQQe4a]: (none)
> +RELOCATION RECORDS FOR
> [.text._GLOBAL__I__ZNKSt8ios_base6getlocEvio_inst.cc8dREWa]: (none)
>
>
>
> So what's up here? Is this a binutils problem or something wrong with the
> compiler?
GCC produces different results on purpose. This has to do with anonymous
namespaces (see PR 9393). You can use "-frandom-seed=0" to get the same
results with every compilation.
> If someone can confirm that I'm not going nuts, I'll happily file
> a bug if indeed it is one.
IANAP (I am not a psychiatrist), but seeing different object files is not
a sign of going nuts ;-)
> Thanks for gcc.
> Greg
>
Regards,
Volker