* layout.cc (Layout::Layout): Initialize increase_relro_.
[deliverable/binutils-gdb.git] / gold / x86_64.cc
index cbc45beda15eae87d85970bb140e2f154e34893d..4635799908a732f897dad31f856c6185e90b8ca7 100644 (file)
@@ -102,7 +102,7 @@ class Target_x86_64 : public Target_freebsd<64, false>
 
   // Finalize the sections.
   void
-  do_finalize_sections(Layout*, const Input_objects*);
+  do_finalize_sections(Layout*, const Input_objects*, Symbol_table*);
 
   // Return the value to use for a dynamic which requires special
   // treatment.
@@ -439,7 +439,9 @@ const Target::Target_info Target_x86_64::x86_64_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_X86_64_LCOMMON,  // large_common_shndx
   0,                   // small_common_section_flags
-  elfcpp::SHF_X86_64_LARGE     // large_common_section_flags
+  elfcpp::SHF_X86_64_LARGE,    // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 // This is called when a new output section is created.  This is where
@@ -467,25 +469,25 @@ Target_x86_64::got_section(Symbol_table* symtab, Layout* layout)
       os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
                                           (elfcpp::SHF_ALLOC
                                            | elfcpp::SHF_WRITE),
-                                          this->got_, false);
-      os->set_is_relro();
+                                          this->got_, false, true, true,
+                                          false);
 
-      // The old GNU linker creates a .got.plt section.  We just
-      // create another set of data in the .got section.  Note that we
-      // always create a PLT if we create a GOT, although the PLT
-      // might be empty.
       this->got_plt_ = new Output_data_space(8, "** GOT PLT");
-      os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
+      os = layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS,
                                           (elfcpp::SHF_ALLOC
                                            | elfcpp::SHF_WRITE),
-                                          this->got_plt_, false);
-      os->set_is_relro();
+                                          this->got_plt_, false, false,
+                                          false, true);
 
       // The first three entries are reserved.
       this->got_plt_->set_current_data_size(3 * 8);
 
+      // Those bytes can go into the relro segment.
+      layout->increase_relro(3 * 8);
+
       // Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT.
       symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
+                                   Symbol_table::PREDEFINED,
                                    this->got_plt_,
                                    0, 0, elfcpp::STT_OBJECT,
                                    elfcpp::STB_LOCAL,
@@ -506,7 +508,8 @@ Target_x86_64::rela_dyn_section(Layout* layout)
       gold_assert(layout != NULL);
       this->rela_dyn_ = new Reloc_section(parameters->options().combreloc());
       layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA,
-                                     elfcpp::SHF_ALLOC, this->rela_dyn_, true);
+                                     elfcpp::SHF_ALLOC, this->rela_dyn_, true,
+                                     false, false, false);
     }
   return this->rela_dyn_;
 }
@@ -606,7 +609,8 @@ Output_data_plt_x86_64::Output_data_plt_x86_64(Layout* layout,
 {
   this->rel_ = new Reloc_section(false);
   layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA,
-                                 elfcpp::SHF_ALLOC, this->rel_, true);
+                                 elfcpp::SHF_ALLOC, this->rel_, true,
+                                 false, false, false);
 }
 
 void
@@ -802,7 +806,7 @@ Target_x86_64::make_plt_section(Symbol_table* symtab, Layout* layout)
       layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
                                      (elfcpp::SHF_ALLOC
                                       | elfcpp::SHF_EXECINSTR),
-                                     this->plt_, false);
+                                     this->plt_, false, false, false, false);
     }
 }
 
@@ -834,6 +838,7 @@ Target_x86_64::define_tls_base_symbol(Symbol_table* symtab, Layout* layout)
     {
       bool is_exec = parameters->options().output_is_executable();
       symtab->define_in_output_segment("_TLS_MODULE_BASE_", NULL,
+                                      Symbol_table::PREDEFINED,
                                       tls_segment, 0, 0,
                                       elfcpp::STT_TLS,
                                       elfcpp::STB_LOCAL,
@@ -1350,7 +1355,7 @@ Target_x86_64::Scan::global(Symbol_table* symtab,
           target->make_plt_entry(symtab, layout, gsym);
         // Make a dynamic relocation if necessary.
         int flags = Symbol::NON_PIC_REF;
-        if (gsym->type() == elfcpp::STT_FUNC)
+        if (gsym->is_func())
           flags |= Symbol::FUNCTION_CALL;
         if (gsym->needs_dynamic_reloc(flags))
           {
@@ -1642,7 +1647,10 @@ Target_x86_64::scan_relocs(Symbol_table* symtab,
 // Finalize the sections.
 
 void
-Target_x86_64::do_finalize_sections(Layout* layout, const Input_objects*)
+Target_x86_64::do_finalize_sections(
+    Layout* layout,
+    const Input_objects*,
+    Symbol_table*)
 {
   // Fill in some more dynamic tags.
   Output_data_dynamic* const odyn = layout->dynamic_data();
@@ -2687,7 +2695,11 @@ Target_x86_64::do_calls_non_split(Relobj* object, unsigned int shndx,
       this->set_view_to_nop(view, view_size, fnoffset + 1, 8);
     }
   // lea NN(%rsp),%r10
-  else if (this->match_view(view, view_size, fnoffset, "\x4c\x8d\x94\x24", 4)
+  // lea NN(%rsp),%r11
+  else if ((this->match_view(view, view_size, fnoffset,
+                            "\x4c\x8d\x94\x24", 4)
+           || this->match_view(view, view_size, fnoffset,
+                               "\x4c\x8d\x9c\x24", 4))
           && fnsize > 8)
     {
       // This is loading an offset from the stack pointer for a
@@ -2705,7 +2717,7 @@ Target_x86_64::do_calls_non_split(Relobj* object, unsigned int shndx,
       if (!object->has_no_split_stack())
        object->error(_("failed to match split-stack sequence at "
                        "section %u offset %0zx"),
-                     shndx, fnoffset);
+                     shndx, static_cast<size_t>(fnoffset));
       return;
     }
 
This page took 0.040798 seconds and 4 git commands to generate.