Fix build failure in inf-ptrace.c.
[binutils-gdb.git] / gold / stringpool.h
index 0257894a869ab110eecdf7e5069bb139e98bb45d..906ceaa17a41a0a0b55c71e05e3089969ff85635 100644 (file)
@@ -1,6 +1,6 @@
 // stringpool.h -- a string pool for gold    -*- C++ -*-
 
-// 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.
@@ -176,6 +176,12 @@ class Stringpool_template
   set_no_zero_null()
   { this->zero_null_ = false; }
 
+  // Indicate that this string pool should be optimized, even if not
+  // running with -O2.
+  void
+  set_optimize()
+  { this->optimize_ = true; }
+
   // Add the string S to the pool.  This returns a canonical permanent
   // pointer to the string in the pool.  If COPY is true, the string
   // is copied into permanent storage.  If PKEY is not NULL, this sets
@@ -220,8 +226,8 @@ class Stringpool_template
   section_offset_type
   get_offset_from_key(Key k) const
   {
-    gold_assert(k < this->key_to_offset_.size());
-    return this->key_to_offset_[k];
+    gold_assert(k <= this->key_to_offset_.size());
+    return this->key_to_offset_[k - 1];
   }
 
   // Get the size of the string table.  This returns the number of
@@ -364,6 +370,8 @@ class Stringpool_template
   section_size_type strtab_size_;
   // Whether to reserve offset 0 to hold the null string.
   bool zero_null_;
+  // Whether to optimize the string table.
+  bool optimize_;
 };
 
 // The most common type of Stringpool.