This is the mail archive of the
mailing list for the binutils project.
Re: trunk gold not building unoptimized, powerpc.cc refs to invalid_address and pltresolve_size
On Thu, Dec 6, 2012 at 5:26 PM, Alan Modra <firstname.lastname@example.org> wrote:
> On Fri, Dec 07, 2012 at 10:59:36AM +1030, Alan Modra wrote:
>> On Thu, Dec 06, 2012 at 03:45:22PM -0800, Ian Lance Taylor wrote:
>> > Alan needs to add a definition for the constant. In C++98, all
>> > constants declared in classes, even those declared in template
>> > classes, require an explicit definition.
>> > template<int size, bool big_endian>
>> > const Address Target_powerpc::invalid_address;
> This makes the link error go away, but I don't really understand why
> this is necessary.. OK to apply?
> * powerpc.cc (Stub_table::do_write): Delete redundant Address
> typedef and invalid_address constant.
> (class Output_data_glink, class Stub_table): Explicitly instantiate.
> 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 01:21:14 -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,31 @@ Target_selector_powerpc<32, false> targe
> Target_selector_powerpc<64, true> target_selector_ppc64;
> Target_selector_powerpc<64, false> target_selector_ppc64le;
> +#ifdef HAVE_TARGET_32_LITTLE
> +class Output_data_glink<32, false>;
> +class Stub_table<32, false>;
Writing code like this is not wrong, but you don't need it, because
the templates are instantiated anyhow by the Target_selector_powerpc
class, and you are explicitly instantiating all variants of that
What you need is an explicit definition of the const. I haven't
tested it, but I think that I wrote before is what you need:
template<int size, bool big_endian>
const Address Target_powerpc::invalid_address;
That is a definition of the const, just like "int i;" is a definition
of i. You don't need to provide the initializer here, because you
already provided it in the declaration.