zgu@2364: /* zgu@2364: * Copyright (c) 1997, 2010, 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@2364: #ifndef __ELF_STRING_TABLE_HPP zgu@2364: #define __ELF_STRING_TABLE_HPP zgu@2364: zgu@2364: #ifndef _WINDOWS 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@2364: zgu@2364: #define MAX_SYMBOL_LEN 256 zgu@2364: zgu@2364: 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@2364: const char* string_at(int offset); zgu@2364: zgu@2364: // get status code zgu@2364: Decoder::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: // buffer for reading individual string zgu@2364: char m_symbol[MAX_SYMBOL_LEN]; zgu@2364: zgu@2364: // error code zgu@2364: Decoder::decoder_status m_status; zgu@2364: }; zgu@2364: zgu@2364: #endif // _WINDOWS zgu@2364: zgu@2364: #endif // __ELF_STRING_TABLE_HPP zgu@2364: