[GOLD][PATCH] Addend reader struct for stubs.

Ian Lance Taylor iant@google.com
Fri Oct 30 23:42:00 GMT 2009


"Doug Kwan (關振德)" <dougkwan@google.com> writes:

> +// Functor to read reloc addends during stub generation.
> +
> +template<int sh_type, bool big_endian>
> +struct Stub_addend_reader
> +{
> +  // Return the addend for a relocation of a particular type.  Depending
> +  // on whether this is a REL or RELA relocation, read the addend from a
> +  // view or from a Reloc object.
> +  elfcpp::Elf_types<32>::Elf_Swxword
> +  operator()(
> +    unsigned int /* r_type */,
> +    const unsigned char* /* view */,
> +    const typename Reloc_types<sh_type,
> +			       32, big_endian>::Reloc& /* reloc */) const
> +  { gold_unreachable(); }
> +};

You don't have to define this operator() -- nothing will call it.  It
should suffice to do

template<int sh_type, bool big_endian>
struct Stub_addend_reader;

All the actual uses will use the specializations.


> +// Stub_addend_reader methods.
> +
> +// Read the addend of a REL relocation of type R_TYPE at VIEW.
> +
> +template<bool big_endian>
> +elfcpp::Elf_types<32>::Elf_Swxword
> +Stub_addend_reader<elfcpp::SHT_REL, big_endian>::operator()(
> +    unsigned int r_type,
> +    const unsigned char* view,
> +    const typename Reloc_types<elfcpp::SHT_REL, 32, big_endian>::Reloc&) const
> +{
> +  switch(r_type)

s/switch(/switch (/


This is OK with those changes.

Thanks.

Ian



More information about the Binutils mailing list