Hi Aaron,

On Mon, Aug 04, 2025 at 11:24:37PM -0400, Aaron Merey wrote:
> Signed-off-by: Aaron Merey <ame...@redhat.com>
> ---
> v2: Mark elf_getshstrndx as deprecated in SYNOPSIS.
> Add note to HISTORY about reason for introducing elf_getshdrndx.
> Explain how to use with elf_strptr and Elf{32,64}_getshdr.
> 
>  doc/Makefile.am         |   2 +
>  doc/elf_getshdrstrndx.3 | 102 ++++++++++++++++++++++++++++++++++++++++
>  doc/elf_getshstrndx.3   |   1 +
>  3 files changed, 105 insertions(+)
>  create mode 100644 doc/elf_getshdrstrndx.3
>  create mode 100644 doc/elf_getshstrndx.3
> 
> diff --git a/doc/Makefile.am b/doc/Makefile.am
> index d6e3062d..bb61ad39 100644
> --- a/doc/Makefile.am
> +++ b/doc/Makefile.am
> @@ -72,7 +72,9 @@ notrans_dist_man3_MANS= elf32_checksum.3 \
>                       elf_getphdrnum.3 \
>                       elf_getscn.3 \
>                       elf_getshdrnum.3 \
> +                     elf_getshdrstrndx.3 \
>                       elf_getshnum.3 \
> +                     elf_getshstrndx.3 \
>                       elf_hash.3 \
>                       elf_kind.3 \
>                       elf_memory.3 \

OK.

> diff --git a/doc/elf_getshdrstrndx.3 b/doc/elf_getshdrstrndx.3
> new file mode 100644
> index 00000000..293da120
> --- /dev/null
> +++ b/doc/elf_getshdrstrndx.3
> @@ -0,0 +1,102 @@
> +.TH ELF_GETSHDRSTRNDX 3 2025-06-30 "Libelf" "Libelf Programmer's Manual"
> +
> +.SH NAME
> +elf_getshdrstrndx, elf_getshstrndx \- retrieve the section header string 
> table index
> +.SH SYNOPSIS
> +.nf
> +#include <libelf.h>
> +
> +.B int elf_getshdrstrndx("Elf *elf", "size_t *dst");
> +.B int elf_getshstrndx("Elf *elf", "size_t *dst"); (deprecated)
> +.fi

OK.

> +.SH DESCRIPTION
> +The
> +.BR elf_getshdrstrndx ()
> +function retrieves the section header string table index from the ELF 
> descriptor
> +.IR elf ,
> +and stores it in the location pointed to by
> +.IR dst .
> +
> +A section's name can be aquired with

acquired.

> +.BR elf_strptr (3).
> +This function takes the section header string table index from
> +.BR elf_getshdrstrndx ()
> +as well as the
> +.I sh_name
> +field from the section's
> +.I Elf32_Shdr
> +or
> +.I Elf64_Shdr
> +(see
> +.B elf32_getshdr
> +and
> +.BR elf64_getshdr ).
> +
> +This function handles both standard ELF values and extended section indexing.
> +In the latter case, if the section header string table index field of the ELF
> +header contains
> +.B SHN_XINDEX,
> +then the true index is stored in the
> +.B sh_link
> +field of section 0.
> +
> +The function
> +.BR elf_getshstrndx ()
> +is a deprecated alias for
> +.BR elf_getshdrstrndx ()
> +and should not be used in new code (see HISTORY).

OK.

> +.SH PARAMETERS
> +.TP
> +.I elf
> +A pointer to an
> +.B Elf
> +descriptor.  The descriptor must have kind
> +.B ELF_K_ELF .
> +If
> +.I elf
> +is NULL, then this function returns \-1 without setting elf_errno
> +
> +.TP
> +.I dst
> +A pointer to a
> +.B size_t
> +location where the index of the section header string table will be stored.
> +Must not be NULL.

OK.

> +.SH RETURN VALUE
> +Returns 0 on success and stores the section header string table index in
> +.IR dst .
> +Returns \-1 on failure and sets elf_errno (if
> +.I elf
> +is not NULL).

OK.

> +.SH SEE ALSO
> +.BR elf32_getshdr (3),
> +.BR elf64_getshdr (3),
> +.BR elf_strptr (3),
> +.BR libelf (3),
> +.BR elf (5)

OK.

> +.SH ATTRIBUTES
> +.TS
> +allbox;
> +lbx lb lb
> +l l l.
> +Interface    Attribute       Value
> +T{
> +.na
> +.nh
> +.BR elf_getshdrstrndx (),\~elf_getshstrndx ()
> +T}   Thread safety   MT-Safe
> +.TE
> +
> +.SH REPORTING BUGS
> +Report bugs to <elfutils-devel@sourceware.org> or 
> https://sourceware.org/bugzilla/.

OK.

> +.SH HISTORY
> +.B elf_getshdrstrndx
> +first appeared in elfutils 0.142.  This function was added due to 
> elf_getshstrndx
> +return value inconsistencies between different libelf implementations.
> +.B elf_getshdrstrndx
> +was introduced to ensure that 0 is returned on success.

OK.

> diff --git a/doc/elf_getshstrndx.3 b/doc/elf_getshstrndx.3
> new file mode 100644
> index 00000000..22a2251f
> --- /dev/null
> +++ b/doc/elf_getshstrndx.3
> @@ -0,0 +1 @@
> +.so man3/elf_getshdrstrndx.3

OK.

Thanks,

Mark

Reply via email to