src/share/vm/utilities/elfSymbolTable.cpp
Print this page
rev 5729 : 8019929: PPC64 (part 107): Extend ELF-decoder to support PPC64 function descriptor tables
*** 1,7 ****
/*
! * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 25,34 ****
--- 25,35 ----
#include "precompiled.hpp"
#if !defined(_WINDOWS) && !defined(__APPLE__)
#include "memory/allocation.inline.hpp"
+ #include "utilities/elfFuncDescTable.hpp"
#include "utilities/elfSymbolTable.hpp"
ElfSymbolTable::ElfSymbolTable(FILE* file, Elf_Shdr shdr) {
assert(file, "null file handle");
m_symbols = NULL;
*** 66,97 ****
if (m_next != NULL) {
delete m_next;
}
}
! bool ElfSymbolTable::lookup(address addr, int* stringtableIndex, int* posIndex, int* offset) {
assert(stringtableIndex, "null string table index pointer");
assert(posIndex, "null string table offset pointer");
assert(offset, "null offset pointer");
if (NullDecoder::is_error(m_status)) {
return false;
}
- address pc = 0;
size_t sym_size = sizeof(Elf_Sym);
assert((m_shdr.sh_size % sym_size) == 0, "check size");
int count = m_shdr.sh_size / sym_size;
if (m_symbols != NULL) {
for (int index = 0; index < count; index ++) {
if (STT_FUNC == ELF_ST_TYPE(m_symbols[index].st_info)) {
! address sym_addr = (address)m_symbols[index].st_value;
! if (sym_addr < addr && (addr - sym_addr) < *offset) {
! pc = (address)m_symbols[index].st_value;
! *offset = (int)(addr - pc);
*posIndex = m_symbols[index].st_name;
*stringtableIndex = m_shdr.sh_link;
}
}
}
} else {
long cur_pos;
--- 67,104 ----
if (m_next != NULL) {
delete m_next;
}
}
! bool ElfSymbolTable::lookup(address addr, int* stringtableIndex, int* posIndex, int* offset, ElfFuncDescTable* funcDescTable) {
assert(stringtableIndex, "null string table index pointer");
assert(posIndex, "null string table offset pointer");
assert(offset, "null offset pointer");
if (NullDecoder::is_error(m_status)) {
return false;
}
size_t sym_size = sizeof(Elf_Sym);
assert((m_shdr.sh_size % sym_size) == 0, "check size");
int count = m_shdr.sh_size / sym_size;
if (m_symbols != NULL) {
for (int index = 0; index < count; index ++) {
if (STT_FUNC == ELF_ST_TYPE(m_symbols[index].st_info)) {
! Elf_Word st_size = m_symbols[index].st_size;
! address sym_addr;
! if (funcDescTable != NULL && funcDescTable->get_index() == m_symbols[index].st_shndx) {
! // We need to go another step trough the function descriptor table (currently PPC64 only)
! sym_addr = funcDescTable->lookup(m_symbols[index].st_value);
! } else {
! sym_addr = (address)m_symbols[index].st_value;
! }
! if (sym_addr <= addr && (Elf_Word)(addr - sym_addr) < st_size) {
! *offset = (int)(addr - sym_addr);
*posIndex = m_symbols[index].st_name;
*stringtableIndex = m_shdr.sh_link;
+ return true;
}
}
}
} else {
long cur_pos;
*** 103,118 ****
Elf_Sym sym;
for (int index = 0; index < count; index ++) {
if (fread(&sym, sym_size, 1, m_file) == 1) {
if (STT_FUNC == ELF_ST_TYPE(sym.st_info)) {
! address sym_addr = (address)sym.st_value;
! if (sym_addr < addr && (addr - sym_addr) < *offset) {
! pc = (address)sym.st_value;
! *offset = (int)(addr - pc);
*posIndex = sym.st_name;
*stringtableIndex = m_shdr.sh_link;
}
}
} else {
m_status = NullDecoder::file_invalid;
return false;
--- 110,132 ----
Elf_Sym sym;
for (int index = 0; index < count; index ++) {
if (fread(&sym, sym_size, 1, m_file) == 1) {
if (STT_FUNC == ELF_ST_TYPE(sym.st_info)) {
! Elf_Word st_size = sym.st_size;
! address sym_addr;
! if (funcDescTable != NULL && funcDescTable->get_index() == sym.st_shndx) {
! // We need to go another step trough the function descriptor table (currently PPC64 only)
! sym_addr = funcDescTable->lookup(sym.st_value);
! } else {
! sym_addr = (address)sym.st_value;
! }
! if (sym_addr <= addr && (Elf_Word)(addr - sym_addr) < st_size) {
! *offset = (int)(addr - sym_addr);
*posIndex = sym.st_name;
*stringtableIndex = m_shdr.sh_link;
+ return true;
}
}
} else {
m_status = NullDecoder::file_invalid;
return false;
*** 121,126 ****
fseek(m_file, cur_pos, SEEK_SET);
}
return true;
}
! #endif // _WINDOWS
--- 135,140 ----
fseek(m_file, cur_pos, SEEK_SET);
}
return true;
}
! #endif // !_WINDOWS && !__APPLE__