binutils-gdb/libctf
Nick Alcock 149ce5c263 libctf: replace 'pending refs' abstraction
A few years ago we introduced a 'pending refs' abstraction to fix one
problem: serializing a dict, then changing it would tend to corrupt the dict
because the strtab sort we do on strtab writeout (to improve compression
efficiency) would modify the offset of any strings that sorted
lexicographically earlier in the strtab: so we added a new restriction that
all strings are added only at serialization time, and maintained a set of
'pending' refs that were added earlier, whose offsets we could update (like
other refs) at writeout time.

This was in hindsight seriously problematic for maintenance (because
serialization has to traverse all strings in all datatypes in the entire
dict), and has become impossible to sustain now that we can read in existing
dicts, modify them, and reserialize them again.  We really don't want to
have to dig through the entire dict we jut read in just in order to dig out
all its strtab offsets, then *change* it, just for the sake of a sort that
adds a frankly trivial amount of compression efficiency.

Sorting *is* still worthwhile -- but it sacrifices very little to only sort
newly-added portions of the strtab, reusing older portions as necessary.
As a first stage in this, discard the whole "pending refs" abstraction and
replace it with "movable" refs, which are exactly like all other refs
(addresses containing the strtab offset of some string, which are updated
wiht the final strtab offset on serialization) except that we track them in
a reverse dict so that we can move the refs around (which we do whenever we
realloc() a buffer containing a bunch of structure members or something when
we add members to the structure).

libctf/

	* ctf-create.c (ctf_add_enumerator): Call ctf_str_move_refs; add
        a movable ref.
	(ctf_add_member_offset): Likewise.
	* ctf-util.c (ctf_realloc): Delete.
	* ctf-serialize.c (ctf_serialize): No longer use it.  Adjust to
	new fields.
	* ctf-string.c (ctf_str_purge_atom_refs): Purge movable refs.
	(ctf_str_free_atom): Free freeable atoms' strings.
	(ctf_str_create_atoms): Create the movable refs dynhash if needed.
	(ctf_str_free_atoms): Destroy it.
	(CTF_STR_MOVABLE): Switch (back) from ints to flags (see previous
	reversion).  Add new flag.
	(aref_create):  New, populate movable refs if need be.
	(ctf_str_add_ref_internal): Switch back to flags, update refs
	directly for nonprovisional strings (with already-known fixed offsets);
	create refs via aref_create.  Allocate strings only if not within an
	mmapped strtab.
	(ctf_str_add_movable_ref): New.
	(ctf_str_add): Adjust to CTF_STR_* reintroduction.
	(ctf_str_add_external): LIkewise.
	(ctf_str_move_refs): New, move refs via ctf_str_movable_refs
	backpointer.
	(ctf_str_purge_refs): Drop ctf_str_num_refs.
	(ctf_str_update_refs): Fix indentation.
	* ctf-impl.h (struct ctf_str_atom_movable): New.
	(struct ctf_dict.ctf_str_num_refs): Drop.
	(struct ctf_dict.ctf_str_movable_refs): New.
	(ctf_str_add_movable_ref): Declare.
	(ctf_str_move_refs): Likewise.
	(ctf_realloc): Drop.
2024-04-19 16:14:46 +01:00
..
doc Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
testsuite libctf: support addition of types to dicts read via ctf_open() 2024-04-19 16:14:46 +01:00
.gitignore libctf: restructure error handling to reduce relocations 2020-07-22 17:57:20 +01:00
aclocal.m4 mmap: Avoid the sanitizer configure check failure 2024-04-10 03:57:46 -07:00
ChangeLog Add markers for 2.42 branch 2024-01-15 14:42:15 +00:00
ChangeLog-2020 libctf: fix old ChangeLog typo 2021-01-05 14:53:40 +00:00
config.h.in Finalized intl-update patches 2023-11-15 12:53:04 +00:00
configure mmap: Avoid the sanitizer configure check failure 2024-04-10 03:57:46 -07:00
configure.ac mmap: Avoid the sanitizer configure check failure 2024-04-10 03:57:46 -07:00
ctf-archive.c libctf: don't leak the symbol name in the name->type cache 2024-04-19 16:14:45 +01:00
ctf-create.c libctf: replace 'pending refs' abstraction 2024-04-19 16:14:46 +01:00
ctf-decl.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-decls.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-dedup.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-dump.c libctf: rename ctf_dict.ctf_{symtab,strtab} 2024-04-19 16:14:46 +01:00
ctf-endian.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-error.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-hash.c Revert "libctf: do not corrupt strings across ctf_serialize" 2024-04-19 16:14:46 +01:00
ctf-impl.h libctf: replace 'pending refs' abstraction 2024-04-19 16:14:46 +01:00
ctf-inlines.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-intl.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-labels.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-link.c libctf: delete LCTF_DIRTY 2024-04-19 16:14:46 +01:00
ctf-lookup.c libctf: rename ctf_dict.ctf_{symtab,strtab} 2024-04-19 16:14:46 +01:00
ctf-open-bfd.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-open.c libctf: rename ctf_dict.ctf_{symtab,strtab} 2024-04-19 16:14:46 +01:00
ctf-qsort_r.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-serialize.c libctf: replace 'pending refs' abstraction 2024-04-19 16:14:46 +01:00
ctf-sha1.c Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-sha1.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
ctf-string.c libctf: replace 'pending refs' abstraction 2024-04-19 16:14:46 +01:00
ctf-subr.c libctf: fix a comment 2024-04-19 16:14:46 +01:00
ctf-types.c libctf: support addition of types to dicts read via ctf_open() 2024-04-19 16:14:46 +01:00
ctf-util.c libctf: replace 'pending refs' abstraction 2024-04-19 16:14:46 +01:00
elf.h Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
libctf.ver Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
Makefile.am Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
Makefile.in mmap: Avoid the sanitizer configure check failure 2024-04-10 03:57:46 -07:00
NEWS include, libctf, ld: extend variable section to contain functions too 2022-03-23 13:48:32 +00:00
swap.h libctf warnings 2024-04-17 09:24:36 +09:30