Hi Aaron, On Mon, 2025-06-30 at 23:12 -0400, Aaron Merey wrote: > Signed-off-by: Aaron Merey <ame...@redhat.com> > --- > doc/Makefile.am | 1 + > doc/elf_strptr.3 | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 73 insertions(+) > create mode 100644 doc/elf_strptr.3 > > diff --git a/doc/Makefile.am b/doc/Makefile.am > index dc4a8b18..f7446872 100644 > --- a/doc/Makefile.am > +++ b/doc/Makefile.am > @@ -86,6 +86,7 @@ notrans_dist_man3_MANS= elf32_checksum.3 \ > elf_rawdata.3 \ > elf_rawfile.3 \ > elf_scnshndx.3 \ > + elf_strptr.3 \ > elf_update.3 \ > elf_version.3 \ > libelf.3
OK. > diff --git a/doc/elf_strptr.3 b/doc/elf_strptr.3 > new file mode 100644 > index 00000000..1cfdf401 > --- /dev/null > +++ b/doc/elf_strptr.3 > @@ -0,0 +1,72 @@ > +.TH ELF_STRPTR 3 2025-06-30 "Libelf" "Libelf Programmer's Manual" > + > +.SH NAME > +elf_strptr \- Return a pointer to a string in a string table section > + > +.SH SYNOPSIS > +.nf > +#include <libelf.h> > + > +.BI "char *elf_strptr(Elf *" elf ", size_t " section_index ", size_t " > offset ");" > +.fi OK. > +.SH DESCRIPTION > +The > +.BR elf_strptr () > +function returns a pointer to a null-terminated string located at > +.I offset > +bytes from the beginning of the string table section identified by > +.IR section_index . > +The section must be of type > +.BR SHT_STRTAB . OK. > +This function validates the provided offset against the size of the string > +table and ensures the string is null-terminated. It transparently handles > +both uncompressed and compressed sections. Maybe explicitly say that the offset is interpreted as if from the uncompressed data? And that the string returned is a valid pointer into the uncompressed data? > + > +If the ELF descriptor is not backed by memory mapping, or the section has > +not been loaded yet, the function will read and initialize the necessary > +data from the file. OK. > +.SH PARAMETERS > +.TP > +.I elf > +Pointer to an ELF descriptor. > + > +.TP > +.I section_index > +The index of the string table section (of type > +.BR SHT_STRTAB ). > + > +.TP > +.I offset > +The byte offset from the beginning of the string table section where > +the desired string is located. OK. > + > +.SH RETURN VALUE > +Returns a pointer to the string within the string table if successful. > +Returns > +.B NULL > +on error. > + > +.SH SEE ALSO > +.BR elf (3), > +.BR elf_getscn (3), > +.BR libelf (3), > +.BR elf (5) Maybe add elf32/64_getshdr and gelf_getsym as examples of sh_name (.shstrtab) or st_name (.strtab) getting name strings? > + > +.SH ATTRIBUTES > +.TS > +allbox; > +lbx lb lb > +l l l. > +Interface Attribute Value > +T{ > +.na > +.nh > +.BR elf_strptr () > +T} Thread safety MT-Safe > +.TE > + > +.SH REPORTING BUGS > +Report bugs to <elfutils-devel@sourceware.org> or > https://sourceware.org/bugzilla/. OK. Thanks, Mark