public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Gold linker - help with .reginfo section for mips
       [not found] ` <mcrpqo9klaw.fsf@google.com>
@ 2011-05-11 15:10   ` Aleksandar Simeonov
  2011-05-11 15:23     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Aleksandar Simeonov @ 2011-05-11 15:10 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: rich, binutils

Hi again Ian,
After few tries and errors I decided to write you again. I still have
problems with .reginfo section. I managed to find all data I need, but I
still have problems to set them in output section. I did create new
type, but still have problems to set correct output data (as well as
correct size). Any idea how to set output data and size in
Output_section class would be great since I'm stuck with this for a week
already.

Thanks in advance for your answer.

Aleksandar

P. S.
I added your previous answer to this mail since I send this to mailing
list, too.

On 26/04/2011 18:51, Ian Lance Taylor wrote:

>> 3. MIPS has .reginfo section. It contains list of registers that are
>> used in current file as well as value of _gp. It is always 24 bytes long
>> (4 bytes for general purpose registers, 16 bytes for coprocessors'
>> registers and 4 bytes for global pointer value). Currently, Gold just
>> concatenates .reginfo sections from all input files. What has to be done
>> is following: first 20 bytes of every section is combined using OR
>> operation, and last 4 bytes just get value of _gp. I'm trying to make
>> that some how, but I have problems to find data I need (I have idea
>> where to find input data, but still I haven't managed to get access to
>> it). Also, I'm not sure if I implement that on correct place (in
>> Target_mips<size, big_endian>::do_finalize_sections function)?
> 
> I think the right way to handle this is for the MIPS target to override
> the default do_make_output_section method.  For a SHT_MIPS_REGINFO
> section it should return a new kind of output section, as the ARM target
> does.  That new class should do the right thing in the various virtual
> functions such as set_final_data_size() and write().
> 
> Ian
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Gold linker - help with .reginfo section for mips
  2011-05-11 15:10   ` Gold linker - help with .reginfo section for mips Aleksandar Simeonov
@ 2011-05-11 15:23     ` Ian Lance Taylor
  2011-05-11 16:02       ` Aleksandar Simeonov
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2011-05-11 15:23 UTC (permalink / raw)
  To: Aleksandar Simeonov; +Cc: rich, binutils

Aleksandar Simeonov <Aleksandar.Simeonov@RT-RK.com> writes:

> After few tries and errors I decided to write you again. I still have
> problems with .reginfo section. I managed to find all data I need, but I
> still have problems to set them in output section. I did create new
> type, but still have problems to set correct output data (as well as
> correct size). Any idea how to set output data and size in
> Output_section class would be great since I'm stuck with this for a week
> already.

It's a little hard to answer a general question like that.

The way for an Output_section class to set the size is to provide its
own implementation of the set_final_data_size method.  It should call
set_data_size with the final size.  For .reginfo the size is a constant,
so this is easy.

The way to write out the data is to provide its own implementation of
the do_write method.  It should write out the data.

Hope that helps.

Ian

> On 26/04/2011 18:51, Ian Lance Taylor wrote:
>
>>> 3. MIPS has .reginfo section. It contains list of registers that are
>>> used in current file as well as value of _gp. It is always 24 bytes long
>>> (4 bytes for general purpose registers, 16 bytes for coprocessors'
>>> registers and 4 bytes for global pointer value). Currently, Gold just
>>> concatenates .reginfo sections from all input files. What has to be done
>>> is following: first 20 bytes of every section is combined using OR
>>> operation, and last 4 bytes just get value of _gp. I'm trying to make
>>> that some how, but I have problems to find data I need (I have idea
>>> where to find input data, but still I haven't managed to get access to
>>> it). Also, I'm not sure if I implement that on correct place (in
>>> Target_mips<size, big_endian>::do_finalize_sections function)?
>> 
>> I think the right way to handle this is for the MIPS target to override
>> the default do_make_output_section method.  For a SHT_MIPS_REGINFO
>> section it should return a new kind of output section, as the ARM target
>> does.  That new class should do the right thing in the various virtual
>> functions such as set_final_data_size() and write().
>> 
>> Ian
>> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Gold linker - help with .reginfo section for mips
  2011-05-11 15:23     ` Ian Lance Taylor
