This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] gold: remove unused methods in Output_data_got_powerpc
- From: Cary Coutant <ccoutant at google dot com>
- To: Roland McGrath <mcgrathr at google dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Fri, 11 Oct 2013 16:48:27 -0700
- Subject: Re: [PATCH] gold: remove unused methods in Output_data_got_powerpc
- Authentication-results: sourceware.org; auth=none
- References: <CAB=4xhrDkG1OZnJrG1eOA4NRogvo46wta9Q6_WC6LeF1R5_1Gg at mail dot gmail dot com> <CAHACq4p_PEf5R3RTA3ZFD+2rX339084gV8ATMMN3WYk=5CSrOA at mail dot gmail dot com> <20131011225626 dot GB20756 at bubble dot grove dot modra dot org> <20131011231423 dot GC20756 at bubble dot grove dot modra dot org> <CAB=4xhqw+sW7wG=dJYLcbN_9XLsmd6wCAF1U6c8RsN2xAmuzMQ at mail dot gmail dot com>
>> No, wait a minute. I do want those functions, but probably
>> misunderstood C++ rules so they aren't effective. I need to somehow
>> arrange that Output_data_got_powerpc::reserve_ent() is called before
>> Output_data_got adds anything to its entries_ vector, because the
>> powerpc got header can sit somewhere in the middle of the GOT. What's
>> the best way to accomplish that?
> You need to change those in Output_data_got (the base class) to be virtual.
> Then you can override them in Output_data_got_powerpc and use
> Output_data_got<size, big_endian>::add_got_entry to call the superclass
> method after doing what you need to do first. Also note that you need to
> name the argument type as Output_data_got<size, big_endian>::Got_entry.
> You'll probably want to do typedef Output_data_got<size, big_endian> Base;
> or suchlike in Output_data_got_powerpc so you can reduce the amount of
> typing on the lhs of each :: there.
> And, of course, add a test case that notices the failure mode of missing
> the reserve_ent call so you can tell whether you got it right.
When adding virtual functions, please observe the "no public virtuals"
guideline. Rather than make add_got_entry and add_got_entry_pair
virtual, though, I'd be OK with adding an inline reserve_entry()
method in the Output_data_got class, having it call a protected
virtual do_reserve_entry() method, and add a default empty
implementation of that method in Output_data_got. Then you can simply
override that method in Output_data_got_powerpc. That would eliminate
the need for the messy declaration of Base::Got_entry, and the messy
invocation of the superclass method.