This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: Mips target in gold - part 3
- From: Sasa Stankovic <Sasa dot Stankovic at imgtec dot com>
- To: Cary Coutant <ccoutant at google dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>, "iant at google dot com" <iant at google dot com>, Petar Jovanovic <Petar dot Jovanovic at imgtec dot com>
- Date: Fri, 2 Aug 2013 17:11:04 +0000
- Subject: RE: Mips target in gold - part 3
- References: <7EDC79CE48A9944A88968ABABE6038EE22803419 at BADAG02 dot ba dot imgtec dot org>,<CAHACq4p0NPEV9H9dgLsNW1F28R1eHjPwhj3TZz0Y_P0j8sfqfQ at mail dot gmail dot com>
Hi Cary,
Updated patches are attached. I left the method set_nonvis as public because it is used in three places in the file mips.cc, but only one is from the derived class Mips_symbol - the other two are from the class Target_mips. I also attached the patch mips3.patch which is the update on 2 mips patches (this patch also contains the previous config.patch).
Regards,
Sasa
________________________________________
From: Cary Coutant [ccoutant@google.com]
Sent: Tuesday, July 30, 2013 11:38 PM
To: Sasa Stankovic
Cc: binutils@sourceware.org; iant@google.com; Petar Jovanovic
Subject: Re: Mips target in gold - part 3
Thanks for organizing this patch series so nicely! A couple of general comments:
- all patches need ChangeLog entries. (See
http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs.)
- don't include generated files like Makefile.in in the diff (just say
"Regenerated" in the ChangeLog entry).
I'm still working on the big two-part mips.cc patch, but I've got
comments on the others for you. First...
> 1. start.patch
> This patch allows a target to define start symbol. Mips start symbol is "__start" instead of "_start".
I decided to do this differently. Rather than add a virtual function
to return the entry symbol, I added the symbol name to struct
Target_info, and added "_start" as the entry_symbol_name in the
Target_info initializers for each target. I've committed the attached
patch. You'll need to adjust mips.cc similarly.
-cary
2013-07-23 Cary Coutant <ccoutant@google.com>
Sasa Stankovic <Sasa.Stankovic@imgtec.com>
* parameters.cc (Parameters::entry): Return target-specific entry
symbol name.
* target.h (Target::entry_symbol_name): New function.
(Target_info::entry_symbol_name): New data member.
* arm.cc (Target_arm::arm_info): Add entry_symbol_name.
* i386.cc (Target_i386::i386_info): Likewise.
(Target_i386_nacl::i386_nacl_info): Likewise.
* sparc.cc (Target_sparc::sparc_info): Likewise.
* tilegx.cc (Target_tilegx::tilegx_info): Likewise.
* x86_64.cc: (Target_x86_64::x86_64_info) Likewise.
(Target_x86_64_nacl::x86_64_nacl_info) Likewise.
* testsuite/testfile.cc (Target_test::test_target_info): Likewise.
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 1bbeda4..2ba098b 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+
+ * symtab.cc (Symbol_table::set_dynsym_indexes): Allow a target to set
+ dynsym indexes.
+ * target.h (Target::has_custom_set_dynsym_indexes): New function.
+ (Target::set_dynsym_indexes): New function.
+
2013-07-31 Cary Coutant <ccoutant@google.com>
* object.cc (Sized_relobj::do_output_section_address): New function.
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 2e17529..e9a224b 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -2369,6 +2369,25 @@ Symbol_table::set_dynsym_indexes(unsigned int index,
Versions* versions)
{
std::vector<Symbol*> as_needed_sym;
+ std::vector<Symbol*> dyn_symbols;
+
+ // Allow a target to set dynsym indexes.
+ if (parameters->target().has_custom_set_dynsym_indexes())
+ {
+ for (Symbol_table_type::iterator p = this->table_.begin();
+ p != this->table_.end();
+ ++p)
+ {
+ Symbol* sym = p->second;
+ if (!sym->should_add_dynsym_entry(this))
+ sym->set_dynsym_index(-1U);
+ else
+ dyn_symbols.push_back(sym);
+ }
+
+ return parameters->target().set_dynsym_indexes(&dyn_symbols, index, syms,
+ dynpool, versions, this);
+ }
for (Symbol_table_type::iterator p = this->table_.begin();
p != this->table_.end();
diff --git a/gold/target.h b/gold/target.h
index 4c58d10..a8bf28f 100644
--- a/gold/target.h
+++ b/gold/target.h
@@ -37,6 +37,7 @@
#include "elfcpp.h"
#include "options.h"
#include "parameters.h"
+#include "stringpool.h"
#include "debug.h"
namespace gold
@@ -62,6 +63,7 @@ class Output_section;
class Input_objects;
class Task;
struct Symbol_location;
+class Versions;
// The abstract class for target specific handling.
@@ -454,6 +456,17 @@ class Target
entry_symbol_name() const
{ return this->pti_->entry_symbol_name; }
+ // Whether the target has a custom set_dynsym_indexes method.
+ virtual bool
+ has_custom_set_dynsym_indexes() const
+ { return false; }
+
+ // Custom set_dynsym_indexes method for a target.
+ virtual unsigned int
+ set_dynsym_indexes(std::vector<Symbol*>*, unsigned int, std::vector<Symbol*>*,
+ Stringpool*, Versions*, Symbol_table*) const
+ { gold_unreachable(); }
+
protected:
// This struct holds the constant information for a child class. We
// use a struct to avoid the overhead of virtual function calls for
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 2ba098b..3a12ab5 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,9 @@
2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+ * symtab.h (Symbol::set_nonvis): New function.
+
+2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+
* symtab.cc (Symbol_table::set_dynsym_indexes): Allow a target to set
dynsym indexes.
* target.h (Target::has_custom_set_dynsym_indexes): New function.
diff --git a/gold/symtab.h b/gold/symtab.h
index 9299ea8..3b550b4 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -259,6 +259,11 @@ class Symbol
nonvis() const
{ return this->nonvis_; }
+ // Set the non-visibility part of the st_other field.
+ void
+ set_nonvis(unsigned int nonvis)
+ { this->nonvis_ = nonvis; }
+
// Return whether this symbol is a forwarder. This will never be
// true of a symbol found in the hash table, but may be true of
// symbol pointers attached to object files.
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 3a12ab5..b43ae82 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,15 @@
2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+ * output.cc (Output_data_dynamic::Dynamic_entry::write):
+ Get the value of DYNAMIC_CUSTOM dynamic entry.
+ * output.h (Output_data_dynamic::add_custom): New function.
+ (Dynamic_entry::Dynamic_entry): New constructor for DYNAMIC_CUSTOM
+ dynamic entry.
+ (enum Dynamic_entry::Classification): Add DYNAMIC_CUSTOM.
+ * target.h (Target::dynamic_tag_custom_value): New function.
+
+2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+
* symtab.h (Symbol::set_nonvis): New function.
2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
diff --git a/gold/output.cc b/gold/output.cc
index 583c020..8a1ea12 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -1797,6 +1797,10 @@ Output_data_dynamic::Dynamic_entry::write(
val = pool->get_offset(this->u_.str);
break;
+ case DYNAMIC_CUSTOM:
+ val = parameters->target().dynamic_tag_custom_value(this->tag_);
+ break;
+
default:
val = this->u_.od->address() + this->offset_;
break;
diff --git a/gold/output.h b/gold/output.h
index 1bcdfea..a9dc6f0 100644
--- a/gold/output.h
+++ b/gold/output.h
@@ -2574,6 +2574,11 @@ class Output_data_dynamic : public Output_section_data
add_string(elfcpp::DT tag, const std::string& str)
{ this->add_string(tag, str.c_str()); }
+ // Add a new dynamic entry with custom value.
+ void
+ add_custom(elfcpp::DT tag)
+ { this->add_entry(Dynamic_entry(tag)); }
+
protected:
// Adjust the output section to set the entry size.
void
@@ -2638,6 +2643,11 @@ class Output_data_dynamic : public Output_section_data
: tag_(tag), offset_(DYNAMIC_STRING)
{ this->u_.str = str; }
+ // Create an entry with a custom value.
+ Dynamic_entry(elfcpp::DT tag)
+ : tag_(tag), offset_(DYNAMIC_CUSTOM)
+ { }
+
// Return the tag of this entry.
elfcpp::DT
tag() const
@@ -2661,7 +2671,9 @@ class Output_data_dynamic : public Output_section_data
// Symbol adress.
DYNAMIC_SYMBOL = -3U,
// String.
- DYNAMIC_STRING = -4U
+ DYNAMIC_STRING = -4U,
+ // Custom value.
+ DYNAMIC_CUSTOM = -5U
// Any other value indicates a section address plus OFFSET.
};
diff --git a/gold/target.h b/gold/target.h
index a8bf28f..529b105 100644
--- a/gold/target.h
+++ b/gold/target.h
@@ -467,6 +467,11 @@ class Target
Stringpool*, Versions*, Symbol_table*) const
{ gold_unreachable(); }
+ // Get the custom dynamic tag value.
+ virtual unsigned int
+ dynamic_tag_custom_value(elfcpp::DT) const
+ { gold_unreachable(); }
+
protected:
// This struct holds the constant information for a child class. We
// use a struct to avoid the overhead of virtual function calls for
diff --git a/gold/ChangeLog b/gold/ChangeLog
index b43ae82..7426ca2 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,11 @@
2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+ * symtab.cc (Sized_symbol<32>::init_output_data):
+ Instantiate the template.
+ (Sized_symbol<64>::init_output_data): Likewise.
+
+2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+
* output.cc (Output_data_dynamic::Dynamic_entry::write):
Get the value of DYNAMIC_CUSTOM dynamic entry.
* output.h (Output_data_dynamic::add_custom): New function.
diff --git a/gold/symtab.cc b/gold/symtab.cc
index e9a224b..b6c9f34 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -3641,6 +3641,32 @@ Symbol_table::define_with_copy_reloc<64>(
elfcpp::Elf_types<64>::Elf_Addr value);
#endif
+#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
+template
+void
+Sized_symbol<32>::init_output_data(const char* name, const char* version,
+ Output_data* od, Value_type value,
+ Size_type symsize, elfcpp::STT type,
+ elfcpp::STB binding,
+ elfcpp::STV visibility,
+ unsigned char nonvis,
+ bool offset_is_from_end,
+ bool is_predefined);
+#endif
+
+#if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
+template
+void
+Sized_symbol<64>::init_output_data(const char* name, const char* version,
+ Output_data* od, Value_type value,
+ Size_type symsize, elfcpp::STT type,
+ elfcpp::STB binding,
+ elfcpp::STV visibility,
+ unsigned char nonvis,
+ bool offset_is_from_end,
+ bool is_predefined);
+#endif
+
#ifdef HAVE_TARGET_32_LITTLE
template
void
diff --git a/elfcpp/ChangeLog b/elfcpp/ChangeLog
index 41897fb..e3954cb 100644
--- a/elfcpp/ChangeLog
+++ b/elfcpp/ChangeLog
@@ -1,3 +1,25 @@
+2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+
+ * mips.h (R _MIPS16_TLS_GD, R_MIPS16_TLS_LDM, R_MIPS16_TLS_DTPREL_HI16,
+ R_MIPS16_TLS_DTPREL_LO16, R_MIPS16_TLS_GOTTPREL,
+ R_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_LO16, R_MICROMIPS_26_S1,
+ R_MICROMIPS_HI16, R_MICROMIPS_LO16, R_MICROMIPS_GPREL16,
+ R_MICROMIPS_LITERAL, R_MICROMIPS_GOT16, R_MICROMIPS_PC7_S1,
+ R_MICROMIPS_PC10_S1, R_MICROMIPS_PC16_S1, R_MICROMIPS_CALL16,
+ R_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_OFST,
+ R_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_LO16, R_MICROMIPS_SUB,
+ R_MICROMIPS_HIGHER, R_MICROMIPS_HIGHEST, R_MICROMIPS_CALL_HI16,
+ R_MICROMIPS_CALL_LO16, R_MICROMIPS_SCN_DISP, R_MICROMIPS_JALR,
+ R_MICROMIPS_HI0_LO16, R_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_LDM,
+ R_MICROMIPS_TLS_DTPREL_HI16, R_MICROMIPS_TLS_DTPREL_LO16,
+ R_MICROMIPS_TLS_GOTTPREL, R_MICROMIPS_TLS_TPREL_HI16,
+ R_MICROMIPS_TLS_TPREL_LO16, R_MICROMIPS_GPREL7_S2,
+ R_MICROMIPS_PC23_S20): New enums for relocations (mips16 and micromips).
+ (elf_st_is_mips16): New function.
+ (elf_st_is_micromips): New function.
+ (abi_n32): New function.
+ (abi_n64): New function.
+
2013-03-01 Cary Coutant <ccoutant@google.com>
* dwarf.h (enum DW_LANG): Adjust spacing for consistency.
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 7426ca2..7804391 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,15 @@
2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+ * mips.cc: New file.
+ * Makefile.am (TARGETSOURCES): Add mips.cc
+ (ALL_TARGETOBJS): Add mips.$(OBJEXT)
+ * configure.tgt: Add entries for mips*.
+ * configure.ac: Likewise.
+ * Makefile.in: Regenerate.
+ * configure: Likewise.
+
+2013-08-02 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+
* symtab.cc (Sized_symbol<32>::init_output_data):
Instantiate the template.
(Sized_symbol<64>::init_output_data): Likewise.
diff --git a/gold/Makefile.am b/gold/Makefile.am
index 8e2fff1..12699d0 100644
--- a/gold/Makefile.am
+++ b/gold/Makefile.am
@@ -164,11 +164,12 @@ DEFFILES = arm-reloc.def
EXTRA_DIST = yyscript.c yyscript.h
TARGETSOURCES = \
- i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc
+ i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \
+ mips.cc
ALL_TARGETOBJS = \
i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \
- arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT)
+ arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) mips.$(OBJEXT)
libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
libgold_a_LIBADD = $(LIBOBJS)
diff --git a/gold/configure.ac b/gold/configure.ac
index e3e10b3..02af2de 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -206,6 +206,7 @@ for targ in $target $canon_targets; do
AM_CONDITIONAL(DEFAULT_TARGET_SPARC, test "$targ_obj" = "sparc")
AM_CONDITIONAL(DEFAULT_TARGET_X86_64, test "$targ_obj" = "x86_64")
AM_CONDITIONAL(DEFAULT_TARGET_TILEGX, test "$targ_obj" = "tilegx")
+ AM_CONDITIONAL(DEFAULT_TARGET_MIPS, test "$targ_obj" = "mips")
DEFAULT_TARGET=${targ_obj}
AC_SUBST(DEFAULT_TARGET)
fi
diff --git a/gold/configure.tgt b/gold/configure.tgt
index d61647e..8b816fc 100644
--- a/gold/configure.tgt
+++ b/gold/configure.tgt
@@ -144,6 +144,20 @@ arm*-*-*)
targ_big_endian=false
targ_extra_big_endian=true
;;
+mips*-*-*)
+ targ_obj=mips
+ targ_machine=EM_MIPS
+ targ_size=32
+ targ_big_endian=true
+ targ_extra_big_endian=false
+ ;;
+mips*el*-*-*|mips*le*-*-*)
+ targ_obj=mips
+ targ_machine=EM_MIPS_RS3_LE
+ targ_size=32
+ targ_big_endian=false
+ targ_extra_big_endian=true
+ ;;
*)
targ_obj=UNKNOWN
;;
diff --git a/gold/mips.cc b/gold/mips.cc
index c558457..950717d 100644
--- a/gold/mips.cc
+++ b/gold/mips.cc
@@ -2730,7 +2730,7 @@ class Target_mips : public Sized_target<size, big_endian>
}
bool
- custom_set_dynsym_indexes() const
+ has_custom_set_dynsym_indexes() const
{ return true; }
void
@@ -9330,7 +9330,8 @@ Target::Target_info Target_mips<size, big_endian>::mips_info =
0, // small_common_section_flags
0, // large_common_section_flags
NULL, // attributes_section
- NULL // attributes_vendor
+ NULL, // attributes_vendor
+ "__start" // entry_symbol_name
};
// The selector for mips object files.