@ 2011-05-11 16:02       ` Aleksandar Simeonov
  2011-05-11 17:32         ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Aleksandar Simeonov @ 2011-05-11 16:02 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

Here is code I added for set_final_data_size:
template <int size, bool big_endian>
void Mips_output_section <size, big_endian>::set_final_data_size()
{
  if (this->type () == elfcpp::SHT_MIPS_REGINFO)
    {
      this->set_data_size(24);
    }
  else
    Output_section::set_final_data_size();
}

But now I have error as follows:
./mips-linux-gnu-ld.gold: internal error in write_sections, at reloc.cc:816

I guess something is missing?

Aleksandar
On 11/05/2011 17:22, Ian Lance Taylor wrote:
> Aleksandar Simeonov <Aleksandar.Simeonov@RT-RK.com> writes:
> 
>> After few tries and errors I decided to write you again. I still have
>> problems with .reginfo section. I managed to find all data I need, but I
>> still have problems to set them in output section. I did create new
>> type, but still have problems to set correct output data (as well as
>> correct size). Any idea how to set output data and size in
>> Output_section class would be great since I'm stuck with this for a week
>> already.
> 
> It's a little hard to answer a general question like that.
> 
> The way for an Output_section class to set the size is to provide its
> own implementation of the set_final_data_size method.  It should call
> set_data_size with the final size.  For .reginfo the size is a constant,
> so this is easy.
> 
> The way to write out the data is to provide its own implementation of
> the do_write method.  It should write out the data.
> 
> Hope that helps.
> 
> Ian
> 
>> On 26/04/2011 18:51, Ian Lance Taylor wrote:
>>
>>>> 3. MIPS has .reginfo section. It contains list of registers that are
>>>> used in current file as well as value of _gp. It is always 24 bytes long
>>>> (4 bytes for general purpose registers, 16 bytes for coprocessors'
>>>> registers and 4 bytes for global pointer value). Currently, Gold just
>>>> concatenates .reginfo sections from all input files. What has to be done
>>>> is following: first 20 bytes of every section is combined using OR
>>>> operation, and last 4 bytes just get value of _gp. I'm trying to make
>>>> that some how, but I have problems to find data I need (I have idea
>>>> where to find input data, but still I haven't managed to get access to
>>>> it). Also, I'm not sure if I implement that on correct place (in
>>>> Target_mips<size, big_endian>::do_finalize_sections function)?
>>>
>>> I think the right way to handle this is for the MIPS target to override
>>> the default do_make_output_section method.  For a SHT_MIPS_REGINFO
>>> section it should return a new kind of output section, as the ARM target
>>> does.  That new class should do the right thing in the various virtual
>>> functions such as set_final_data_size() and write().
>>>
>>> Ian
>>>
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Gold linker - help with .reginfo section for mips
  2011-05-11 16:02       ` Aleksandar Simeonov
@ 2011-05-11 17:32         ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2011-05-11 17:32 UTC (permalink / raw)
  To: Aleksandar Simeonov; +Cc: binutils

Aleksandar Simeonov <Aleksandar.Simeonov@RT-RK.com> writes:

> Here is code I added for set_final_data_size:
> template <int size, bool big_endian>
> void Mips_output_section <size, big_endian>::set_final_data_size()
> {
>   if (this->type () == elfcpp::SHT_MIPS_REGINFO)
>     {
>       this->set_data_size(24);
>     }
>   else
>     Output_section::set_final_data_size();
> }

If you only need special treatment for SHT_MIPS_REGINFO, then I would
recommend only creating a Mips_output_section for SHT_MIPS_REGINFO.  It
should probably be named Mips_reginfo_section or something like that.
For other section types just return a regular Output_section, probably
by simply calling this->Target::do_make_output_section.

> But now I have error as follows:
> ./mips-linux-gnu-ld.gold: internal error in write_sections, at reloc.cc:816

You can't override set_final_data_size without also overriding do_write.
Look at, e.g., Output_compress_section for an example of an
Output_section which is not the simple concatenation of input sections.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-11 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4DB6F193.5090302@RT-RK.com>
     [not found] ` <mcrpqo9klaw.fsf@google.com>
2011-05-11 15:10   ` Gold linker - help with .reginfo section for mips Aleksandar Simeonov
2011-05-11 15:23     ` Ian Lance Taylor
2011-05-11 16:02       ` Aleksandar Simeonov
2011-05-11 17:32         ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).