This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Mips target in gold - revision 2 - part 1
- From: Sasa Stankovic <Sasa dot Stankovic at imgtec dot com>
- To: "Cary Coutant [ccoutant at google dot com]" <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: Thu, 30 Jan 2014 14:16:26 +0000
- Subject: Mips target in gold - revision 2 - part 1
- Authentication-results: sourceware.org; auth=none
Hi Cary,
Attached is the first part of the patch that implements Mips target in gold. This part contains one new patch that changes target independent code. adjust_dynsym.patch allows a target to adjust the value written to the dynamic symbol table. This is needed because Mips dynamic linker expects MIPS16 and microMIPS symbols to have odd values created by adding +1 to the dynamic symbol value.
> You shouldn't need to include "stringpool.h". The set_dynsym_indexes
> function takes a Stringpool*, so you only need a forward declaration
> for class Stringpool.
Stringpool is defined as a template in file stringpool.h. If I remove "stringpool.h" then following needs to be added to file target.h:
template<typename Stringpool_char>
class Stringpool_template;
typedef Stringpool_template<char> Stringpool;
Regards,
Sasa
diff --git a/gold/ChangeLog b/gold/ChangeLog
index d2c975e..6eb1194 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2014-01-30 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.
+
2014-01-28 Cary Coutant <ccoutant@google.com>
Add .gdb_index version 7 support.
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 2e17529..7721ada 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -2370,6 +2370,25 @@ Symbol_table::set_dynsym_indexes(unsigned int index,
{
std::vector<Symbol*> as_needed_sym;
+ // Allow a target to set dynsym indexes.
+ if (parameters->target().has_custom_set_dynsym_indexes())
+ {
+ std::vector<Symbol*> dyn_symbols;
+ 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();
++p)
diff --git a/gold/target.h b/gold/target.h
index 415b7ed..0a1b637 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 6eb1194..02adb24 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,9 @@
2014-01-30 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+ * symtab.h (Symbol::set_nonvis): New function.
+
+2014-01-30 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 1232c97..b55b50f 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 02adb24..c9b27ed 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,15 @@
2014-01-30 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.
+
+2014-01-30 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+
* symtab.h (Symbol::set_nonvis): New function.
2014-01-30 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
diff --git a/gold/output.cc b/gold/output.cc
index 348ad64..abe0629 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 574d270..1cba0b7 100644
--- a/gold/output.h
+++ b/gold/output.h
@@ -2578,6 +2578,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
@@ -2642,6 +2647,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
@@ -2665,7 +2675,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 0a1b637..18ef2c8 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 c9b27ed..0c7bf6d 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,11 @@
2014-01-30 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+ * symtab.cc (Sized_symbol<32>::init_output_data):
+ Instantiate the template.
+ (Sized_symbol<64>::init_output_data): Likewise.
+
+2014-01-30 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 7721ada..07212ac 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/gold/ChangeLog b/gold/ChangeLog
index 0c7bf6d..a978b8a 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,11 @@
2014-01-30 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+ * symtab.cc (Symbol_table::sized_write_globals): Allow a target to
+ adjust dynamic symbol value.
+ * target.h (Target::adjust_dyn_symbol): New function.
+
+2014-01-30 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/symtab.cc b/gold/symtab.cc
index 07212ac..3e7d1ae 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -3011,6 +3011,8 @@ Symbol_table::sized_write_globals(const Stringpool* sympool,
unsigned char* pd = dynamic_view + (dynsym_index * sym_size);
this->sized_write_symbol<size, big_endian>(sym, dynsym_value, shndx,
binding, dynpool, pd);
+ // Allow a target to adjust dynamic symbol value.
+ parameters->target().adjust_dyn_symbol(sym, pd);
}
}
diff --git a/gold/target.h b/gold/target.h
index 18ef2c8..796b938 100644
--- a/gold/target.h
+++ b/gold/target.h
@@ -472,6 +472,11 @@ class Target
dynamic_tag_custom_value(elfcpp::DT) const
{ gold_unreachable(); }
+ // Adjust the value written to the dynamic symbol table.
+ virtual void
+ adjust_dyn_symbol(const Symbol*, unsigned char*) const
+ { }
+
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/elfcpp/ChangeLog b/elfcpp/ChangeLog
index 2399da6..f5a2876 100644
--- a/elfcpp/ChangeLog
+++ b/elfcpp/ChangeLog
@@ -1,3 +1,32 @@
+2014-01-30 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, R_MIPS_EH): New enums for relocations (mips16 and
+ micromips).
+ (STO_MIPS_FLAGS): New enum constant.
+ (elf_st_is_mips16): New function.
+ (elf_st_is_micromips): New function.
+ (is_micromips): New function.
+ (abi_n32): New function.
+ (abi_n64): New function.
+ (ODK_NULL, ODK_REGINFO, ODK_EXCEPTIONS, ODK_PAD, ODK_HWPATCH, ODK_FILL,
+ ODK_TAGS, ODK_HWAND, ODK_HWOR, ODK_GP_GROUP, ODK_IDENT): New enum
+ constants.
+ * elfcpp.h (SHT_MIPS_OPTIONS): New enum constant.
+
2013-11-17 H.J. Lu <hongjiu.lu@intel.com>
* x86_64.h (R_X86_64_PC32_BND): New.
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index 067c775..f86558a 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -401,9 +401,11 @@ enum SHT
// x86_64 unwind information.
SHT_X86_64_UNWIND = 0x70000001,
- //MIPS-specific section types.
- // Register info section
+ // MIPS-specific section types.
+ // Section contains register usage information.
SHT_MIPS_REGINFO = 0x70000006,
+ // Section contains miscellaneous options.
+ SHT_MIPS_OPTIONS = 0x7000000d,
// Link editor is to sort the entries in this section based on the
// address specified in the associated symbol table entry.
diff --git a/elfcpp/mips.h b/elfcpp/mips.h
index 8c2d8f4..b355424 100644
--- a/elfcpp/mips.h
+++ b/elfcpp/mips.h
@@ -1,7 +1,8 @@
// mips.h -- ELF definitions specific to EM_MIPS -*- C++ -*-
// Copyright 2012 Free Software Foundation, Inc.
-// Written by Aleksandar Simeonov <aleksandar.simeonov@rt-rk.com>.
+// Written by Sasa Stankovic <sasa.stankovic@rt-rk.com>
+// and Aleksandar Simeonov <aleksandar.simeonov@rt-rk.com>.
// This file is part of elfcpp.
@@ -46,16 +47,16 @@ enum
{
R_MIPS_NONE = 0,
R_MIPS_16 = 1,
- R_MIPS_32 = 2,
- R_MIPS_REL32 = 3,
+ R_MIPS_32 = 2, // In Elf 64: alias R_MIPS_ADD
+ R_MIPS_REL32 = 3, // In Elf 64: alias R_MIPS_REL
R_MIPS_26 = 4,
R_MIPS_HI16 = 5,
R_MIPS_LO16 = 6,
- R_MIPS_GPREL16 = 7,
+ R_MIPS_GPREL16 = 7, // In Elf 64: alias R_MIPS_GPREL
R_MIPS_LITERAL = 8,
- R_MIPS_GOT16 = 9,
+ R_MIPS_GOT16 = 9, // In Elf 64: alias R_MIPS_GOT
R_MIPS_PC16 = 10,
- R_MIPS_CALL16 = 11,
+ R_MIPS_CALL16 = 11, // In Elf 64: alias R_MIPS_CALL
R_MIPS_GPREL32 = 12,
R_MIPS_UNUSED1 = 13,
R_MIPS_UNUSED2 = 14,
@@ -69,48 +70,101 @@ enum
R_MIPS_GOT_HI16 = 22,
R_MIPS_GOT_LO16 = 23,
R_MIPS_SUB = 24,
- R_MIPS_INSERT_A = 25, // Empty relocation
- R_MIPS_INSERT_B = 26, // Empty relocation
- R_MIPS_DELETE = 27, // Empty relocation
+ R_MIPS_INSERT_A = 25,
+ R_MIPS_INSERT_B = 26,
+ R_MIPS_DELETE = 27,
R_MIPS_HIGHER = 28,
R_MIPS_HIGHEST = 29,
R_MIPS_CALL_HI16 = 30,
R_MIPS_CALL_LO16 = 31,
R_MIPS_SCN_DISP = 32,
- R_MIPS_REL16 = 33, // Empty relocation
- R_MIPS_ADD_IMMEDIATE = 34, // Empty relocation
- R_MIPS_PJUMP = 35, // Empty relocation
- R_MIPS_RELGOT = 36, // Empty relocation
+ R_MIPS_REL16 = 33,
+ R_MIPS_ADD_IMMEDIATE = 34,
+ R_MIPS_PJUMP = 35,
+ R_MIPS_RELGOT = 36,
R_MIPS_JALR = 37,
+ // TLS relocations.
R_MIPS_TLS_DTPMOD32 = 38,
R_MIPS_TLS_DTPREL32 = 39,
- R_MIPS_TLS_DTPMOD64 = 40, // Empty relocation
- R_MIPS_TLS_DTPREL64 = 41, // Empty relocation
+ R_MIPS_TLS_DTPMOD64 = 40,
+ R_MIPS_TLS_DTPREL64 = 41,
R_MIPS_TLS_GD = 42,
R_MIPS_TLS_LDM = 43,
R_MIPS_TLS_DTPREL_HI16 = 44,
R_MIPS_TLS_DTPREL_LO16 = 45,
R_MIPS_TLS_GOTTPREL = 46,
R_MIPS_TLS_TPREL32 = 47,
- R_MIPS_TLS_TPREL64 = 48, // Empty relocation
+ R_MIPS_TLS_TPREL64 = 48,
R_MIPS_TLS_TPREL_HI16 = 49,
R_MIPS_TLS_TPREL_LO16 = 50,
R_MIPS_GLOB_DAT = 51,
+ // These relocs are used for the mips16.
R_MIPS16_26 = 100,
R_MIPS16_GPREL = 101,
R_MIPS16_GOT16 = 102,
R_MIPS16_CALL16 = 103,
R_MIPS16_HI16 = 104,
R_MIPS16_LO16 = 105,
+ R_MIPS16_TLS_GD = 106,
+ R_MIPS16_TLS_LDM = 107,
+ R_MIPS16_TLS_DTPREL_HI16 = 108,
+ R_MIPS16_TLS_DTPREL_LO16 = 109,
+ R_MIPS16_TLS_GOTTPREL = 110,
+ R_MIPS16_TLS_TPREL_HI16 = 111,
+ R_MIPS16_TLS_TPREL_LO16 = 112,
+
R_MIPS_COPY = 126,
R_MIPS_JUMP_SLOT = 127,
+
+ // These relocations are specific to microMIPS.
+ R_MICROMIPS_26_S1 = 133,
+ R_MICROMIPS_HI16 = 134,
+ R_MICROMIPS_LO16 = 135,
+ R_MICROMIPS_GPREL16 = 136, // In Elf 64: alias R_MICROMIPS_GPREL
+ R_MICROMIPS_LITERAL = 137,
+ R_MICROMIPS_GOT16 = 138, // In Elf 64: alias R_MICROMIPS_GOT
+ R_MICROMIPS_PC7_S1 = 139,
+ R_MICROMIPS_PC10_S1 = 140,
+ R_MICROMIPS_PC16_S1 = 141,
+ R_MICROMIPS_CALL16 = 142, // In Elf 64: alias R_MICROMIPS_CALL
+ R_MICROMIPS_GOT_DISP = 145,
+ R_MICROMIPS_GOT_PAGE = 146,
+ R_MICROMIPS_GOT_OFST = 147,
+ R_MICROMIPS_GOT_HI16 = 148,
+ R_MICROMIPS_GOT_LO16 = 149,
+ R_MICROMIPS_SUB = 150,
+ R_MICROMIPS_HIGHER = 151,
+ R_MICROMIPS_HIGHEST = 152,
+ R_MICROMIPS_CALL_HI16 = 153,
+ R_MICROMIPS_CALL_LO16 = 154,
+ R_MICROMIPS_SCN_DISP = 155,
+ R_MICROMIPS_JALR = 156,
+ R_MICROMIPS_HI0_LO16 = 157,
+ // TLS relocations.
+ R_MICROMIPS_TLS_GD = 162,
+ R_MICROMIPS_TLS_LDM = 163,
+ R_MICROMIPS_TLS_DTPREL_HI16 = 164,
+ R_MICROMIPS_TLS_DTPREL_LO16 = 165,
+ R_MICROMIPS_TLS_GOTTPREL = 166,
+ R_MICROMIPS_TLS_TPREL_HI16 = 169,
+ R_MICROMIPS_TLS_TPREL_LO16 = 170,
+ // microMIPS GP- and PC-relative relocations.
+ R_MICROMIPS_GPREL7_S2 = 172,
+ R_MICROMIPS_PC23_S2 = 173,
+
+ // This was a GNU extension used by embedded-PIC. It was co-opted by
+ // mips-linux for exception-handling data. GCC stopped using it in
+ // May, 2004, then started using it again for compact unwind tables.
R_MIPS_PC32 = 248,
+ R_MIPS_EH = 249,
+ // This relocation is used internally by gas.
R_MIPS_GNU_REL16_S2 = 250,
+ // These are GNU extensions to enable C++ vtable garbage collection.
R_MIPS_GNU_VTINHERIT = 253,
R_MIPS_GNU_VTENTRY = 254
};
-// Processor specific flags for the ELF header e_flags field. */
+// Processor specific flags for the ELF header e_flags field.
enum
{
// At least one .noreorder directive appears in the source.
@@ -235,6 +289,10 @@ enum
// Note that one of the MIPS16 bits overlaps with STO_MIPS_PIC.
STO_MIPS_ISA = 0xc0,
+ // The mask spanning the rest of MIPS psABI flags. At most one is expected
+ // to be set except for STO_MIPS16.
+ STO_MIPS_FLAGS = ~(STO_MIPS_ISA | 0x3),
+
// The MIPS psABI was updated in 2008 with support for PLTs and copy
// relocs. There are therefore two types of nonzero SHN_UNDEF functions:
// PLT entries and traditional MIPS lazy binding stubs. We mark the former
@@ -262,6 +320,57 @@ enum
DTP_OFFSET = 0x8000
};
+
+bool
+elf_st_is_mips16(unsigned char st_other)
+{ return (st_other & elfcpp::STO_MIPS16) == elfcpp::STO_MIPS16; }
+
+bool
+elf_st_is_micromips(unsigned char st_other)
+{ return (st_other & elfcpp::STO_MIPS_ISA) == elfcpp::STO_MICROMIPS; }
+
+// Whether the ABI is N32.
+bool
+abi_n32(elfcpp::Elf_Word e_flags)
+{ return (e_flags & elfcpp::EF_MIPS_ABI2) != 0; }
+
+// Whether the ABI is N64.
+bool
+abi_64(unsigned char ei_class)
+{ return ei_class == elfcpp::ELFCLASS64; }
+
+// Whether the file has microMIPS code.
+bool
+is_micromips(elfcpp::Elf_Word e_flags)
+{ return (e_flags & elfcpp::EF_MIPS_ARCH_ASE_MICROMIPS) != 0; }
+
+// Values which may appear in the kind field of an Elf_Options structure.
+enum
+{
+ // Undefined.
+ ODK_NULL = 0,
+ // Register usage and GP value.
+ ODK_REGINFO = 1,
+ // Exception processing information.
+ ODK_EXCEPTIONS = 2,
+ // Section padding information.
+ ODK_PAD = 3,
+ // Hardware workarounds performed.
+ ODK_HWPATCH = 4,
+ // Fill value used by the linker.
+ ODK_FILL = 5,
+ // Reserved space for desktop tools.
+ ODK_TAGS = 6,
+ // Hardware workarounds, AND bits when merging.
+ ODK_HWAND = 7,
+ // Hardware workarounds, OR bits when merging.
+ ODK_HWOR = 8,
+ // GP group to use for text/data sections.
+ ODK_GP_GROUP = 9,
+ // ID information.
+ ODK_IDENT = 10
+};
+
} // End namespace elfcpp.
#endif // !defined(ELFCPP_MIPS_H)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index a978b8a..37d2686 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,15 @@
2014-01-30 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.
+
+2014-01-30 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
+
* symtab.cc (Symbol_table::sized_write_globals): Allow a target to
adjust dynamic symbol value.
* target.h (Target::adjust_dyn_symbol): New function.
diff --git a/gold/Makefile.am b/gold/Makefile.am
index 42704ce..0f85377 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/Makefile.in b/gold/Makefile.in
index 661613e..d035919 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -533,11 +533,12 @@ YFILES = \
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 b2741cf..87a4ecf 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
;;