gold/
authorCary Coutant <ccoutant@google.com>
Tue, 23 Oct 2012 21:34:58 +0000 (21:34 +0000)
committerCary Coutant <ccoutant@google.com>
Tue, 23 Oct 2012 21:34:58 +0000 (21:34 +0000)
* dwarf_reader.cc (make_elf_reloc_mapper): Check size and endianness
from object, not parameters.
(Dwarf_info_reader::parse): Likewise.
* object.h (Relobj::elfsize, Relobj::is_big_endian): New methods.
(Relobj::do_elfsize, Relobj::do_is_big_endian): New methods.
(Sized_relobj::do_elfsize, Sized_relobj::do_is_big_endian): New
methods.

gold/ChangeLog
gold/dwarf_reader.cc
gold/object.h

index 4ea4b271a1b8e912b43851b1606aa08968c7054a..dbf1f5ee3be96725aedffa0d7663842266634247 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-23  Cary Coutant  <ccoutant@google.com>
+
+       * dwarf_reader.cc (make_elf_reloc_mapper): Check size and endianness
+       from object, not parameters.
+       (Dwarf_info_reader::parse): Likewise.
+       * object.h (Relobj::elfsize, Relobj::is_big_endian): New methods.
+       (Relobj::do_elfsize, Relobj::do_is_big_endian): New methods.
+       (Sized_relobj::do_elfsize, Sized_relobj::do_is_big_endian): New
+       methods.
+
 2012-10-23  Cary Coutant  <ccoutant@google.com>
 
        * fileread.cc (Input_file::Input_file): New constructor.
index 00347032a0c6aa76244d65743566d2b09fd79b22..d0f059dada07bfa93baac69fd1cc8d5f8783368e 100644 (file)
@@ -28,7 +28,6 @@
 #include "elfcpp_swap.h"
 #include "dwarf.h"
 #include "object.h"
-#include "parameters.h"
 #include "reloc.h"
 #include "dwarf_reader.h"
 #include "int_encoding.h"
@@ -90,34 +89,53 @@ Sized_elf_reloc_mapper<size, big_endian>::do_get_reloc_target(
 }
 
 static inline Elf_reloc_mapper*
-make_elf_reloc_mapper(Object* object, const unsigned char* symtab,
+make_elf_reloc_mapper(Relobj* object, const unsigned char* symtab,
                      off_t symtab_size)
 {
-  switch (parameters->size_and_endianness())
+  if (object->elfsize() == 32)
     {
-#ifdef HAVE_TARGET_32_LITTLE
-      case Parameters::TARGET_32_LITTLE:
-       return new Sized_elf_reloc_mapper<32, false>(object, symtab,
-                                                    symtab_size);
-#endif
+      if (object->is_big_endian())
+        {
 #ifdef HAVE_TARGET_32_BIG
-      case Parameters::TARGET_32_BIG:
-       return new Sized_elf_reloc_mapper<32, true>(object, symtab,
-                                                   symtab_size);
+         return new Sized_elf_reloc_mapper<32, true>(object, symtab,
+                                                     symtab_size);
+#else
+         gold_unreachable();
 #endif
-#ifdef HAVE_TARGET_64_LITTLE
-      case Parameters::TARGET_64_LITTLE:
-       return new Sized_elf_reloc_mapper<64, false>(object, symtab,
-                                                    symtab_size);
+        }
+      else
+        {
+#ifdef HAVE_TARGET_32_LITTLE
+         return new Sized_elf_reloc_mapper<32, false>(object, symtab,
+                                                      symtab_size);
+#else
+         gold_unreachable();
 #endif
+        }
+    }
+  else if (object->elfsize() == 64)
+    {
+      if (object->is_big_endian())
+        {
 #ifdef HAVE_TARGET_64_BIG
-      case Parameters::TARGET_64_BIG:
-       return new Sized_elf_reloc_mapper<64, true>(object, symtab,
-                                                   symtab_size);
+         return new Sized_elf_reloc_mapper<64, true>(object, symtab,
+                                                     symtab_size);
+#else
+         gold_unreachable();
 #endif
-      default:
-       gold_unreachable();
+        }
+      else
+        {
+#ifdef HAVE_TARGET_64_LITTLE
+         return new Sized_elf_reloc_mapper<64, false>(object, symtab,
+                                                      symtab_size);
+#else
+         gold_unreachable();
+#endif
+        }
     }
+  else
+    gold_unreachable();
 }
 
 // class Dwarf_abbrev_table
@@ -1136,30 +1154,21 @@ Dwarf_info_reader::check_buffer(const unsigned char* p) const
 void
 Dwarf_info_reader::parse()
 {
-  switch (parameters->size_and_endianness())
+  if (this->object_->is_big_endian())
     {
-#ifdef HAVE_TARGET_32_LITTLE
-      case Parameters::TARGET_32_LITTLE:
-        this->do_parse<false>();
-        break;
-#endif
-#ifdef HAVE_TARGET_32_BIG
-      case Parameters::TARGET_32_BIG:
-        this->do_parse<true>();
-        break;
+#if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
+      this->do_parse<true>();
+#else
+      gold_unreachable();
 #endif
-#ifdef HAVE_TARGET_64_LITTLE
-      case Parameters::TARGET_64_LITTLE:
-        this->do_parse<false>();
-        break;
-#endif
-#ifdef HAVE_TARGET_64_BIG
-      case Parameters::TARGET_64_BIG:
-        this->do_parse<true>();
-        break;
+    }
+  else
+    {
+#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
+      this->do_parse<false>();
+#else
+      gold_unreachable();
 #endif
-      default:
-       gold_unreachable();
     }
 }
 
index 522b63f44b67865a45a798ed344e994a378aad13..01c3c6fe2fbfe47a0f7bee08b87228fb5c46d6c0 100644 (file)
@@ -1224,6 +1224,16 @@ class Relobj : public Object
   do_get_incremental_reloc_count(unsigned int symndx) const
   { return this->reloc_counts_[symndx]; }
 
+  // Return the word size of the object file.
+  int
+  elfsize() const
+  { return this->do_elfsize(); }
+
+  // Return TRUE if this is a big-endian object file.
+  bool
+  is_big_endian() const
+  { return this->do_is_big_endian(); }
+
  protected:
   // The output section to be used for each input section, indexed by
   // the input section number.  The output section is NULL if the
@@ -1386,6 +1396,16 @@ class Relobj : public Object
     return this->reloc_bases_[symndx] + counter;
   }
 
+  // Return the word size of the object file--
+  // implemented by child class.
+  virtual int
+  do_elfsize() const = 0;
+
+  // Return TRUE if this is a big-endian object file--
+  // implemented by child class.
+  virtual bool
+  do_is_big_endian() const = 0;
+
  private:
   // Mapping from input sections to output section.
   Output_sections output_sections_;
@@ -1963,6 +1983,16 @@ class Sized_relobj : public Relobj
       }
   }
 
+  // Return the word size of the object file.
+  virtual int
+  do_elfsize() const
+  { return size; }
+
+  // Return TRUE if this is a big-endian object file.
+  virtual bool
+  do_is_big_endian() const
+  { return big_endian; }
+
  private:
   // The GOT offsets of local symbols. This map also stores GOT offsets
   // for tp-relative offsets for TLS symbols.