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 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 + +.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 . + +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. + +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. + +.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. + +.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) + +.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/. -- 2.49.0