[PATCH][GOLD] Use offsets within output sections during a relocatable link.

Doug Kwan (關振德) dougkwan@google.com
Wed May 26 18:11:00 GMT 2010


I used uint64_t because START and Output_section::address() are of
type uint64_t.  I can certainly change that to Address.

-Doug

在 2010年5月27日上午1:32,Ian Lance Taylor <iant@google.com> 寫道:
> "Doug Kwan (關振德)" <dougkwan@google.com> writes:
>
>> 2010-05-27  Doug Kwan  <dougkwan@google.com>
>>
>>         * object.cc (Sized_relobj::do_finalize_local_symbols): Use offset
>>         from start of output section instead of address for a local symbol
>>         in a merged or relaxed section when doing a relocatable link.
>
> Thanks for finding this.
>
>
>> --- gold/object.cc    26 May 2010 15:47:39 -0000      1.123
>> +++ gold/object.cc    26 May 2010 15:57:55 -0000
>> @@ -1827,7 +1827,12 @@ Sized_relobj<size, big_endian>::do_final
>>                 const Output_section_data* posd =
>>                   os->find_relaxed_input_section(this, shndx);
>>                 if (posd != NULL)
>> -                 lv.set_output_value(posd->address());
>> +                 {
>> +                   uint64_t relocatable_link_adjustment =
>> +                     relocatable ? os->address() : 0;
>> +                   lv.set_output_value(posd->address()
>> +                                       - relocatable_link_adjustment);
>> +                 }
>
> This is a template function.  The variable relocation_link_adjustment
> should have type Address (a typedef in Sized_relobj), not uint64_t.
>
>
>> @@ -1835,9 +1840,14 @@ Sized_relobj<size, big_endian>::do_final
>>               {
>>                 // We have to consider the addend to determine the
>>                 // value to use in a relocation.  START is the start
>> -               // of this input section.
>> +               // of this input section.  If we are doing a relocatable
>> +               // link, use offset from start output section instead of
>> +               // address.
>> +               uint64_t adjusted_start =
>> +                 relocatable ? start - os->address() : start;
>>                 Merged_symbol_value<size>* msv =
>> -                 new Merged_symbol_value<size>(lv.input_value(), start);
>> +                 new Merged_symbol_value<size>(lv.input_value(),
>> +                                               adjusted_start);
>>                 lv.set_merged_symbol_value(msv);
>>               }
>>           }
>
> Here too, for the variable adjusted_start.
>
> This is OK with those changes.
>
> Thanks.
>
> Ian
>



More information about the Binutils mailing list