src/hotspot/share/utilities/elfStringTable.hpp
changeset 48975 2c35fd3c5789
parent 47216 71c04702a3d5
child 53244 9807daeb47c4
equal deleted inserted replaced
48974:66173ef5fbbf 48975:2c35fd3c5789
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    35 // The string table represents a string table section in an elf file.
    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
    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.
    37 // one blob. Otherwise, it will load string from file when requested.
    38 class ElfStringTable: CHeapObj<mtInternal> {
    38 class ElfStringTable: CHeapObj<mtInternal> {
    39   friend class ElfFile;
    39   friend class ElfFile;
    40  public:
    40 private:
    41   ElfStringTable(FILE* file, Elf_Shdr shdr, int index);
    41   ElfStringTable*   _next;
       
    42   int               _index;     // section index
       
    43   ElfSection        _section;
       
    44   FILE* const       _fd;
       
    45   NullDecoder::decoder_status _status;
       
    46 
       
    47 public:
       
    48   ElfStringTable(FILE* const file, Elf_Shdr& shdr, int index);
    42   ~ElfStringTable();
    49   ~ElfStringTable();
    43 
    50 
    44   // section index
    51   // section index
    45   int index() { return m_index; };
    52   int index() const { return _index; };
    46 
    53 
    47   // get string at specified offset
    54   // get string at specified offset
    48   bool string_at(int offset, char* buf, int buflen);
    55   bool string_at(size_t offset, char* buf, int buflen);
    49 
    56 
    50   // get status code
    57   // get status code
    51   NullDecoder::decoder_status get_status() { return m_status; };
    58   NullDecoder::decoder_status get_status() const {
       
    59     return _status;
       
    60   }
    52 
    61 
    53  protected:
    62 private:
    54   ElfStringTable*        m_next;
    63   void set_next(ElfStringTable* next) {
       
    64     _next = next;
       
    65   }
    55 
    66 
    56   // section index
    67   ElfStringTable* next() const {
    57   int                      m_index;
    68     return _next;
    58 
    69   }
    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 };
    70 };
    72 
    71 
    73 #endif // !_WINDOWS && !__APPLE__
    72 #endif // !_WINDOWS && !__APPLE__
    74 
    73 
    75 #endif // SHARE_VM_UTILITIES_ELF_STRING_TABLE_HPP
    74 #endif // SHARE_VM_UTILITIES_ELF_STRING_TABLE_HPP