ELFTC_STRING_TABLE_DESTROY(3)
πΈ NAME πΈ
okay so bestie, welcome to ELFTC_STRING_TABLE_CREAT(3) β it's from the Library Functions Manual, and it's literally the convenience-routine era for handling ELF string tables. π
The whole squad is elftc_string_table_create, elftc_string_table_destroy, elftc_string_table_from_section, elftc_string_table_image, elftc_string_table_insert, elftc_string_table_lookup, elftc_string_table_remove, and elftc_string_table_to_string β no cap, that's the lineup.
β¨ SYNOPSIS β¨
#include <libelftc.h>
Elftc_String_Table *
elftc_string_table_create(size_t sizehint);
void
elftc_string_table_destroy(Elftc_String_Table *table);
Elftc_String_Table *
elftc_string_table_from_section(Elf_Scn *scn, size_t sizehint);
const char *
elftc_string_table_image(Elftc_String_Table *table, size_t *size);
size_t
elftc_string_table_insert(Elftc_String_Table *table,
const char *string);
size_t
elftc_string_table_lookup(Elftc_String_Table *table,
const char *string);
int
elftc_string_table_remove(Elftc_String_Table *table,
const char *string);
const char *
elftc_string_table_to_string(Elftc_String_Table *table, size_t offset);
π¦ DESCRIPTION π¦
This manual page is the whole docs situation for the convenience routines that handle ELF string tables. It's giving "tiny helper era," and honestly? Obsessed. π
elftc_string_table_create()β creates a new, empty string table. The argumentsizehintis a hint about the expected number of bytes of string data in the table. Ifsizehintis zero, an implementation-defined default gets used instead. πelftc_string_table_destroy()β destroys the previously allocated string table specified by argumenttable, and frees the internal resources allocated for it. Bye bestie, memory reclaimed. πelftc_string_table_from_section()β creates a new string table and initializes it based on the contents of the section specified by argumentscn. This section must be of typeSHT_STRTAB. The argumentsizehintis a hint about the expected number of bytes of string data in the table. If the value ofsizehintis zero, an implementation-default gets used instead. πelftc_string_table_image()β returns a pointer to the ELF representation of the contents of the string table specified by argumenttable. If argumentsizeis notNULL, the size of the ELF representation of the string table is stored in the location pointed to by argumentsize. This function will compact the string table if the table contains deleted strings. The string offsets returned by prior calls toelftc_string_table_insert()andelftc_string_table_lookup()should be treated as invalid after a call to this function. π That part is important, bestie β invalid means invalid.elftc_string_table_insert()β inserts the NUL-terminated string pointed to by argumentstringinto the string table specified by argumenttable, and returns an offset value usable in ELF data structures. Multiple insertions of the same content will return the same offset. The offset returned will remain valid until the next call toelftc_string_table_image(). β¨elftc_string_table_lookup()β looks up the string referenced by argumentstringin the string table specified by argumenttable, and if found, returns the offset associated with the string. The returned offset will be valid until the next call toelftc_string_table_image(). π₯elftc_string_table_remove()β removes the string pointed by argumentstringfrom the string table referenced by argumenttable, if it is present in the string table. π«Άelftc_string_table_to_string()β returns a pointer to the NUL-terminated string residing at argumentoffsetin the string table specified by argumenttable. The value of argumentoffsetshould be one returned by a prior call toelftc_string_table_insert()orelftc_string_table_lookup(). The returned pointer will remain valid until the next call toelftc_string_table_insert()orelftc_string_table_image(). π§
π§ Memory Management π
The libelftc library manages its own memory allocations. The application should not free the pointers returned by the string table functions. Like, not me watching you call free() on these β absolutely do not. π
π IMPLEMENTATION NOTES π
The current implementation is optimized for the case where strings are added to a string table, but rarely removed from it. It's giving "add now, remove never," and that's the vibe it was built for. π
The functions elftc_string_table_insert(), elftc_string_table_lookup(), elftc_string_table_remove() and elftc_string_table_to_string() have O(1) asymptotic behavior. The function elftc_string_table_image() can have O(size) asymptotic behavior, where size denotes the size of the string table. β
π RETURN VALUES π
- Functions
elftc_string_table_create()andelftc_string_table_from_section()return a valid pointer to an opaque structure of typeElftc_String_Tableon success, orNULLin case of an error. π - The function
elftc_string_table_image()returns a pointer to an in-memory representation of an ELF string table on success, orNULLin case of an error. π¦ - Functions
elftc_string_table_insert()andelftc_string_table_lookup()return a non-zero offset on success, or zero in case of an error. π₯ - Function
elftc_string_table_remove()returns a positive value on success, or zero in case of an error. π - Function
elftc_string_table_to_string()returns a valid pointer on success, orNULLin case of an error. πΈ
π SEE ALSO π
and that's the whole page, bestie β this one is from Debian, dated June 27, 2019, and the footer says ELFTC_STRING_TABLE_CREATE(3) (yes, CREAT up top and CREATE down below, iconic chaos, no cap). π«Άβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: libelftc 15.0.0
- Copyright (c) 2012-2013 Joseph Koshy
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms