public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Target specific Relobj?
@ 2009-08-16  9:41 Doug Kwan (關振德)
  2009-08-16 10:14 ` Doug Kwan (關振德)
  2009-08-16 16:51 ` Ian Lance Taylor
  0 siblings, 2 replies; 4+ messages in thread
From: Doug Kwan (關振德) @ 2009-08-16  9:41 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

Hi Ian,

    I need to attach some ARM specific information to Relobj objects.
To do that I can think of two ways

    1.  Use an Unordered_map<Relobj*, Arm_specific_info*>
    2.  Sub-classing Relobj (or Sized_relobj)

I actually prefer 2.  I would like to check make_elf_sized_object() to
check if a target has its own make_elf_sized_object.  If so, it calls
the target's own version.  We'll need to pass size and big_endian as
two extra parameters.  What do you think?

-Doug

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Target specific Relobj?
  2009-08-16  9:41 Target specific Relobj? Doug Kwan (關振德)
@ 2009-08-16 10:14 ` Doug Kwan (關振德)
  2009-08-16 16:51 ` Ian Lance Taylor
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Kwan (關振德) @ 2009-08-16 10:14 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

I looked at the code and found I need a few adjustment of the proposed change.

-Targets have size and endianity, so there is no need to pass size and
endianity to target-specific  make_elf_sized_object.
-make_elf_sized_object takes a elfcpp::Ehdr<size, big_endian>& ehdr as
parameter,  I would change this back to a plain unsigned char pointer
so that we only need one hook, instead of 4.

-Doug

2009/8/16 Doug Kwan (關振德) <dougkwan@google.com>:
> Hi Ian,
>
>    I need to attach some ARM specific information to Relobj objects.
> To do that I can think of two ways
>
>    1.  Use an Unordered_map<Relobj*, Arm_specific_info*>
>    2.  Sub-classing Relobj (or Sized_relobj)
>
> I actually prefer 2.  I would like to check make_elf_sized_object() to
> check if a target has its own make_elf_sized_object.  If so, it calls
> the target's own version.  We'll need to pass size and big_endian as
> two extra parameters.  What do you think?
>
> -Doug
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Target specific Relobj?
  2009-08-16  9:41 Target specific Relobj? Doug Kwan (關振德)
  2009-08-16 10:14 ` Doug Kwan (關振德)
@ 2009-08-16 16:51 ` Ian Lance Taylor
  2009-08-17  9:02   ` Doug Kwan (關振德)
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2009-08-16 16:51 UTC (permalink / raw)
  To: Doug Kwan (關振德); +Cc: binutils

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

>     I need to attach some ARM specific information to Relobj objects.
> To do that I can think of two ways
>
>     1.  Use an Unordered_map<Relobj*, Arm_specific_info*>
>     2.  Sub-classing Relobj (or Sized_relobj)
>
> I actually prefer 2.  I would like to check make_elf_sized_object() to
> check if a target has its own make_elf_sized_object.  If so, it calls
> the target's own version.  We'll need to pass size and big_endian as
> two extra parameters.  What do you think?

Creating a child class makes sense to me.

> -Targets have size and endianity, so there is no need to pass size and
> endianity to target-specific  make_elf_sized_object.
> -make_elf_sized_object takes a elfcpp::Ehdr<size, big_endian>& ehdr as
> parameter,  I would change this back to a plain unsigned char pointer
> so that we only need one hook, instead of 4.

Probably the way to do it is to always call the target to create the
object.  Then the hook would simply be

   template<int size, bool big_endian>
   make_object(const elfcpp::Ehdr<size, big_endian>&);

with the obvious default implementation.

Admittedly targets which needed to override this would have to
explicitly instantiate the required forms of the function.  This would
also mean reworking the current way that set_target works, to call
select_target before creating the object.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Target specific Relobj?
  2009-08-16 16:51 ` Ian Lance Taylor
@ 2009-08-17  9:02   ` Doug Kwan (關振德)
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Kwan (關振德) @ 2009-08-17  9:02 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

Yes, that is simpler and better. I will make a patch.  Thanks.

-Doug

2009/8/16 Ian Lance Taylor <iant@google.com>:

> Probably the way to do it is to always call the target to create the
> object.  Then the hook would simply be
>
>   template<int size, bool big_endian>
>   make_object(const elfcpp::Ehdr<size, big_endian>&);
>
> with the obvious default implementation.
>
> Admittedly targets which needed to override this would have to
> explicitly instantiate the required forms of the function.  This would
> also mean reworking the current way that set_target works, to call
> select_target before creating the object.
>
> Ian
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-16 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-16  9:41 Target specific Relobj? Doug Kwan (關振德)
2009-08-16 10:14 ` Doug Kwan (關振德)
2009-08-16 16:51 ` Ian Lance Taylor
2009-08-17  9:02   ` Doug Kwan (關振德)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).