gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gold / tilegx.cc
index ce449a425b56096d65ee732e70f5792e0623074a..f2c1038b045982f5d77b7ca01eab8322f04f1b95 100644 (file)
@@ -1,6 +1,6 @@
 // tilegx.cc -- tilegx target support for gold.
 
-// Copyright (C) 2012-2015 Free Software Foundation, Inc.
+// Copyright (C) 2012-2020 Free Software Foundation, Inc.
 // Written by Jiong Wang (jiwang@tilera.com)
 
 // This file is part of gold.
@@ -308,6 +308,21 @@ class Target_tilegx : public Sized_target<size, big_endian>
                           const unsigned char* plocal_symbols,
                           Relocatable_relocs*);
 
+  // Scan the relocs for --emit-relocs.
+  void
+  emit_relocs_scan(Symbol_table* symtab,
+                  Layout* layout,
+                  Sized_relobj_file<size, big_endian>* object,
+                  unsigned int data_shndx,
+                  unsigned int sh_type,
+                  const unsigned char* prelocs,
+                  size_t reloc_count,
+                  Output_section* output_section,
+                  bool needs_special_offset_handling,
+                  size_t local_symbol_count,
+                  const unsigned char* plocal_syms,
+                  Relocatable_relocs* rr);
+
   // Relocate a section during a relocatable link.
   void
   relocate_relocs(
@@ -317,7 +332,6 @@ class Target_tilegx : public Sized_target<size, big_endian>
       size_t reloc_count,
       Output_section* output_section,
       typename elfcpp::Elf_types<size>::Elf_Off offset_in_output_section,
-      const Relocatable_relocs*,
       unsigned char* view,
       typename elfcpp::Elf_types<size>::Elf_Addr view_address,
       section_size_type view_size,
@@ -517,22 +531,11 @@ class Target_tilegx : public Sized_target<size, big_endian>
     // Do a relocation.  Return false if the caller should not issue
     // any warnings about this relocation.
     inline bool
-    relocate(const Relocate_info<size, big_endian>*, Target_tilegx*,
-             Output_section*,
-             size_t relnum, const elfcpp::Rela<size, big_endian>&,
-             unsigned int r_type, const Sized_symbol<size>*,
-             const Symbol_value<size>*,
-             unsigned char*, typename elfcpp::Elf_types<size>::Elf_Addr,
-             section_size_type);
-  };
-
-  // A class which returns the size required for a relocation type,
-  // used while scanning relocs during a relocatable link.
-  class Relocatable_size_for_reloc
-  {
-   public:
-    unsigned int
-    get_size_for_reloc(unsigned int, Relobj*);
+    relocate(const Relocate_info<size, big_endian>*, unsigned int,
+            Target_tilegx*, Output_section*, size_t, const unsigned char*,
+            const Sized_symbol<size>*, const Symbol_value<size>*,
+            unsigned char*, typename elfcpp::Elf_types<size>::Elf_Addr,
+            section_size_type);
   };
 
   // Adjust TLS relocation type based on the options and whether this
@@ -594,10 +597,13 @@ class Target_tilegx : public Sized_target<size, big_endian>
              unsigned int shndx, Output_section* output_section,
              Symbol* sym, const elfcpp::Rela<size, big_endian>& reloc)
   {
+    unsigned int r_type = elfcpp::elf_r_type<size>(reloc.get_r_info());
     this->copy_relocs_.copy_reloc(symtab, layout,
                                   symtab->get_sized_symbol<size>(sym),
                                   object, shndx, output_section,
-                                  reloc, this->rela_dyn_section(layout));
+                                 r_type, reloc.get_r_offset(),
+                                 reloc.get_r_addend(),
+                                  this->rela_dyn_section(layout));
   }
 
   // Information about this specific target which we pass to the
@@ -682,6 +688,7 @@ const Target::Target_info Target_tilegx<64, false>::tilegx_info =
   NULL,                 // attributes_vendor
   "_start",            // entry_symbol_name
   32,                  // hash_entry_size
