Hi Aaron,

On Tue, 2025-04-01 at 00:05 -0400, Aaron Merey wrote:
> diff --git a/doc/elf_hash.3 b/doc/elf_hash.3
> new file mode 100644
> index 00000000..6082c8c8
> --- /dev/null
> +++ b/doc/elf_hash.3
> @@ -0,0 +1,49 @@
> +.TH ELF_HASH 3 2025-03-31 "Libelf" "Libelf Programmer's Manual"
> +
> +.SH NAME
> +elf_hash \- Compute the standard ELF hash of a string.
> +
> +.SH SYNOPSIS
> +.nf
> +#include <libelf.h>
> +
> +.BI "int elf_hash(const char *" string ");"

The actual signature is:

  unsigned long int elf_hash (const char *string);

But it looks like the code makes sure only 32bits are relevant.
Which should probably be mentioned below.

> +
> +.SH DESCRIPTION
> +The
> +.B elf_hash
> +function computes the standard ELF hash value for a null-terminated
> +string.  The hash values are typically used in ELF object files for
> +symbol table hashing.  The hash function avoids generating
> +architecture-dependent values and is suitable for use across architectures.

Maybe mention "as used in SHT_HASH sections"?

> +.SH PARAMETERS
> +.TP
> +.I string
> +NULL-terminated string to be hashed.
> +
> +.SH RETURN VALUE
> +This function returns the standard ELF hash value for
> +.IR string .

Mention that the returned hash is a 32bit value?

> +
> +.SH SEE ALSO
> +.BR libelf (3),
> +.BR elf (5)
> +
> +.SH ATTRIBUTES
> +For an explanation of the terms used in this section, see
> +.BR attributes (7).
> +.TS
> +allbox;
> +lbx lb lb
> +l l l.
> +Interface    Attribute       Value
> +T{
> +.na
> +.nh
> +.BR elf_hash ()
> +T}   Thread safety   MT-Safe
> +.TE
> +
> +.SH REPORTING BUGS
> +Report bugs to <elfutils-devel@sourceware.org> or 
> https://sourceware.org/bugzilla/.


Cheers,

Mark

Reply via email to