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: [GOLD][PATCH] Add Arm_output_section class and downcasting hooks.


"Doug Kwan (éæå)" <dougkwan@google.com> writes:

>> 2009-10-22  Doug Kwan  <dougkwan@google.com>
>>
>>        * arm.cc (Arm_output_section, Arm_relobj): Forward class declarations.
>>        (Arm_input_section::do_arm_input_section): New method.
>>        (Arm_output_section): New class definition.
>>        (Arm_output_section::create_stub_group,
>>        Arm_output_section::group_sections): New method definitions.
>>        * object.h (Arm_relobj): Forward class declaration.
>>        (Relobj::arm_relobj): New function template definition.
>>        (Relobj::do_arm_relobj): New overloaded method definitions.
>>        * output.h (Arm_input_section, Arm_output_section): Forward class
>>        declarations.
>>        (Output_relaxed_input_section::arm_input_section): New function
>>        template definition.
>>        (Output_relaxed_input_section::do_arm_input_section): New
>>        overloaded method definitions.
>>        (Output_section::arm_output_section): New function template
>>        definition.
>>        (Output_section::do_arm_output_section): New overloaded method
>>        definitions.


> +  Input_section_list::const_iterator after_end = end + 1;
> +  for (Input_section_list::const_iterator p = begin; p != after_end; ++p)

This is not the convention for C++ iterators.  The convention is p =
begin; p != end; ++p, without using after_end.  Moreover, I see that
later on you do sometimes pass CONTAINER.end() as the end parameter
here, in which case end + 1 is undefined.



> +  // Return a pointer to self if this is an Arm_relobj or NULL otherwise.
> +  template<bool big_endian>
> +  Arm_relobj<big_endian>*
> +  arm_relobj()
> +  {
> +    Arm_relobj<big_endian>* as_arm_relobj;
> +    this->do_arm_relobj(&as_arm_relobj);
> +    return as_arm_relobj;
> +  }

This is nicely type safe but I don't think we want target specific
stuff getting into object.h/object.cc.  Just use a static_cast in
arm.cc.  If you want to make it safe, do something which verifies that
machine_code(), get_size(), and is_big_endian() are what you expect.


This is OK with these changes if you only change arm.cc.  If
static_cast doesn't do what you need, let's take another round.

Ian


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