zgu@2364: /* mikael@4153: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. zgu@2364: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. zgu@2364: * zgu@2364: * This code is free software; you can redistribute it and/or modify it zgu@2364: * under the terms of the GNU General Public License version 2 only, as zgu@2364: * published by the Free Software Foundation. zgu@2364: * zgu@2364: * This code is distributed in the hope that it will be useful, but WITHOUT zgu@2364: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or zgu@2364: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License zgu@2364: * version 2 for more details (a copy is included in the LICENSE file that zgu@2364: * accompanied this code). zgu@2364: * zgu@2364: * You should have received a copy of the GNU General Public License version zgu@2364: * 2 along with this work; if not, write to the Free Software Foundation, zgu@2364: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. zgu@2364: * zgu@2364: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA zgu@2364: * or visit www.oracle.com if you need additional information or have any zgu@2364: * questions. zgu@2364: * zgu@2364: */ zgu@2364: zgu@3430: #ifndef SHARE_VM_UTILITIES_ELF_STRING_TABLE_HPP zgu@3430: #define SHARE_VM_UTILITIES_ELF_STRING_TABLE_HPP zgu@2364: never@3156: #if !defined(_WINDOWS) && !defined(__APPLE__) zgu@2364: zgu@2364: #include "memory/allocation.hpp" zgu@2364: #include "utilities/decoder.hpp" zgu@2364: #include "utilities/elfFile.hpp" zgu@2364: zgu@2364: zgu@2364: // The string table represents a string table section in an elf file. zgu@2364: // Whenever there is enough memory, it will load whole string table as zgu@2364: // one blob. Otherwise, it will load string from file when requested. zgu@3900: class ElfStringTable: CHeapObj { zgu@2364: friend class ElfFile; zgu@2364: public: zgu@2364: ElfStringTable(FILE* file, Elf_Shdr shdr, int index); zgu@2364: ~ElfStringTable(); zgu@2364: zgu@2364: // section index zgu@2364: int index() { return m_index; }; zgu@2364: zgu@2364: // get string at specified offset zgu@3430: bool string_at(int offset, char* buf, int buflen); zgu@2364: zgu@2364: // get status code zgu@3430: NullDecoder::decoder_status get_status() { return m_status; }; zgu@2364: zgu@2364: protected: zgu@2364: ElfStringTable* m_next; zgu@2364: zgu@2364: // section index zgu@2364: int m_index; zgu@2364: zgu@2364: // holds complete string table if can zgu@2364: // allocate enough memory zgu@2364: const char* m_table; zgu@2364: zgu@2364: // file contains string table zgu@2364: FILE* m_file; zgu@2364: zgu@2364: // section header zgu@2364: Elf_Shdr m_shdr; zgu@2364: zgu@2364: // error code zgu@3430: NullDecoder::decoder_status m_status; zgu@2364: }; zgu@2364: simonis@6491: #endif // !_WINDOWS && !__APPLE__ zgu@2364: zgu@3430: #endif // SHARE_VM_UTILITIES_ELF_STRING_TABLE_HPP