Hi Aaron, On Mon, Jun 30, 2025 at 11:12:27PM -0400, Aaron Merey wrote: > Signed-off-by: Aaron Merey <ame...@redhat.com> > --- > doc/Makefile.am | 1 + > doc/elf_newscn.3 | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 71 insertions(+) > create mode 100644 doc/elf_newscn.3 > > diff --git a/doc/Makefile.am b/doc/Makefile.am > index 97aac570..022906bb 100644 > --- a/doc/Makefile.am > +++ b/doc/Makefile.am > @@ -80,6 +80,7 @@ notrans_dist_man3_MANS= elf32_checksum.3 \ > elf_memory.3 \ > elf_ndxscn.3 \ > elf_newdata.3 \ > + elf_newscn.3 \ > elf_update.3 \ > elf_version.3 \ > libelf.3
OK. > diff --git a/doc/elf_newscn.3 b/doc/elf_newscn.3 > new file mode 100644 > index 00000000..c53cd4ef > --- /dev/null > +++ b/doc/elf_newscn.3 > @@ -0,0 +1,70 @@ > +.TH ELF_NEWSCN 3 2025-06-30 "Libelf" "Libelf Programmer's Manual" > + > +.SH NAME > +elf_newscn \- create a new section for an ELF descriptor > + > +.SH SYNOPSIS > +.nf > +#include <libelf.h> > + > +.BI "void elf_fill(int " fill ");" ? Elf_Scn *elf_newscn(Elf *elf); > +.SH DESCRIPTION > +The > +.BR elf_newscn () > +function creates a new section descriptor for the ELF descriptor > +.I elf. > + > +Each call to > +.BR elf_newscn () > +appends a new section to the internal list of sections for the > +ELF descriptor. It also creates a corresponding empty section header, > +which is zero-initialized and marked dirty. If the elf didn't have any sections yet, elf_newscn creates the zero section, but returns a new first section. The zero section is special and doesn't have any section data associated with it. > +A newly created section has no name or type and must be properly initialized > +before calling > +.BR elf_update (). > +Use > +.BR elf_getshdr () elf32_getshdr or elf64_getshdr. > +to obtain the section header structure, then populate the required fields. > +Use > +.BR elf_newdata () > +to associate one or more data buffers with the new section. > + > +The section with index 0 (the null section) is reserved and cannot have > +data added to it. Right. Also elf_newscn will never return it (see above). > +.SH PARAMETERS > +.TP > +.I elf > +An ELF descriptor in ELF_C_WRITE or ELF_C_RDWR mode. Are you sure? I believe you can always call elf_newscn and it will add internal data as if the Elf had a new section. You cannot write it out with elf_update though. The Elf does need to have an Ehdr before calling elf_newscn though. > + > +.SH RETURN VALUE > +On success, > +.BR elf_newscn () > +returns a pointer to a new section descriptor. On failure, it returns NULL. and sets elf_errno. If elf is NULL, failure is returned and elf_errno is not (re)set. > + > +.SH SEE ALSO > +.BR elf_getshdr (3), elf32_getshdr elf64_getshdr > +.BR elf_getdata (3), > +.BR elf_newdata (3), > +.BR elf_update (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_newscn () > +T} Thread safety MT-Safe > +.TE > + > +.SH REPORTING BUGS > +Report bugs to <elfutils-devel@sourceware.org> or > https://sourceware.org/bugzilla/. OK. Thanks, Mark