public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Initial MIPS patch for GOLD - version 3
@ 2012-01-24 15:39 Aleksandar Simeonov
  2012-01-28  1:06 ` Ian Lance Taylor
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Aleksandar Simeonov @ 2012-01-24 15:39 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Fuhler, Rich, mips-compiler, binutils

[-- Attachment #1: Type: text/plain, Size: 4557 bytes --]

Hi Ian,
Please find patch for MIPS version of Gold. It still contains just
initial version of code for MIPS, but this time I added all changes that
are done in common code. Since those changes have effects on all
architectures I would like to ask you to check if you approve them, and
if not, to give some suggestions how to change them.

List of changes in common code:
* parameters.cc (Parameters::entry) : Default entry symbol for MIPS is
"__start".
- Unlike other architectures, default entry symbol for MIPS is "__start",
not "_start".

* output.cc (Output_file_header::entry) : Start address is not defaulting
to zero but rather to starting address of .text section (if exists).
* target.h (Target::text_section_address) : New function.
- If there are no start symbol or start address is not set from command
line, MIPS linker has to set start of .text section, not 0 (if section
exists).

* output.h (Output_data_reloc::add_absolute_null) : New function. Needed
for generation of R_MIPS_NONE relocation.
* output.cc (Output_reloc::compare) :  R_MIPS_NONE relocation have to be
first.
- First dynamic relocation in MIPS executable or shared object has to be
null relocation (absolute R_MIPS_NONE type to address 0). Function for
creating that entry is added and there were changes in function for
sorting dynamic relocations in order to have this relocation first.

* symtab.h (Symbol::set_nonvis) : New function. Set the non-visibility
part of the st_other field.
- Needed to set STO_MIPS_PLT flag that represents undefined functions (in
file) that are PLT entries.

* layout.cc (Layout::finalize) : Added additional fixing of section data
after all necessary information are known (for MIPS data about dynamic
symbol table are needed).
* target.h (Target::fix_sections) : New function.
* target.h (Target::do_fix_sections) : New function.
- If there are more then 65536 entries in dynamic symbol table entries in
.MIPS.stubs section have size of 5 32-bit words (4 32-bits words is size
when there are less or equal then 65536 entries). Since this value is only
known at the end of Layout::finalize function, additional fixing of data
is needed at the end of that function.

* symtab.cc (got_offset_compare) : New function.
* symtab.cc (Symbol_table::set_dynsym_indexes) : Order of symbols in
dynamic symbol table changed. New order is local symbols, global symbols
without got entry, global symbols with got entry.
- MIPS has strict order of entries in dynamic symbol table. First come
local symbols, then global symbols that has no entry in got, then global
symbols that has got entry.

* symtab.h (Symbol_table::global_got_index_): New data member.
* symtab.h (Symbol_table::global_got_index): New function.
- First entry in dynamic symbol table that has got entry. Needed for
.dynamic section tag (DT_MIPS_GOTSYM).

* utils.h: New file that contains utilities for manipulating integers of
up to 32-bits.
* arm.cc (namespace utils): Removed common code to separate file (utils.h).
* arm.cc (utils::sign_extend): Removed.
* arm.cc (utils::has_overflow): Likewise.
* arm.cc (utils::has_signed_unsigned_overflow): Likewise.
* arm.cc (utils::bit_select): Likewise.
- Functions that are common for MIPS and ARM architectures moved to
separate file to avoid duplication of code.

* output.cc (Output_data_dynamic::Dynamic_entry::write): Added code for
target specific dynamic tags.
* output.h (Output_data_dynamic::add_target_specific): Added function for
adding target specific dynamic tag.
* output.h (Output_data_dynamic::add_target_specific): New method.
* output.h (Output_data_dynamic::Dynamic_entry): Add support for target
specific dynamic table entries.
* output.h (DYNAMIC_TARGET): New enum for target specific dynamic tags.
- MIPS has several dynamic tags that are mandatory. This code is added to
support them.

* layout.cc (Layout::segment_precedes): Fixed order of MIPS specific
segments.
- MIPS needs to have PT_MIPS_REGINFO segment before any loadable segment.
- MIPS needs to have PT_NULL segment to be last in list of segments.

* layout.h (Layout::segment_list): Returns segment list.
* layout.h (Layout::segment_list): New function.
- MIPS dynamic tag DT_MIPS_BASE_ADDRESS needs virtual address of first
loadable segment.

* reloc.cc (Sized_relobj_file<size, big_endian>::write_sections): Special
handling of MIPS .reginfo section.
- .reginfo section is generated by linker and needs special handling.

Rest of the changes are or in mips specific part or in make and configure
files (new target is added).

Best regards,
Aleksandar


[-- Attachment #2: mips_gold.tar.gz --]
[-- Type: application/gzip, Size: 30252 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: Initial MIPS patch for GOLD - version 3
@ 2012-02-03 15:40 Simeonov, Aleksandar (c)
  2012-03-07 14:26 ` Simeonov, Aleksandar (c)
  0 siblings, 1 reply; 10+ messages in thread
