Hi Aaron,
On Wed, 2025-12-31 at 21:50 -0500, Aaron Merey wrote:
> Signed-off-by: Aaron Merey <[email protected]>
> ---
> doc/Makefile.am | 1 +
> doc/gelf_getsymshndx.3 | 119 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 120 insertions(+)
> create mode 100644 doc/gelf_getsymshndx.3
>
> diff --git a/doc/Makefile.am b/doc/Makefile.am
> index 928c38a8..d6e7b11a 100644
> --- a/doc/Makefile.am
> +++ b/doc/Makefile.am
> @@ -99,6 +99,7 @@ notrans_dist_man3_MANS= elf32_checksum.3 \
> gelf_getrel.3 \
> gelf_getrela.3 \
> gelf_getsym.3 \
> + gelf_getsymshndx.3 \
> gelf_getversym.3 \
> gelf_getverdef.3 \
> gelf_getverdaux.3 \
OK.
> diff --git a/doc/gelf_getsymshndx.3 b/doc/gelf_getsymshndx.3
> new file mode 100644
> index 00000000..743cefb3
> --- /dev/null
> +++ b/doc/gelf_getsymshndx.3
> @@ -0,0 +1,119 @@
> +.TH GELF_GETSYMSHNDX 3 2025-12-30 "Libelf" "Libelf Programmer's Manual"
> +
> +.SH NAME
> +gelf_getsymshndx \- Retrieve symbol information and separate section index
> +from the symbol table at the given index.
> +
> +.SH SYNOPSIS
> +.nf
> +.B #include <gelf.h>
> +
> +.BI "GElf_Sym *gelf_getsymshndx (Elf_Data *" symdata ", Elf_Data *"
> shndxdata ", int " ndx ", GElf_Sym *" sym ", Elf32_Word *" xshndx ");"
OK.
> +.SH DESCRIPTION
> +This function retrieves the symbol information for a symbol at index
> +.I ndx
> +in
> +.I symdata
> +of a section with type
> +.B SHT_SYMTAB
> +and stores it in
> +.IR sym .
Maybe mention how to find the size of the table?
And that both tables should have the same number of entries?
> +This function also retrieves the symbol's extended section index from
> +.B shndxdata
> +of a section with type
> +.BR SHT_SYMTAB_SHNDX
> +and stores it in
> +.IR xshndx .
> +
> +A
> +.B SHT_SYMTAB_SHNDX
> +section is present in ELF binaries when the number of sections is too large
> to
> +be represented as an unsigned 16-bit value. In this case the
> +.B st_shndx
> +field of a
> +.B GElf_Sym
> +will be set to
> +.B SHN_XINDEX
> +to indicate that the symbol's section index can be found in the
> +.B SHT_SYMTAB_SHNDX
> +section.
> +.I shndxdata
> +for this section can be acquired using
> +.BR elf_scnshndx (3),
> +.BR elf_getscn (3),
> +and
> +.BR elf_getdata (3).
OK.
> +.SH PARAMETERS
> +.TP
> +.I symdata
> +Pointer to
> +.B Elf_Data
> +for a
> +.B SHT_SYMTAB
> +section.
>
> +.TP
> +.I shndxdata
> +Pointer to
> +.B Elf_Data
> +for a
> +.B SHT_SYMTAB_SHNDX
> +section.
May be NULL.
> +.TP
> +.I ndx
> +Zero\-based index of the symbol table entry in
> +.B symdata
> +and extended section index entry in
> +.BR shndxdata .
> +
> +.TP
> +.I sym
> +Pointer to a caller\-provided
> +.B GElf_Sym
> +structure for storing the symbol table entry. Must not be NULL.
> +
> +.TP
> +.I xshndx
> +Pointer to a caller\-provided
> +.B Elf32_Word
> +for storing the extended section index associated with the symbol. May
> +be NULL.
OK.
> +.SH RETURN VALUE
> +On success, this function updates
> +.I dst
> +and
> +.I sym
> +(if not NULL) returns
> +.IR sym .
> +On failure, it returns NULL and sets elf_errno. If
> +.I symdata
> +is NULL, then NULL is returned and elf_errno is not set.
xshndx is only set (when not NULL) if a non-NULL shndxdata was
provided?
> +.SH SEE ALSO
> +.BR elf_getdata (3),
> +.BR elf_getscn (3),
> +.BR elf_scnshndx (3),
> +.BR gelf_update_symshndx (3),
> +.BR libelf (3),
> +.BR elf (5)
gelf_getsym maybe?
> +.SH ATTRIBUTES
> +.TS
> +allbox;
> +lbx lb lb
> +l l l.
> +Interface Attribute Value
> +T{
> +.na
> +.nh
> +.BR gelf_getsymshndx ()
> +T} Thread safety MT-Safe
> +.TE
> +
> +.SH REPORTING BUGS
> +Report bugs to <[email protected]> or
> https://sourceware.org/bugzilla/.
OK.
Thanks,
Mark