This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: trunk gold not building unoptimized, powerpc.cc refs to invalid_address and pltresolve_size


On Thu, Dec 06, 2012 at 07:56:21PM -0800, Ian Lance Taylor wrote:
> What you've got there is a declaration of the const, just as though
> you wrote "extern int i;".  In C++98 you are required to also have a
> definition of the const, the equivalent of "int i;".  But the compiler
> is not required to diagnose the absence of the definition.  So in
> effect what happens is that if the const can be inlined everywhere it
> is needed, the compiler won't complain.  But if the compiler happens
> to not inline it, then it will complain.  Historically g++ has failed
> to inline the const when it is used in a ?: expression, and in a few
> other cases as well.  So it is simply that one of the cases above is
> being used in a way that requires the definition, when not optimizing.

Thanks for the explanation.  Indeed, I use the constants in ?:
expressions.  Applied.

	* powerpc.cc (Stub_table::do_write): Delete redundant Address
	typedef and invalid_address constant.
	(Output_data_glink, Stub_table, Target_powerpc): Explicitly
	instantiate constants.

Index: gold/powerpc.cc
===================================================================
RCS file: /cvs/src/src/gold/powerpc.cc,v
retrieving revision 1.75
diff -u -p -r1.75 powerpc.cc
--- gold/powerpc.cc	7 Dec 2012 00:03:18 -0000	1.75
+++ gold/powerpc.cc	7 Dec 2012 04:19:59 -0000
@@ -3239,9 +3239,6 @@ Stub_table<size, big_endian>::do_write(O
   unsigned char* const oview = of->get_output_view(off, oview_size);
   unsigned char* p;
 
-  typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
-  static const Address invalid_address = static_cast<Address>(0) - 1;
-
   if (size == 64)
     {
       const Output_data_got_powerpc<size, big_endian>* got
@@ -6984,4 +6981,14 @@ Target_selector_powerpc<32, false> targe
 Target_selector_powerpc<64, true> target_selector_ppc64;
 Target_selector_powerpc<64, false> target_selector_ppc64le;
 
+// Instantiate these constants for -O0
+template<int size, bool big_endian>
+const int Output_data_glink<size, big_endian>::pltresolve_size;
+template<int size, bool big_endian>
+const typename Stub_table<size, big_endian>::Address
+  Stub_table<size, big_endian>::invalid_address;
+template<int size, bool big_endian>
+const typename Target_powerpc<size, big_endian>::Address
+  Target_powerpc<size, big_endian>::invalid_address;
+
 } // End anonymous namespace.

-- 
Alan Modra
Australia Development Lab, IBM


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