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: [PATCH] gold: remove unused methods in Output_data_got_powerpc


>> 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.

-cary


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