1 /* Get required symbol version information at the given offset.
2 Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
3 Written by Ulrich Drepper <drepper@redhat.com>, 1999.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
30 gelf_getverneed (data, offset, dst)
40 if (unlikely (data->d_type != ELF_T_VNEED))
42 __libelf_seterrno (ELF_E_INVALID_HANDLE);
46 /* It's easy to handle this type. It has the same size for 32 and
47 64 bit objects. And fortunately the `ElfXXX_Vernaux' records
48 also have the same size. */
49 assert (sizeof (GElf_Verneed) == sizeof (Elf32_Verneed));
50 assert (sizeof (GElf_Verneed) == sizeof (Elf64_Verneed));
51 assert (sizeof (GElf_Verneed) == sizeof (Elf32_Vernaux));
52 assert (sizeof (GElf_Verneed) == sizeof (Elf64_Vernaux));
54 rwlock_rdlock (((Elf_Data_Scn *) data)->s->elf->lock);
56 /* The data is already in the correct form. Just make sure the
58 if (unlikely (offset < 0)
59 || unlikely (offset + sizeof (GElf_Verneed) > data->d_size)
60 || unlikely (offset % sizeof (GElf_Verneed) != 0))
62 __libelf_seterrno (ELF_E_OFFSET_RANGE);
66 result = (GElf_Verneed *) memcpy (dst, (char *) data->d_buf + offset,
67 sizeof (GElf_Verneed));
69 rwlock_unlock (((Elf_Data_Scn *) data)->s->elf->lock);