[GOLD] powerpc64 --gc-sections RFC

Ian Lance Taylor iant@google.com
Thu Sep 6 04:39:00 GMT 2012


On Wed, Sep 5, 2012 at 7:20 PM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Sep 05, 2012 at 05:31:40PM -0700, Ian Lance Taylor wrote:
>
>> > +
>> > +         symtab->gc()->add_reference(src_obj, src_indx, dst_obj, code_indx);
>> > +         if (code_indx != dst_indx)
>> > +           symtab->gc()->add_reference(src_obj, src_indx, dst_obj, dst_indx);
>>
>> Why do you need this last add_reference?
>
> That arranges to keep the .opd section.

Hmmm, right.  So in effect you will have a complete .opd section, but
some of the values will no longer point to anything.


>> > +  // Add a reference from SRC_OBJ, SRC_INDX to this object's .opd
>> > +  // section at DST_OFF.
>> > +  void
>> > +  add_reference(Object* src_obj,
>> > +               unsigned int src_indx,
>> > +               typename elfcpp::Elf_types<size>::Elf_Addr dst_off)
>> > +  {
>> > +    // FIXME: Thread safety?  Can multiple threads attempt to update
>> > +    // access_from_map_?
>> > +    Section_id src_id(src_obj, src_indx);
>> > +    typename Access_from::iterator p = this->access_from_map_.find(dst_off);
>> > +    if (p == this->access_from_map_.end())
>> > +      this->access_from_map_[dst_off].insert(src_id);
>> > +    else
>> > +      p->second.insert(src_id);
>> > +  }
>>
>> Seems like this is always
>> this->access_from_map_[dst_off].insert(src_id).  I'm not sure why you
>> need the find.
>
> This might just be me showing my ignorance, but we can have multiple
> src_id references to a given dst_off.  If the find is unnecessary,
> why the find in gc.h:Garbage_collection::add_reference?

I might be missing something, but it seems to me that the insert
should handle having multiple src_id's for a dst_off.

I have no idea why gc.h:Garbage_collection::add_reference uses find, I
guess I missed that in the patch review.

Ian



More information about the Binutils mailing list