+  elfcpp::SHT_PROGBITS,        // unwind_section_type
 };
 
 template<>
@@ -710,6 +717,7 @@ const Target::Target_info Target_tilegx<32, false>::tilegx_info =
   NULL,                 // attributes_vendor
   "_start",            // entry_symbol_name
   32,                  // hash_entry_size
+  elfcpp::SHT_PROGBITS,        // unwind_section_type
 };
 
 template<>
@@ -738,6 +746,7 @@ const Target::Target_info Target_tilegx<64, true>::tilegx_info =
   NULL,                 // attributes_vendor
   "_start",            // entry_symbol_name
   32,                  // hash_entry_size
+  elfcpp::SHT_PROGBITS,        // unwind_section_type
 };
 
 template<>
@@ -766,6 +775,7 @@ const Target::Target_info Target_tilegx<32, true>::tilegx_info =
   NULL,                  // attributes_vendor
   "_start",            // entry_symbol_name
   32,                  // hash_entry_size
+  elfcpp::SHT_PROGBITS,        // unwind_section_type
 };
 
 // tilegx relocation handlers
@@ -2521,7 +2531,7 @@ Target_tilegx<size, big_endian>::make_plt_section(Symbol_table* symtab,
       this->got_section(symtab, layout);
 
       // Ensure that .rela.dyn always appears before .rela.plt,
-      // becuase on TILE-Gx, .rela.dyn needs to include .rela.plt
+      // because on TILE-Gx, .rela.dyn needs to include .rela.plt
       // in it's range.
       this->rela_dyn_section(layout);
 
@@ -3369,7 +3379,7 @@ Target_tilegx<size, big_endian>::Scan::local(Symbol_table* symtab,
             // tilegx dynamic linker will not update local got entry,
             // so, if we are generating a shared object, we need to add a
             // dynamic relocation for this symbol's GOT entry to inform
-            // dynamic linker plus the load base explictly.
+            // dynamic linker plus the load base explicitly.
             if (parameters->options().output_is_position_independent())
               {
                unsigned int got_offset
@@ -3425,7 +3435,7 @@ Target_tilegx<size, big_endian>::Scan::local(Symbol_table* symtab,
                //
                // R_TILEGX_TLS_GD_CALL implicitly reference __tls_get_addr,
                // while all other target, x86/arm/mips/powerpc/sparc
-               // generate tls relocation against __tls_get_addr explictly,
+               // generate tls relocation against __tls_get_addr explicitly,
                // so for TILEGX, we need the following hack.
                if (opt_t == tls::TLSOPT_NONE) {
                  if (!target->tls_get_addr_sym_defined_) {
@@ -4154,26 +4164,26 @@ Target_tilegx<size, big_endian>::gc_process_relocs(Symbol_table* symtab,
 {
   typedef Target_tilegx<size, big_endian> Tilegx;
   typedef typename Target_tilegx<size, big_endian>::Scan Scan;
+  typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian>
+      Classify_reloc;
 
   if (sh_type == elfcpp::SHT_REL)
     {
       return;
     }
 
-   gold::gc_process_relocs<size, big_endian,
-                           Tilegx, elfcpp::SHT_RELA, Scan,
-      typename Target_tilegx<size, big_endian>::Relocatable_size_for_reloc>(
-          symtab,
-          layout,
-          this,
-          object,
-          data_shndx,
-          prelocs,
-          reloc_count,
-          output_section,
-          needs_special_offset_handling,
-          local_symbol_count,
-          plocal_symbols);
+   gold::gc_process_relocs<size, big_endian, Tilegx, Scan, Classify_reloc>(
+     symtab,
+     layout,
+     this,
+     object,
+     data_shndx,
+     prelocs,
+     reloc_count,
+     output_section,
+     needs_special_offset_handling,
+     local_symbol_count,
+     plocal_symbols);
 }
 // Scan relocations for a section.
 
@@ -4193,6 +4203,8 @@ Target_tilegx<size, big_endian>::scan_relocs(Symbol_table* symtab,
 {
   typedef Target_tilegx<size, big_endian> Tilegx;
   typedef typename Target_tilegx<size, big_endian>::Scan Scan;
+  typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian>
+      Classify_reloc;
 
   if (sh_type == elfcpp::SHT_REL)
     {
@@ -4201,7 +4213,7 @@ Target_tilegx<size, big_endian>::scan_relocs(Symbol_table* symtab,
       return;
     }
 
-  gold::scan_relocs<size, big_endian, Tilegx, elfcpp::SHT_RELA, Scan>(
+  gold::scan_relocs<size, big_endian, Tilegx, Scan, Classify_reloc>(
     symtab,
     layout,
     this,
@@ -4324,11 +4336,11 @@ template<int size, bool big_endian>
 inline bool
 Target_tilegx<size, big_endian>::Relocate::relocate(
     const Relocate_info<size, big_endian>* relinfo,
+    unsigned int,
     Target_tilegx<size, big_endian>* target,
     Output_section*,
     size_t relnum,
-    const elfcpp::Rela<size, big_endian>& rela,
-    unsigned int r_type,
+    const unsigned char* preloc,
     const Sized_symbol<size>* gsym,
     const Symbol_value<size>* psymval,
     unsigned char* view,
@@ -4341,6 +4353,8 @@ Target_tilegx<size, big_endian>::Relocate::relocate(
   typedef Tilegx_relocate_functions<size, big_endian> TilegxReloc;
   typename TilegxReloc::Tilegx_howto r_howto;
 
+  const elfcpp::Rela<size, big_endian> rela(preloc);
+  unsigned int r_type = elfcpp::elf_r_type<size>(rela.get_r_info());
   const Sized_relobj_file<size, big_endian>* object = relinfo->object;
 
   // Pick the value to use for symbols defined in the PLT.
@@ -4418,6 +4432,7 @@ Target_tilegx<size, big_endian>::Relocate::relocate(
       psymval = &symval;
       always_apply_relocation = true;
       addend = 0;
+      // Fall through.
 
     // when under PIC mode, these relocations are deferred to rtld
     case elfcpp::R_TILEGX_IMM16_X0_HW0:
@@ -4608,6 +4623,7 @@ Target_tilegx<size, big_endian>::Relocate::relocate(
                 got_type = GOT_TYPE_TLS_OFFSET;
                 have_got_offset = true;
               }
+             // Fall through.
             do_update_value:
               if (have_got_offset) {
                 if (gsym != NULL) {
@@ -4637,10 +4653,8 @@ Target_tilegx<size, big_endian>::Relocate::relocate(
               } // else if (opt_t == tls::TLSOPT_TO_LE)
                 //   both GD/IE are turned into LE, which
                 //   is absolute relocation.
-                //
-                //  |  go through
-                //  |
-                //  V
+                // Fall through.
+
             // LE
             //
             // tp
@@ -4741,11 +4755,13 @@ Target_tilegx<size, big_endian>::relocate_section(
 {
   typedef Target_tilegx<size, big_endian> Tilegx;
   typedef typename Target_tilegx<size, big_endian>::Relocate Tilegx_relocate;
+  typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian>
+      Classify_reloc;
 
   gold_assert(sh_type == elfcpp::SHT_RELA);
 
-  gold::relocate_section<size, big_endian, Tilegx, elfcpp::SHT_RELA,
-                        Tilegx_relocate, gold::Default_comdat_behavior>(
+  gold::relocate_section<size, big_endian, Tilegx, Tilegx_relocate,
+                        gold::Default_comdat_behavior, Classify_reloc>(
     relinfo,
     this,
     prelocs,
@@ -4786,24 +4802,50 @@ Target_tilegx<size, big_endian>::apply_relocation(
     view_size);
 }
 
-// Return the size of a relocation while scanning during a relocatable
-// link.
+// Scan the relocs during a relocatable link.
 
 template<int size, bool big_endian>
-unsigned int
-Target_tilegx<size,big_endian>::Relocatable_size_for_reloc::get_size_for_reloc(
-  unsigned int, Relobj*)
+void
+Target_tilegx<size, big_endian>::scan_relocatable_relocs(
+    Symbol_table* symtab,
+    Layout* layout,
+    Sized_relobj_file<size, big_endian>* object,
+    unsigned int data_shndx,
+    unsigned int sh_type,
+    const unsigned char* prelocs,
+    size_t reloc_count,
+    Output_section* output_section,
+    bool needs_special_offset_handling,
+    size_t local_symbol_count,
+    const unsigned char* plocal_symbols,
+    Relocatable_relocs* rr)
 {
-  // We are always SHT_RELA, so we should never get here.
-  gold_unreachable();
-  return 0;
+  typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian>
+      Classify_reloc;
+  typedef gold::Default_scan_relocatable_relocs<Classify_reloc>
+      Scan_relocatable_relocs;
+
+  gold_assert(sh_type == elfcpp::SHT_RELA);
+
+  gold::scan_relocatable_relocs<size, big_endian, Scan_relocatable_relocs>(
+    symtab,
+    layout,
+    object,
+    data_shndx,
+    prelocs,
+    reloc_count,
+    output_section,
+    needs_special_offset_handling,
+    local_symbol_count,
+    plocal_symbols,
+    rr);
 }
 
-// Scan the relocs during a relocatable link.
+// Scan the relocs for --emit-relocs.
 
 template<int size, bool big_endian>
 void
-Target_tilegx<size, big_endian>::scan_relocatable_relocs(
+Target_tilegx<size, big_endian>::emit_relocs_scan(
     Symbol_table* symtab,
     Layout* layout,
     Sized_relobj_file<size, big_endian>* object,
@@ -4814,16 +4856,17 @@ Target_tilegx<size, big_endian>::scan_relocatable_relocs(
     Output_section* output_section,
     bool needs_special_offset_handling,
     size_t local_symbol_count,
-    const unsigned char* plocal_symbols,
+    const unsigned char* plocal_syms,
     Relocatable_relocs* rr)
 {
-  gold_assert(sh_type == elfcpp::SHT_RELA);
+  typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian>
+      Classify_reloc;
+  typedef gold::Default_emit_relocs_strategy<Classify_reloc>
+      Emit_relocs_strategy;
 
-  typedef gold::Default_scan_relocatable_relocs<elfcpp::SHT_RELA,
-    Relocatable_size_for_reloc> Scan_relocatable_relocs;
+  gold_assert(sh_type == elfcpp::SHT_RELA);
 
-  gold::scan_relocatable_relocs<size, big_endian, elfcpp::SHT_RELA,
-      Scan_relocatable_relocs>(
+  gold::scan_relocatable_relocs<size, big_endian, Emit_relocs_strategy>(
     symtab,
     layout,
     object,
@@ -4833,7 +4876,7 @@ Target_tilegx<size, big_endian>::scan_relocatable_relocs(
     output_section,
     needs_special_offset_handling,
     local_symbol_count,
-    plocal_symbols,
+    plocal_syms,
     rr);
 }
 
@@ -4848,22 +4891,23 @@ Target_tilegx<size, big_endian>::relocate_relocs(
     size_t reloc_count,
     Output_section* output_section,
     typename elfcpp::Elf_types<size>::Elf_Off offset_in_output_section,
-    const Relocatable_relocs* rr,
     unsigned char* view,
     typename elfcpp::Elf_types<size>::Elf_Addr view_address,
     section_size_type view_size,
     unsigned char* reloc_view,
     section_size_type reloc_view_size)
 {
+  typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian>
+      Classify_reloc;
+
   gold_assert(sh_type == elfcpp::SHT_RELA);
 
-  gold::relocate_relocs<size, big_endian, elfcpp::SHT_RELA>(
+  gold::relocate_relocs<size, big_endian, Classify_reloc>(
     relinfo,
     prelocs,
     reloc_count,
     output_section,
     offset_in_output_section,
-    rr,
     view,
     view_address,
     view_size,
This page took 0.02895 seconds and 4 git commands to generate.