* elflink.c (set_symbol_value): Add isymbuf and locsymcount
[deliverable/binutils-gdb.git] / gold / dynobj.cc
index 10f8fbefb856ff51df63fc3ba1d5940dff90f691..09e71263ac8f2200ef665af8968757f1fd476191 100644 (file)
@@ -1,11 +1,32 @@
 // dynobj.cc -- dynamic object support for gold
 
+// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Written by Ian Lance Taylor <iant@google.com>.
+
+// This file is part of gold.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
 #include "gold.h"
 
 #include <vector>
 #include <cstring>
 
 #include "elfcpp.h"
+#include "parameters.h"
 #include "symtab.h"
 #include "dynobj.h"
 
@@ -153,7 +174,8 @@ Sized_dynobj<size, big_endian>::read_dynsym_section(
       gold_exit(false);
     }
 
-  *view = this->get_lasting_view(shdr.get_sh_offset(), shdr.get_sh_size());
+  *view = this->get_lasting_view(shdr.get_sh_offset(), shdr.get_sh_size(),
+                                false);
   *view_size = shdr.get_sh_size();
   *view_info = shdr.get_sh_info();
 }
@@ -177,7 +199,7 @@ Sized_dynobj<size, big_endian>::set_soname(const unsigned char* pshdrs,
 
   const off_t dynamic_size = dynamicshdr.get_sh_size();
   const unsigned char* pdynamic = this->get_view(dynamicshdr.get_sh_offset(),
-                                                dynamic_size);
+                                                dynamic_size, false);
 
   const unsigned int link = dynamicshdr.get_sh_link();
   if (link != strtab_shndx)
@@ -202,7 +224,7 @@ Sized_dynobj<size, big_endian>::set_soname(const unsigned char* pshdrs,
        }
 
       strtab_size = strtabshdr.get_sh_size();
-      strtabu = this->get_view(strtabshdr.get_sh_offset(), strtab_size);
+      strtabu = this->get_view(strtabshdr.get_sh_offset(), strtab_size, false);
     }
 
   for (const unsigned char* p = pdynamic;
@@ -274,7 +296,7 @@ Sized_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
       gold_assert(dynsymshdr.get_sh_type() == elfcpp::SHT_DYNSYM);
 
       sd->symbols = this->get_lasting_view(dynsymshdr.get_sh_offset(),
-                                          dynsymshdr.get_sh_size());
+                                          dynsymshdr.get_sh_size(), false);
       sd->symbols_size = dynsymshdr.get_sh_size();
 
       // Get the symbol names.
@@ -298,7 +320,8 @@ Sized_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
        }
 
       sd->symbol_names = this->get_lasting_view(strtabshdr.get_sh_offset(),
-                                               strtabshdr.get_sh_size());
+                                               strtabshdr.get_sh_size(),
+                                               true);
       sd->symbol_names_size = strtabshdr.get_sh_size();
 
       // Get the version information.
@@ -340,8 +363,7 @@ Sized_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
 
 template<int size, bool big_endian>
 void
