This is the mail archive of the 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: [GOLD] powerpc64 --gc-sections RFC

On Thu, Sep 6, 2012 at 5:57 PM, Alan Modra <> wrote:
> I've revised the patch considerably.  I now want to add the following
> to Sized_target, and I'm confused about the rules.
>   // Handle target specific gc actions when adding a gc reference.
>   virtual void
>   do_gc_add_reference(Symbol_table* /* symtab */,
>                       Object* /* src_obj */,
>                       unsigned int /* src_shndx */,
>                       Object* /* dst_obj */,
>                       unsigned int /* dst_shndx */,
>                       typename elfcpp::Elf_types<size>::Elf_Addr /* dst_off */)
>   { }
> Does this need a gc_add_reference in Sized_target?

Not necessarily.  The rule is: virtual methods are always protected.
They are only ever called by the parent class and by child classes.
Public methods are never virtual.  In the common case of a public
parent method that is implemented by child classes, the public method
calls the protected virtual method.  The goal is to cleanly separate
the interface seen by users of the class and the interface implemented
by children of the class.

> Or should I make
> that last parameter a uint64_t and treat this function like
> adjust_elf_header/do_adjust_elf_header?  Note that in this case we
> will be calling the function from gc.h:gc_process_relocs which is
> templated on size so I'm thinking uint32_t -> uint64_t -> uint32_t
> conversions for 32-bit targets is a little unclean.

Making the last parameter a uint64_t is probably fine.  You're right
that it's a little unclean.  It's also OK to have a public method in
the child class, if you can get to it.  Just don't make it virtual.


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