gdb/
[deliverable/binutils-gdb.git] / gold / output.cc
index 96fdd9fa81c2d309a8b9a0ef85042599efbc6679..f2321b77fc54188a0b41afb9affb560aced4dfdc 100644 (file)
@@ -851,15 +851,16 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::Output_reloc(
     os->set_needs_symtab_index();
 }
 
-// An absolute relocation.
+// An absolute or relative relocation.
 
 template<bool dynamic, int size, bool big_endian>
 Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::Output_reloc(
     unsigned int type,
     Output_data* od,
-    Address address)
+    Address address,
+    bool is_relative)
   : address_(address), local_sym_index_(0), type_(type),
-    is_relative_(false), is_symbolless_(false),
+    is_relative_(is_relative), is_symbolless_(false),
     is_section_symbol_(false), use_plt_offset_(false), shndx_(INVALID_CODE)
 {
   // this->type_ is a bitfield; make sure TYPE fits.
@@ -873,9 +874,10 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::Output_reloc(
     unsigned int type,
     Sized_relobj<size, big_endian>* relobj,
     unsigned int shndx,
-    Address address)
+    Address address,
+    bool is_relative)
   : address_(address), local_sym_index_(0), type_(type),
-    is_relative_(false), is_symbolless_(false),
+    is_relative_(is_relative), is_symbolless_(false),
     is_section_symbol_(false), use_plt_offset_(false), shndx_(shndx)
 {
   gold_assert(shndx != INVALID_CODE);
@@ -1129,11 +1131,7 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::symbol_value(
       const Sized_symbol<size>* sym;
       sym = static_cast<const Sized_symbol<size>*>(this->u1_.gsym);
       if (this->use_plt_offset_ && sym->has_plt_offset())
-       {
-         uint64_t plt_address =
-           parameters->target().plt_address_for_global(sym);
-         return plt_address + sym->plt_offset();
-       }
+       return parameters->target().plt_address_for_global(sym);
       else
        return sym->value() + addend;
     }
@@ -1151,11 +1149,7 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::symbol_value(
       this->u1_.relobj->sized_relobj();
   gold_assert(relobj != NULL);
   if (this->use_plt_offset_)
-    {
-      uint64_t plt_address =
-         parameters->target().plt_address_for_local(relobj, lsi);
-      return plt_address + relobj->local_plt_offset(lsi);
-    }
+    return parameters->target().plt_address_for_local(relobj, lsi);
   const Symbol_value<size>* symval = relobj->local_symbol(lsi);
   return symval->value(relobj, addend);
 }
@@ -1385,8 +1379,7 @@ Output_data_got<got_size, big_endian>::Got_entry::write(
        // RELATIVE relocation.
        Symbol* gsym = this->u_.gsym;
        if (this->use_plt_or_tls_offset_ && gsym->has_plt_offset())
-         val = (parameters->target().plt_address_for_global(gsym)
-                + gsym->plt_offset());
+         val = parameters->target().plt_address_for_global(gsym);
        else
          {
            switch (parameters->size_and_endianness())
@@ -1442,11 +1435,7 @@ Output_data_got<got_size, big_endian>::Got_entry::write(
         const unsigned int lsi = this->local_sym_index_;
        bool is_tls = object->local_is_tls(lsi);
        if (this->use_plt_or_tls_offset_ && !is_tls)
-         {
-           uint64_t plt_address =
-             parameters->target().plt_address_for_local(object, lsi);
-           val = plt_address + object->local_plt_offset(lsi);
-         }
+         val = parameters->target().plt_address_for_local(object, lsi);
        else
          {
            uint64_t lval = object->local_symbol_value(lsi, 0);
@@ -1948,7 +1937,7 @@ Output_symtab_xindex::endian_do_write(unsigned char* const oview)
        ++p)
     {
       unsigned int symndx = p->first;
-      gold_assert(symndx * 4 < this->data_size());
+      gold_assert(static_cast<off_t>(symndx) * 4 < this->data_size());
       elfcpp::Swap<32, big_endian>::writeval(oview + symndx * 4, p->second);
     }
 }
@@ -2609,9 +2598,9 @@ Output_section::add_relaxed_input_section(Layout* layout,
 
   // For a relaxed section, we use the current data size.  Linker scripts
   // get all the input sections, including relaxed one from an output
-  // section and add them back to them same output section to compute the
+  // section and add them back to the same output section to compute the
   // output section size.  If we do not account for sizes of relaxed input
-  // sections,  an output section would be incorrectly sized.
+  // sections, an output section would be incorrectly sized.
   off_t offset_in_section = this->current_data_size_for_child();
   off_t aligned_offset_in_section = align_address(offset_in_section,
                                                  poris->addralign());
@@ -2778,7 +2767,7 @@ Output_section::convert_input_sections_in_list_to_relaxed_sections(
       (*input_sections)[p->second].set_section_order_index(soi);
     }
 }
-  
+
 // Convert regular input sections into relaxed input sections. RELAXED_SECTIONS
 // is a vector of pointers to Output_relaxed_input_section or its derived
 // classes.  The relaxed sections must correspond to existing input sections.
@@ -2793,7 +2782,7 @@ Output_section::convert_input_sections_to_relaxed_sections(
   // this.  If there is no checkpoint active, just search the current
   // input section list and replace the sections there.  If there is
   // a checkpoint, also replace the sections there.
-  
+
   // By default, we look at the whole list.
   size_t limit = this->input_sections_.size();
 
@@ -2906,13 +2895,13 @@ Output_section::build_lookup_maps() const
          for (Output_merge_base::Input_sections::const_iterator is =
                 pomb->input_sections_begin();
               is != pomb->input_sections_end();
-              ++is) 
+              ++is)
            {
              const Const_section_id& csid = *is;
            this->lookup_maps_->add_merge_input_section(csid.first,
                                                        csid.second, pomb);
            }
-           
+
        }
       else if (p->is_relaxed_input_section())
        {
@@ -2954,7 +2943,7 @@ Output_section::is_input_address_mapped(const Relobj* object,
     {
       section_offset_type output_offset;
       bool found = posd->output_offset(object, shndx, offset, &output_offset);
-      gold_assert(found);   
+      gold_assert(found);
       return output_offset != -1;
     }
 
@@ -2989,13 +2978,13 @@ Output_section::output_offset(const Relobj* object, unsigned int shndx,
 
   // Look at the Output_section_data_maps first.
   const Output_section_data* posd = this->find_merge_section(object, shndx);
-  if (posd == NULL) 
+  if (posd == NULL)
     posd = this->find_relaxed_input_section(object, shndx);
   if (posd != NULL)
     {
       section_offset_type output_offset;
       bool found = posd->output_offset(object, shndx, offset, &output_offset);
-      gold_assert(found);   
+      gold_assert(found);
       return output_offset;
     }
 
@@ -3022,7 +3011,7 @@ Output_section::output_address(const Relobj* object, unsigned int shndx,
 
   // Look at the Output_section_data_maps first.
   const Output_section_data* posd = this->find_merge_section(object, shndx);
-  if (posd == NULL) 
+  if (posd == NULL)
     posd = this->find_relaxed_input_section(object, shndx);
   if (posd != NULL && posd->is_address_valid())
     {
@@ -3334,7 +3323,11 @@ class Output_section::Input_section_sort_entry
   // in order to better support gcc, and we need to be compatible.
   bool
   match_file_name(const char* file_name) const
-  { return Layout::match_file_name(this->input_section_.relobj(), file_name); }
+  {
+    if (this->input_section_.is_output_section_data())
+      return false;
+    return Layout::match_file_name(this->input_section_.relobj(), file_name);
+  }
 
   // Returns 1 if THIS should appear before S in section order, -1 if S
   // appears before THIS and 0 if they are not comparable.
@@ -3406,6 +3399,19 @@ Output_section::Input_section_sort_compare::operator()(
       return s1.index() < s2.index();
     }
 
+  // Some input section names have special ordering requirements.
+  int o1 = Layout::special_ordering_of_input_section(s1.section_name().c_str());
+  int o2 = Layout::special_ordering_of_input_section(s2.section_name().c_str());
+  if (o1 != o2)
+    {
+      if (o1 < 0)
+       return false;
+      else if (o2 < 0)
+       return true;
+      else
+       return o1 < o2;
+    }
+
   // A section with a priority follows a section without a priority.
   bool s1_has_priority = s1.has_priority();
   bool s2_has_priority = s2.has_priority();
@@ -3508,7 +3514,7 @@ Output_section::Input_section_sort_section_order_index_compare::operator()(
   // Keep input order if section ordering cannot determine order.
   if (s1_secn_index == s2_secn_index)
     return s1.index() < s2.index();
-  
+
   return s1_secn_index < s2_secn_index;
 }
 
@@ -3871,7 +3877,7 @@ Output_section::add_script_input_section(const Input_section& sis)
 
   this->input_sections_.push_back(sis);
 
-  // Update fast lookup maps if necessary. 
+  // Update fast lookup maps if necessary.
   if (this->lookup_maps_->is_valid())
     {
       if (sis.is_merge_section())
@@ -4186,7 +4192,7 @@ Output_segment::maximum_alignment()
   if (!this->is_max_align_known_)
     {
       for (int i = 0; i < static_cast<int>(ORDER_MAX); ++i)
-       {       
+       {
          const Output_data_list* pdl = &this->output_lists_[i];
          uint64_t addralign = Output_segment::maximum_alignment_list(pdl);
          if (addralign > this->max_align_)
This page took 0.028127 seconds and 4 git commands to generate.