1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, 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. |
38 * of the elf file into memory. Otherwise, it will walk the section in file |
38 * of the elf file into memory. Otherwise, it will walk the section in file |
39 * to look up the symbol that nearest the given address. |
39 * to look up the symbol that nearest the given address. |
40 */ |
40 */ |
41 class ElfSymbolTable: public CHeapObj<mtInternal> { |
41 class ElfSymbolTable: public CHeapObj<mtInternal> { |
42 friend class ElfFile; |
42 friend class ElfFile; |
43 public: |
43 private: |
44 ElfSymbolTable(FILE* file, Elf_Shdr shdr); |
44 ElfSymbolTable* _next; |
|
45 |
|
46 // file contains string table |
|
47 FILE* const _fd; |
|
48 |
|
49 // corresponding section |
|
50 ElfSection _section; |
|
51 |
|
52 NullDecoder::decoder_status _status; |
|
53 public: |
|
54 ElfSymbolTable(FILE* const file, Elf_Shdr& shdr); |
45 ~ElfSymbolTable(); |
55 ~ElfSymbolTable(); |
46 |
56 |
47 // search the symbol that is nearest to the specified address. |
57 // search the symbol that is nearest to the specified address. |
48 bool lookup(address addr, int* stringtableIndex, int* posIndex, int* offset, ElfFuncDescTable* funcDescTable); |
58 bool lookup(address addr, int* stringtableIndex, int* posIndex, int* offset, ElfFuncDescTable* funcDescTable); |
49 |
59 |
50 NullDecoder::decoder_status get_status() { return m_status; }; |
60 NullDecoder::decoder_status get_status() const { return _status; }; |
51 |
61 private: |
52 protected: |
62 ElfSymbolTable* next() const { return _next; } |
53 ElfSymbolTable* m_next; |
63 void set_next(ElfSymbolTable* next) { _next = next; } |
54 |
|
55 // holds a complete symbol table section if |
|
56 // can allocate enough memory |
|
57 Elf_Sym* m_symbols; |
|
58 |
|
59 // file contains string table |
|
60 FILE* m_file; |
|
61 |
|
62 // section header |
|
63 Elf_Shdr m_shdr; |
|
64 |
|
65 NullDecoder::decoder_status m_status; |
|
66 |
64 |
67 bool compare(const Elf_Sym* sym, address addr, int* stringtableIndex, int* posIndex, int* offset, ElfFuncDescTable* funcDescTable); |
65 bool compare(const Elf_Sym* sym, address addr, int* stringtableIndex, int* posIndex, int* offset, ElfFuncDescTable* funcDescTable); |
68 }; |
66 }; |
69 |
67 |
70 #endif // !_WINDOWS and !__APPLE__ |
68 #endif // !_WINDOWS and !__APPLE__ |