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] Make string offset assignment independent of implementation of unordered map elements order.


The assert "offset_ == 0" triggered because offset_ was initialized to
be sizeof(Stringpool_char) is zero_null_ is true.  I changed that to
gold_assert(key_to_offset_.size() == 0).  I also changed the setting
of the first offset so that it is computed correctly even though
zero_null_ may be set to false.

Here is the committed patch.



-Doug

2010/3/15 Ian Lance Taylor <iant@google.com>:
> "Doug Kwan (Ãö®¶¼w)" <dougkwan@google.com> writes:
>
>> We may get incorrect offset if
>> Stringpool_template::set_no_zero_null is set after the first offset is
>> assigned.  Currently set_no_zero_null is only used by merged string
>> section and is called before any strings are inserted.   So it should
>> be okay.
>
> Please add "gold_assert(this->offset_ == 0);" to set_no_zero_null.
>
>> +template<typename Stringpool_char>
>> +void
>> +Stringpool_template<Stringpool_char>::new_key_offset(const Stringpool_char* s,
>> +                                                  size_t length)
>> +{
>> +  section_offset_type offset;
>> +  if (this->zero_null_ && s[0] == 0)
>> +    offset = 0;
>
> You can test length == 0 rather than s[0] == 0.
>
>
> This is OK with those changes.
>
> Thanks.
>
> Ian
>

Attachment: patch-stringpool-final.txt
Description: Text document


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