Initial MIPS patch for GOLD - version 3

Aleksandar Simeonov Aleksandar.Simeonov@RT-RK.com
Tue Jan 24 15:39:00 GMT 2012


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mips_gold.tar.gz
Type: application/gzip
Size: 30252 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20120124/13a9ee06/attachment.gz>


More information about the Binutils mailing list