|
Packit Service |
97d2fb |
/* Resolve symbol values through .opd function descriptors.
|
|
Packit Service |
97d2fb |
Copyright (C) 2013 Red Hat, Inc.
|
|
Packit Service |
97d2fb |
This file is part of elfutils.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
This file is free software; you can redistribute it and/or modify
|
|
Packit Service |
97d2fb |
it under the terms of either
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
97d2fb |
Software Foundation; either version 3 of the License, or (at
|
|
Packit Service |
97d2fb |
your option) any later version
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
or
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
* the GNU General Public License as published by the Free
|
|
Packit Service |
97d2fb |
Software Foundation; either version 2 of the License, or (at
|
|
Packit Service |
97d2fb |
your option) any later version
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
or both in parallel, as here.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit Service |
97d2fb |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
97d2fb |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
97d2fb |
General Public License for more details.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
You should have received copies of the GNU General Public License and
|
|
Packit Service |
97d2fb |
the GNU Lesser General Public License along with this program. If
|
|
Packit Service |
97d2fb |
not, see <http://www.gnu.org/licenses/>. */
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
97d2fb |
# include <config.h>
|
|
Packit Service |
97d2fb |
#endif
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#define BACKEND ppc64_
|
|
Packit Service |
97d2fb |
#include "libebl_CPU.h"
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Resolve a function descriptor if addr points into the .opd section.
|
|
Packit Service |
97d2fb |
The .opd section contains function descriptors consisting of 3 addresses.
|
|
Packit Service |
97d2fb |
function, toc and chain. We are just interested in the first.
|
|
Packit Service |
97d2fb |
http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html#FUNC-DES
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Returns true if the given address could be resolved, false otherwise.
|
|
Packit Service |
97d2fb |
*/
|
|
Packit Service |
97d2fb |
bool
|
|
Packit Service |
97d2fb |
ppc64_resolve_sym_value (Ebl *ebl, GElf_Addr *addr)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
if (ebl->fd_data != NULL && *addr >= ebl->fd_addr
|
|
Packit Service |
97d2fb |
&& *addr + sizeof (Elf64_Addr) <= ebl->fd_addr + ebl->fd_data->d_size)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (ebl->elf, &ehdr_mem);
|
|
Packit Service |
97d2fb |
if (ehdr != NULL)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
Elf_Data opd_in, opd_out;
|
|
Packit Service |
97d2fb |
opd_in.d_buf = ebl->fd_data->d_buf + (*addr - ebl->fd_addr);
|
|
Packit Service |
97d2fb |
opd_out.d_buf = addr;
|
|
Packit Service |
97d2fb |
opd_out.d_size = opd_in.d_size = sizeof (Elf64_Addr);
|
|
Packit Service |
97d2fb |
opd_out.d_type = opd_in.d_type = ELF_T_ADDR;
|
|
Packit Service |
97d2fb |
if (elf64_xlatetom (&opd_out, &opd_in,
|
|
Packit Service |
97d2fb |
ehdr->e_ident[EI_DATA]) != NULL)
|
|
Packit Service |
97d2fb |
return true;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
return false;
|
|
Packit Service |
97d2fb |
}
|