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] Add make_elf_object target hooks.


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

>> + ? ? ?obj->setup(ehdr);
>
> It no longer makes sense for Object::setup to take an ehdr parameter.
> It should take a target parameter, and avoid looking up the target
> again.

Agree. I suppose all objects have targets and their targets do not
change.   Should setup() be simply part of the constructor?

>
>> + ?// make_elf_object hooks. ?There are four versions of these for
>> + ?// different address sizes and endianities.
>> +
>> +#ifdef HAVE_TARGET_32_LITTLE
>> + ?// Virtual functions which may be overriden by the child class.
>> + ?virtual Object*
>> + ?do_make_elf_object(const std::string& name, Input_file* input_file,
>> + ? ? ? ? ? ? ? ? ?off_t offset, const elfcpp::Ehdr<32, false>& ehdr);
>> +#endif
>> +
>> +#ifdef HAVE_TARGET_32_BIG
>> + ?// Virtual functions which may be overriden by the child class.
>> + ?virtual Object*
>> + ?do_make_elf_object(const std::string& name, Input_file* input_file,
>> + ? ? ? ? ? ? ? ? ?off_t offset, const elfcpp::Ehdr<32, true>& ehdr);
>> +#endif
>> +
>> +#ifdef HAVE_TARGET_64_LITTLE
>> + ?// Virtual functions which may be overriden by the child class.
>> + ?virtual Object*
>> + ?do_make_elf_object(const std::string& name, Input_file* input_file,
>> + ? ? ? ? ? ? ? ? ?off_t offset, const elfcpp::Ehdr<64, false>& ehdr);
>> +#endif
>> +
>> +#ifdef HAVE_TARGET_64_BIG
>> + ?// Virtual functions which may be overriden by the child class.
>> + ?virtual Object*
>> + ?do_make_elf_object(const std::string& name, Input_file* input_file,
>> + ? ? ? ? ? ? ? ? ?off_t offset, const elfcpp::Ehdr<64, true>& ehdr);
>> +#endif
>
> Interesting problem. ?I wonder if there is anything we can do to make
> that easier to write.

Unfortunately, virtual functions cannot be templated.  That's why I
mentioned changing the paratmeter ehdr back to a raw unsigned char
pointer.  If we do so,  we only have one virtual function instead of
four.  The downside of doing that is that callers must ensure that the
pointer points to something valid.   Passing an
Elfcpp::Ehdr<size,big_endian> object enforces that automatically.

-Doug

> Ian
>


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