|
Packit Service |
97d2fb |
/* Get symbol version information at the given index.
|
|
Packit Service |
97d2fb |
Copyright (C) 1999, 2000, 2001, 2002, 2005, 2009, 2014, 2015 Red Hat, Inc.
|
|
Packit Service |
97d2fb |
This file is part of elfutils.
|
|
Packit Service |
97d2fb |
Written by Ulrich Drepper <drepper@redhat.com>, 1999.
|
|
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 |
#include <assert.h>
|
|
Packit Service |
97d2fb |
#include <gelf.h>
|
|
Packit Service |
97d2fb |
#include <string.h>
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#include "libelfP.h"
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
GElf_Versym *
|
|
Packit Service |
97d2fb |
gelf_getversym (Elf_Data *data, int ndx, GElf_Versym *dst)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data;
|
|
Packit Service |
97d2fb |
Elf_Scn *scn;
|
|
Packit Service |
97d2fb |
GElf_Versym *result;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
if (data == NULL)
|
|
Packit Service |
97d2fb |
return NULL;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
if (unlikely (data->d_type != ELF_T_HALF))
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
__libelf_seterrno (ELF_E_INVALID_HANDLE);
|
|
Packit Service |
97d2fb |
return NULL;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* This is the one place where we have to take advantage of the fact
|
|
Packit Service |
97d2fb |
that an `Elf_Data' pointer is also a pointer to `Elf_Data_Scn'.
|
|
Packit Service |
97d2fb |
The interface is broken so that it requires this hack. */
|
|
Packit Service |
97d2fb |
scn = data_scn->s;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* It's easy to handle this type. It has the same size for 32 and
|
|
Packit Service |
97d2fb |
64 bit objects. */
|
|
Packit Service |
97d2fb |
assert (sizeof (GElf_Versym) == sizeof (Elf32_Versym));
|
|
Packit Service |
97d2fb |
assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
rwlock_rdlock (scn->elf->lock);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* The data is already in the correct form. Just make sure the
|
|
Packit Service |
97d2fb |
index is OK. */
|
|
Packit Service |
97d2fb |
if (INVALID_NDX (ndx, GElf_Versym, data))
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
__libelf_seterrno (ELF_E_INVALID_INDEX);
|
|
Packit Service |
97d2fb |
result = NULL;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
else
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
*dst = ((GElf_Versym *) data->d_buf)[ndx];
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
result = dst;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
rwlock_unlock (scn->elf->lock);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return result;
|
|
Packit Service |
97d2fb |
}
|