[PATCH][GOLD] Add make_elf_object target hooks.

Ian Lance Taylor iant@google.com
Tue Aug 18 18:35:00 GMT 2009


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

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

I originally left it out because it can fail, and it's weird to have a
constructor fail.  I guess I'd prefer to keep it separate for now.


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

Yeah, I guess the way you did it is fine.

Ian



More information about the Binutils mailing list