\" $NetBSD: gelf_getshdr.3,v 1.6 2024/03/03 17:37:34 christos Exp $
\"
\" Copyright (c) 2006,2008 Joseph Koshy. All rights reserved.
\"
\" Redistribution and use in source and binary forms, with or without
\" modification, are permitted provided that the following conditions
\" are met:
\" 1. Redistributions of source code must retain the above copyright
\" notice, this list of conditions and the following disclaimer.
\" 2. Redistributions in binary form must reproduce the above copyright
\" notice, this list of conditions and the following disclaimer in the
\" documentation and/or other materials provided with the distribution.
\"
\" This software is provided by Joseph Koshy ``as is'' and
\" any express or implied warranties, including, but not limited to, the
\" implied warranties of merchantability and fitness for a particular purpose
\" are disclaimed. in no event shall Joseph Koshy be liable
\" for any direct, indirect, incidental, special, exemplary, or consequential
\" damages (including, but not limited to, procurement of substitute goods
\" or services; loss of use, data, or profits; or business interruption)
\" however caused and on any theory of liability, whether in contract, strict
\" liability, or tort (including negligence or otherwise) arising in any way
\" out of the use of this software, even if advised of the possibility of
\" such damage.
\"
\" Id: gelf_getshdr.3 3958 2022-03-12 14:31:32Z jkoshy
\"
Dd August 27, 2006
Dt GELF_GETSHDR 3
Os
Sh NAME
Nm elf32_getshdr ,
Nm elf64_getshdr ,
Nm gelf_getshdr
Nd retrieve the class-dependent section header
Sh LIBRARY
Lb libelf
Sh SYNOPSIS
In libelf.h
Ft "Elf32_Shdr *"
Fn elf32_getshdr "Elf_Scn *scn"
Ft "Elf64_Shdr *"
Fn elf64_getshdr "Elf_Scn *scn"
In gelf.h
Ft "GElf_Shdr *"
Fn gelf_getshdr "Elf_Scn *scn" "GElf_Shdr *shdr"
Sh DESCRIPTION
These functions return a pointer to the ELF Section Header data
structure associated with section descriptor
Fa scn .
Pp
Function
Fn elf32_getshdr
retrieves a pointer to an
Vt Elf32_Shdr
structure.
Section descriptor
Fa scn
must be associated with an ELF descriptor of class
Dv ELFCLASS32 .
Pp
Function
Fn elf64_getshdr
retrieves a pointer to an
Vt Elf64_Shdr
structure.
Section descriptor
Fa scn
must be associated with an ELF descriptor of class
Dv ELFCLASS64 .
Pp
Function
Fn gelf_getshdr
copies the values in the section header associated with argument
Fa scn
to the structure pointed to be argument
Fa dst .
The
Vt GElf_Shdr
data structure is described in
Xr gelf 3 .
Sh RETURN VALUES
Functions
Fn elf32_getshdr
and
Fn elf64_getshdr
return a valid pointer to the appropriate section header on success
or
Dv NULL
if an error was encountered.
Pp
Function
Fn gelf_getshdr
returns argument
Fa dst
if successful, or
Dv NULL
if an error was encountered.
Sh ERRORS
These functions may fail with the following errors:
Bl -tag -width "[ELF_E_RESOURCE]"
It Bq Er ELF_E_ARGUMENT
Arguments
Fa scn
or
Fa shdr
were
Dv NULL .
It Bq Er ELF_E_ARGUMENT
Argument
Fa scn
was not associated a descriptor for an ELF object.
It Bq Er ELF_E_CLASS
The ELF class associated with the section descriptor
Fa scn
did not match the class expected by the API.
El
Sh SEE ALSO
Xr elf 3 ,
Xr elf_getscn 3 ,
Xr gelf 3 ,
Xr gelf_update_shdr 3