From: Simeonov, Aleksandar (c) @ 2012-02-03 15:40 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Fuhler, Rich, mips-compiler, binutils

Hi Ian,
I agree with you that processor specific stuff should be in CPU.cc. Because of that I would like to suggest following:

- reloc.cc (Sized_relobj_file<size, big_endian>::write_sections)

Instead of having direct compare of section types in code:
// For MIPS .reginfo section there is no need to do anything
if (shdr.get_sh_type() == elfcpp::SHT_MIPS_REGINFO)
  continue;

To have something like:
// Sections that need special handling (target specific)
if(parameters->target().section_needs_spec_handling(shdr.get_sh_type()))
 continue;

Where section_needs_spec_handling should be defined in Target as a virtual function that returns false by default and can be implemented as needed.


- layout.cc (Layout::segment_precedes)

Instead of having function segment_precedes in Layout class, to move it to Target class. Make virtual default implementation as it was originally and allow different architectures to make their own implementation.

Maybe some other proposals?

Greetings,
Aleksandar 

On 28/01/2012 02:54, Ian Lance Taylor wrote:
> Aleksandar Simeonov <Aleksandar.Simeonov@RT-RK.com> writes:
> 
>> * reloc.cc (Sized_relobj_file<size, big_endian>::write_sections): Special
>> handling of MIPS .reginfo section.
>> - .reginfo section is generated by linker and needs special handling.
> 
> I haven't thought about everything, but I can see that this patch is not
> going to work as is.  It will fail when linking a non-MIPS object which
> happens to have a section type == SHT_MIPS_REGINFO.  We can't use
> processor-specific values like SHT_MIPS_REGINFO outside of the CPU.cc
> file.
> 
>> * layout.cc (Layout::segment_precedes): Fixed order of MIPS specific
>> segments.
>> - MIPS needs to have PT_MIPS_REGINFO segment before any loadable segment.
> 
> This is similarly troubling, though probably less serious.
> 
>> - MIPS needs to have PT_NULL segment to be last in list of segments.
> 
> Why would we ever have a PT_NULL segment?
> 
> Ian
> 

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

end of thread, other threads:[~2012-03-07 19:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 15:39 Initial MIPS patch for GOLD - version 3 Aleksandar Simeonov
2012-01-28  1:06 ` Ian Lance Taylor
2012-01-28  1:48 ` Ian Lance Taylor
2012-01-28  1:55 ` Ian Lance Taylor
2012-01-28  2:11   ` John Reiser
2012-01-29 12:13     ` Richard Sandiford
2012-02-03 15:40 Simeonov, Aleksandar (c)
2012-03-07 14:26 ` Simeonov, Aleksandar (c)
2012-03-07 14:54   ` Ian Lance Taylor
2012-03-07 19:46     ` Fuhler, Rich

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).