]>
git.ipfire.org Git - thirdparty/elfutils.git/blob - libelf/gelf_getshdr.c
1 /* Return section header.
2 Copyright (C) 1998, 1999, 2000, 2002 Red Hat, Inc.
3 Written by Ulrich Drepper <drepper@redhat.com>, 1998.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 2.
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. */
29 gelf_getshdr (scn
, dst
)
33 GElf_Shdr
*result
= NULL
;
40 __libelf_seterrno (ELF_E_INVALID_OPERAND
);
44 rwlock_rdlock (scn
->elf
->lock
);
46 if (scn
->elf
->class == ELFCLASS32
)
48 /* Copy the elements one-by-one. */
49 Elf32_Shdr
*shdr
= scn
->shdr
.e32
?: INTUSE(elf32_getshdr
) (scn
);
53 __libelf_seterrno (ELF_E_INVALID_OPERAND
);
58 dst->name = shdr->name
74 Elf64_Shdr
*shdr
= scn
->shdr
.e64
?: INTUSE(elf64_getshdr
) (scn
);
78 __libelf_seterrno (ELF_E_INVALID_OPERAND
);
82 /* We only have to copy the data. */
83 result
= memcpy (dst
, shdr
, sizeof (GElf_Shdr
));
87 rwlock_unlock (scn
->elf
->lock
);