-Sized_dynobj<size, big_endian>::do_layout(const General_options&,
-                                         Symbol_table* symtab,
+Sized_dynobj<size, big_endian>::do_layout(Symbol_table* symtab,
                                          Layout*,
                                          Read_symbols_data* sd)
 {
@@ -718,8 +740,7 @@ Dynobj::elf_hash(const char* name)
 // symbol table.
 
 void
-Dynobj::create_elf_hash_table(const Target* target,
-                             const std::vector<Symbol*>& dynsyms,
+Dynobj::create_elf_hash_table(const std::vector<Symbol*>& dynsyms,
                              unsigned int local_dynsym_count,
                              unsigned char** pphash,
                              unsigned int* phashlen)
@@ -752,10 +773,24 @@ Dynobj::create_elf_hash_table(const Target* target,
                          * 4);
   unsigned char* phash = new unsigned char[hashlen];
 
-  if (target->is_big_endian())
-    Dynobj::sized_create_elf_hash_table<true>(bucket, chain, phash, hashlen);
+  if (parameters->is_big_endian())
+    {
+#if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
+      Dynobj::sized_create_elf_hash_table<true>(bucket, chain, phash,
+                                               hashlen);
+#else
+      gold_unreachable();
+#endif
+    }
   else
-    Dynobj::sized_create_elf_hash_table<false>(bucket, chain, phash, hashlen);
+    {
+#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
+      Dynobj::sized_create_elf_hash_table<false>(bucket, chain, phash,
+                                                hashlen);
+#else
+      gold_unreachable();
+#endif
+    }
 
   *pphash = phash;
   *phashlen = hashlen;
@@ -818,8 +853,7 @@ Dynobj::gnu_hash(const char* name)
 // symbol table.
 
 void
-Dynobj::create_gnu_hash_table(const Target* target,
-                             const std::vector<Symbol*>& dynsyms,
+Dynobj::create_gnu_hash_table(const std::vector<Symbol*>& dynsyms,
                              unsigned int local_dynsym_count,
                              unsigned char** pphash,
                              unsigned int* phashlen)
@@ -868,37 +902,61 @@ Dynobj::create_gnu_hash_table(const Target* target,
 
   // For the actual data generation we call out to a templatized
   // function.
-  int size = target->get_size();
-  bool big_endian = target->is_big_endian();
+  int size = parameters->get_size();
+  bool big_endian = parameters->is_big_endian();
   if (size == 32)
     {
       if (big_endian)
-       Dynobj::sized_create_gnu_hash_table<32, true>(hashed_dynsyms,
-                                                     dynsym_hashvals,
-                                                     unhashed_dynsym_index,
-                                                     pphash,
-                                                     phashlen);
+       {
+#ifdef HAVE_TARGET_32_BIG
+         Dynobj::sized_create_gnu_hash_table<32, true>(hashed_dynsyms,
+                                                       dynsym_hashvals,
+                                                       unhashed_dynsym_index,
+                                                       pphash,
+                                                       phashlen);
+#else
+         gold_unreachable();
+#endif
+       }
       else
-       Dynobj::sized_create_gnu_hash_table<32, false>(hashed_dynsyms,
-                                                      dynsym_hashvals,
-                                                      unhashed_dynsym_index,
-                                                      pphash,
-                                                      phashlen);
+       {
+#ifdef HAVE_TARGET_32_LITTLE
+         Dynobj::sized_create_gnu_hash_table<32, false>(hashed_dynsyms,
+                                                        dynsym_hashvals,
+                                                        unhashed_dynsym_index,
+                                                        pphash,
+                                                        phashlen);
+#else
+         gold_unreachable();
+#endif
+       }
     }
   else if (size == 64)
     {
       if (big_endian)
-       Dynobj::sized_create_gnu_hash_table<64, true>(hashed_dynsyms,
-                                                     dynsym_hashvals,
-                                                     unhashed_dynsym_index,
-                                                     pphash,
-                                                     phashlen);
+       {
+#ifdef HAVE_TARGET_64_BIG
+         Dynobj::sized_create_gnu_hash_table<64, true>(hashed_dynsyms,
+                                                       dynsym_hashvals,
+                                                       unhashed_dynsym_index,
+                                                       pphash,
+                                                       phashlen);
+#else
+         gold_unreachable();
+#endif
+       }
       else
-       Dynobj::sized_create_gnu_hash_table<64, false>(hashed_dynsyms,
-                                                      dynsym_hashvals,
-                                                      unhashed_dynsym_index,
-                                                      pphash,
-                                                      phashlen);
+       {
+#ifdef HAVE_TARGET_64_LITTLE
+         Dynobj::sized_create_gnu_hash_table<64, false>(hashed_dynsyms,
+                                                        dynsym_hashvals,
+                                                        unhashed_dynsym_index,
+                                                        pphash,
+                                                        phashlen);
+#else
+         gold_unreachable();
+#endif
+       }
     }
   else
     gold_unreachable();
@@ -1196,7 +1254,7 @@ Versions::record_version(const General_options* options,
 
   if (!sym->is_from_dynobj())
     {
-      if (options->is_shared())
+      if (parameters->output_is_shared())
         this->add_def(options, sym, version, version_key);
     }
   else
@@ -1239,7 +1297,7 @@ Versions::add_def(const General_options* options, const Symbol* sym,
       // If we are creating a shared object, it is an error to
       // find a definition of a symbol with a version which is not
       // in the version script.
-      if (options->is_shared())
+      if (parameters->output_is_shared())
        {
          fprintf(stderr, _("%s: symbol %s has undefined version %s\n"),
                  program_name, sym->name(), version);
@@ -1366,8 +1424,7 @@ Versions::finalize(const Target* target, Symbol_table* symtab,
 // pointers.
 
 unsigned int
-Versions::version_index(const General_options* options,
-                        const Stringpool* dynpool, const Symbol* sym) const
+Versions::version_index(const Stringpool* dynpool, const Symbol* sym) const
 {
   Stringpool::Key version_key;
   const char* version = dynpool->find(sym->version(), &version_key);
@@ -1376,7 +1433,7 @@ Versions::version_index(const General_options* options,
   Key k;
   if (!sym->is_from_dynobj())
     {
-      if (!options->is_shared())
+      if (!parameters->output_is_shared())
         return elfcpp::VER_NDX_GLOBAL;
       k = Key(version_key, 0);
     }
@@ -1404,8 +1461,7 @@ Versions::version_index(const General_options* options,
 
 template<int size, bool big_endian>
 void
-Versions::symbol_section_contents(const General_options* options,
-                                  const Stringpool* dynpool,
+Versions::symbol_section_contents(const Stringpool* dynpool,
                                  unsigned int local_symcount,
                                  const std::vector<Symbol*>& syms,
                                  unsigned char** pp,
@@ -1430,7 +1486,7 @@ Versions::symbol_section_contents(const General_options* options,
       if (version == NULL)
        version_index = elfcpp::VER_NDX_GLOBAL;
       else
-       version_index = this->version_index(options, dynpool, *p);
+       version_index = this->version_index(dynpool, *p);
       elfcpp::Swap<16, big_endian>::writeval(pbuf + (*p)->dynsym_index() * 2,
                                             version_index);
     }
@@ -1554,7 +1610,6 @@ class Sized_dynobj<64, true>;
 template
 void
 Versions::symbol_section_contents<32, false>(
-    const General_options*,
     const Stringpool*,
     unsigned int,
     const std::vector<Symbol*>&,
@@ -1567,7 +1622,6 @@ Versions::symbol_section_contents<32, false>(
 template
 void
 Versions::symbol_section_contents<32, true>(
-    const General_options*,
     const Stringpool*,
     unsigned int,
     const std::vector<Symbol*>&,
@@ -1580,7 +1634,6 @@ Versions::symbol_section_contents<32, true>(
 template
 void
 Versions::symbol_section_contents<64, false>(
-    const General_options*,
     const Stringpool*,
     unsigned int,
     const std::vector<Symbol*>&,
@@ -1593,7 +1646,6 @@ Versions::symbol_section_contents<64, false>(
 template
 void
 Versions::symbol_section_contents<64, true>(
-    const General_options*,
     const Stringpool*,
     unsigned int,
     const std::vector<Symbol*>&,
This page took 0.033257 seconds and 4 git commands to generate.