*** empty log message ***
[deliverable/binutils-gdb.git] / gold / object.cc
index 1adb851ba1dd9f2e4f251cb7aaa75f7da6363511..ed7917bf4cf0ec30f430e5f7229f9b71e50818e8 100644 (file)
@@ -1,6 +1,6 @@
 // object.cc -- support for an object file for linking in gold
 
-// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -226,7 +226,7 @@ Sized_relobj<size, big_endian>::check_eh_frame_flags(
 {
   return (shdr->get_sh_size() > 0
          && shdr->get_sh_type() == elfcpp::SHT_PROGBITS
-         && shdr->get_sh_flags() == elfcpp::SHF_ALLOC);
+         && (shdr->get_sh_flags() & elfcpp::SHF_ALLOC) != 0);
 }
 
 // Return whether there is a GNU .eh_frame section, given the section
@@ -275,8 +275,11 @@ Sized_relobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
 
   const unsigned char* namesu = sd->section_names->data();
   const char* names = reinterpret_cast<const char*>(namesu);
-  if (this->find_eh_frame(pshdrs, names, sd->section_names_size))
-    this->has_eh_frame_ = true;
+  if (memmem(names, sd->section_names_size, ".eh_frame", 10) != NULL)
+    {
+      if (this->find_eh_frame(pshdrs, names, sd->section_names_size))
+        this->has_eh_frame_ = true;
+    }
 
   sd->symbols = NULL;
   sd->symbols_size = 0;
@@ -451,7 +454,7 @@ Sized_relobj<size, big_endian>::include_section_group(
   if ((flags & elfcpp::GRP_COMDAT) == 0
       || layout->add_comdat(signature, true))
     {
-      if (parameters->output_is_object())
+      if (parameters->options().relocatable())
        layout->layout_group(symtab, this, index, name, signature, shdr,
                             pword);
       return true;
@@ -593,8 +596,10 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
   // Keep track of which sections to omit.
   std::vector<bool> omit(shnum, false);
 
-  // Keep track of reloc sections when doing a relocatable link.
-  const bool output_is_object = parameters->output_is_object();
+  // Keep track of reloc sections when emitting relocations.
+  const bool relocatable = parameters->options().relocatable();
+  const bool emit_relocs = (relocatable
+                           || parameters->options().emit_relocs());
   std::vector<unsigned int> reloc_sections;
 
   // Keep track of .eh_frame sections.
@@ -617,7 +622,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
 
       if (this->handle_gnu_warning_section(name, i, symtab))
        {
-         if (!output_is_object)
+         if (!relocatable)
            omit[i] = true;
        }
 
@@ -660,7 +665,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
       // ones associated with sections which are not being discarded.
       // However, we don't know that yet for all sections.  So save
       // reloc sections and process them later.
-      if (output_is_object
+      if (emit_relocs
          && (shdr.get_sh_type() == elfcpp::SHT_REL
              || shdr.get_sh_type() == elfcpp::SHT_RELA))
        {
@@ -668,7 +673,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
          continue;
        }
 
-      if (output_is_object && shdr.get_sh_type() == elfcpp::SHT_GROUP)
+      if (relocatable && shdr.get_sh_type() == elfcpp::SHT_GROUP)
        continue;
 
       // The .eh_frame section is special.  It holds exception frame
@@ -677,7 +682,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
       // sections so that the exception frame reader can reliably
       // determine which sections are being discarded, and discard the
       // corresponding information.
-      if (!output_is_object
+      if (!relocatable
          && strcmp(name, ".eh_frame") == 0
          && this->check_eh_frame_flags(&shdr))
        {
@@ -704,7 +709,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
 
   // When doing a relocatable link handle the reloc sections at the
   // end.
-  if (output_is_object)
+  if (emit_relocs)
     this->size_relocatable_relocs();
   for (std::vector<unsigned int>::const_iterator p = reloc_sections.begin();
        p != reloc_sections.end();
@@ -884,12 +889,14 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
       if (shndx < shnum && mo[shndx].output_section == NULL)
         {
          lv.set_no_output_symtab_entry();
+          gold_assert(!lv.needs_output_dynsym_entry());
           continue;
         }
 
       if (sym.get_st_type() == elfcpp::STT_SECTION)
        {
          lv.set_no_output_symtab_entry();
+          gold_assert(!lv.needs_output_dynsym_entry());
          continue;
        }
 
@@ -947,7 +954,7 @@ Sized_relobj<size, big_endian>::do_finalize_local_symbols(unsigned int index,
       
       if (shndx >= elfcpp::SHN_LORESERVE)
        {
-         if (shndx == elfcpp::SHN_ABS)
+         if (shndx == elfcpp::SHN_ABS || shndx == elfcpp::SHN_COMMON)
            lv.set_output_value(lv.input_value());
          else
            {
@@ -1045,17 +1052,6 @@ Sized_relobj<size, big_endian>::do_set_local_dynsym_offset(off_t off)
   return this->output_local_dynsym_count_;
 }
 
-// Return the value of the local symbol symndx.
-template<int size, bool big_endian>
-typename elfcpp::Elf_types<size>::Elf_Addr
-Sized_relobj<size, big_endian>::local_symbol_value(unsigned int symndx) const
-{
-  gold_assert(symndx < this->local_symbol_count_);
-  gold_assert(symndx < this->local_values_.size());
-  const Symbol_value<size>& lv(this->local_values_[symndx]);
-  return lv.value(this, 0);
-}
-
 // Write out the local symbols.
 
 template<int size, bool big_endian>
@@ -1065,7 +1061,8 @@ Sized_relobj<size, big_endian>::write_local_symbols(
     const Stringpool* sympool,
     const Stringpool* dynpool)
 {
-  if (parameters->strip_all() && this->output_local_dynsym_count_ == 0)
+  if (parameters->options().strip_all()
+      && this->output_local_dynsym_count_ == 0)
     return;
 
   gold_assert(this->symtab_shndx_ != -1U);
@@ -1131,7 +1128,7 @@ Sized_relobj<size, big_endian>::write_local_symbols(
        }
 
       // Write the symbol to the output symbol table.
-      if (!parameters->strip_all()
+      if (!parameters->options().strip_all()
          && this->local_values_[i].needs_output_symtab_entry())
         {
           elfcpp::Sym_write<size, big_endian> osym(ov);
@@ -1232,7 +1229,7 @@ Sized_relobj<size, big_endian>::get_symbol_location_info(
          else
             {
               info->enclosing_symbol_name = symbol_names + sym.get_st_name();
-              if (parameters->demangle())
+              if (parameters->options().demangle())
                 {
                   char* demangled_name = cplus_demangle(
                       info->enclosing_symbol_name.c_str(),
@@ -1261,9 +1258,9 @@ Input_objects::add_object(Object* obj)
 {
   // Set the global target from the first object file we recognize.
   Target* target = obj->target();
-  if (!parameters->is_target_valid())
+  if (!parameters->target_valid())
     set_parameters_target(target);
-  else if (target != parameters->target())
+  else if (target != &parameters->target())
     {
       obj->error(_("incompatible target"));
       return false;
This page took 0.025655 seconds and 4 git commands to generate.