1.1 --- a/src/share/vm/utilities/elfSymbolTable.cpp Wed Nov 27 16:16:21 2013 -0800 1.2 +++ b/src/share/vm/utilities/elfSymbolTable.cpp Thu Dec 05 19:19:09 2013 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -27,6 +27,7 @@ 1.11 #if !defined(_WINDOWS) && !defined(__APPLE__) 1.12 1.13 #include "memory/allocation.inline.hpp" 1.14 +#include "utilities/elfFuncDescTable.hpp" 1.15 #include "utilities/elfSymbolTable.hpp" 1.16 1.17 ElfSymbolTable::ElfSymbolTable(FILE* file, Elf_Shdr shdr) { 1.18 @@ -68,7 +69,7 @@ 1.19 } 1.20 } 1.21 1.22 -bool ElfSymbolTable::lookup(address addr, int* stringtableIndex, int* posIndex, int* offset) { 1.23 +bool ElfSymbolTable::lookup(address addr, int* stringtableIndex, int* posIndex, int* offset, ElfFuncDescTable* funcDescTable) { 1.24 assert(stringtableIndex, "null string table index pointer"); 1.25 assert(posIndex, "null string table offset pointer"); 1.26 assert(offset, "null offset pointer"); 1.27 @@ -77,19 +78,25 @@ 1.28 return false; 1.29 } 1.30 1.31 - address pc = 0; 1.32 size_t sym_size = sizeof(Elf_Sym); 1.33 assert((m_shdr.sh_size % sym_size) == 0, "check size"); 1.34 int count = m_shdr.sh_size / sym_size; 1.35 if (m_symbols != NULL) { 1.36 for (int index = 0; index < count; index ++) { 1.37 if (STT_FUNC == ELF_ST_TYPE(m_symbols[index].st_info)) { 1.38 - address sym_addr = (address)m_symbols[index].st_value; 1.39 - if (sym_addr < addr && (addr - sym_addr) < *offset) { 1.40 - pc = (address)m_symbols[index].st_value; 1.41 - *offset = (int)(addr - pc); 1.42 + Elf_Word st_size = m_symbols[index].st_size; 1.43 + address sym_addr; 1.44 + if (funcDescTable != NULL && funcDescTable->get_index() == m_symbols[index].st_shndx) { 1.45 + // We need to go another step trough the function descriptor table (currently PPC64 only) 1.46 + sym_addr = funcDescTable->lookup(m_symbols[index].st_value); 1.47 + } else { 1.48 + sym_addr = (address)m_symbols[index].st_value; 1.49 + } 1.50 + if (sym_addr <= addr && (Elf_Word)(addr - sym_addr) < st_size) { 1.51 + *offset = (int)(addr - sym_addr); 1.52 *posIndex = m_symbols[index].st_name; 1.53 *stringtableIndex = m_shdr.sh_link; 1.54 + return true; 1.55 } 1.56 } 1.57 } 1.58 @@ -105,12 +112,19 @@ 1.59 for (int index = 0; index < count; index ++) { 1.60 if (fread(&sym, sym_size, 1, m_file) == 1) { 1.61 if (STT_FUNC == ELF_ST_TYPE(sym.st_info)) { 1.62 - address sym_addr = (address)sym.st_value; 1.63 - if (sym_addr < addr && (addr - sym_addr) < *offset) { 1.64 - pc = (address)sym.st_value; 1.65 - *offset = (int)(addr - pc); 1.66 + Elf_Word st_size = sym.st_size; 1.67 + address sym_addr; 1.68 + if (funcDescTable != NULL && funcDescTable->get_index() == sym.st_shndx) { 1.69 + // We need to go another step trough the function descriptor table (currently PPC64 only) 1.70 + sym_addr = funcDescTable->lookup(sym.st_value); 1.71 + } else { 1.72 + sym_addr = (address)sym.st_value; 1.73 + } 1.74 + if (sym_addr <= addr && (Elf_Word)(addr - sym_addr) < st_size) { 1.75 + *offset = (int)(addr - sym_addr); 1.76 *posIndex = sym.st_name; 1.77 *stringtableIndex = m_shdr.sh_link; 1.78 + return true; 1.79 } 1.80 } 1.81 } else { 1.82 @@ -123,4 +137,4 @@ 1.83 return true; 1.84 } 1.85 1.86 -#endif // _WINDOWS 1.87 +#endif // !_WINDOWS && !__APPLE__