src/share/vm/utilities/elfStringTable.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef __ELF_STRING_TABLE_HPP
  26 #define __ELF_STRING_TABLE_HPP
  27 
  28 #if !defined(_WINDOWS) && !defined(__APPLE__)
  29 
  30 #include "memory/allocation.hpp"
  31 #include "utilities/decoder.hpp"
  32 #include "utilities/elfFile.hpp"
  33 
  34 
  35 // The string table represents a string table section in an elf file.
  36 // Whenever there is enough memory, it will load whole string table as
  37 // one blob. Otherwise, it will load string from file when requested.
  38 
  39 #define MAX_SYMBOL_LEN  256
  40 
  41 class ElfStringTable: CHeapObj {
  42   friend class ElfFile;
  43  public:
  44   ElfStringTable(FILE* file, Elf_Shdr shdr, int index);
  45   ~ElfStringTable();
  46 
  47   // section index
  48   int index() { return m_index; };
  49 
  50   // get string at specified offset
  51   const char* string_at(int offset);
  52 
  53   // get status code
  54   Decoder::decoder_status get_status() { return m_status; };
  55 
  56  protected:
  57   ElfStringTable*        m_next;
  58 
  59   // section index
  60   int                      m_index;
  61 
  62   // holds complete string table if can
  63   // allocate enough memory
  64   const char*              m_table;
  65 
  66   // file contains string table
  67   FILE*                    m_file;
  68 
  69   // section header
  70   Elf_Shdr                 m_shdr;
  71 
  72   // buffer for reading individual string
  73   char                     m_symbol[MAX_SYMBOL_LEN];
  74 
  75   // error code
  76   Decoder::decoder_status  m_status;
  77 };
  78 
  79 #endif // _WINDOWS
  80 
  81 #endif // __ELF_STRING_TABLE_HPP
   1 /*
   2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_UTILITIES_ELF_STRING_TABLE_HPP
  26 #define SHARE_VM_UTILITIES_ELF_STRING_TABLE_HPP
  27 
  28 #if !defined(_WINDOWS) && !defined(__APPLE__)
  29 
  30 #include "memory/allocation.hpp"
  31 #include "utilities/decoder.hpp"
  32 #include "utilities/elfFile.hpp"
  33 
  34 
  35 // The string table represents a string table section in an elf file.
  36 // Whenever there is enough memory, it will load whole string table as
  37 // one blob. Otherwise, it will load string from file when requested.



  38 class ElfStringTable: CHeapObj {
  39   friend class ElfFile;
  40  public:
  41   ElfStringTable(FILE* file, Elf_Shdr shdr, int index);
  42   ~ElfStringTable();
  43 
  44   // section index
  45   int index() { return m_index; };
  46 
  47   // get string at specified offset
  48   bool string_at(int offset, char* buf, int buflen);
  49 
  50   // get status code
  51   NullDecoder::decoder_status get_status() { return m_status; };
  52 
  53  protected:
  54   ElfStringTable*        m_next;
  55 
  56   // section index
  57   int                      m_index;
  58 
  59   // holds complete string table if can
  60   // allocate enough memory
  61   const char*              m_table;
  62 
  63   // file contains string table
  64   FILE*                    m_file;
  65 
  66   // section header
  67   Elf_Shdr                 m_shdr;
  68 



  69   // error code
  70   NullDecoder::decoder_status  m_status;
  71 };
  72 
  73 #endif // _WINDOWS and _APPLE
  74 
  75 #endif // SHARE_VM_UTILITIES_ELF_STRING_TABLE_HPP