[PATCH][GOLD] Add a few methods and data members for stub-generation.

Ian Lance Taylor iant@google.com
Tue Nov 3 15:08:00 GMT 2009


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

> +// Make a new Arm_input_section object.
> +
> +template<bool big_endian>
> +Arm_input_section<big_endian>*
> +Target_arm<big_endian>::new_arm_input_section(
> +    Relobj* relobj,
> +    unsigned int shndx)
> +{
> +  Input_section_specifier iss(relobj, shndx);
> +
> +  // Make sure that it we have not created another Arm_input_section
> +  // for this input section already.
> +  typename Arm_input_section_map::const_iterator p =
> +    this->arm_input_section_map_.find(iss);
> +  gold_assert(p == this->arm_input_section_map_.end());
> +
> +  Arm_input_section<big_endian>* arm_input_section =
> +    new Arm_input_section<big_endian>(relobj, shndx);
> +  arm_input_section->init();
> +
> +  // Register new Arm_input_section in map for look-up.
> +  this->arm_input_section_map_[iss] = arm_input_section;
> +  return arm_input_section; 
> +}

You can save a hash table lookup by writing:

  Arm_input_section<big_endian>* arm_input_section =
    new Arm_input_section<big_endian>(relobj, shndx);
  arm_input_section->init();

  // Register new Arm_input_section in map for look-up.
  std::pair<typename Arm_input_section_map::iterator, bool> ins =
    this->arm_input_section_map_.insert(std::make_pair(iss, arm_input_section));

  // Make sure we have not created another Arm_input_seciton for this
  // input section already.
  gold_assert(ins.second);

  return arm_input_section; 



This is OK with a change along those lines.

Thanks.

Ian



More information about the Binutils mailing list