binutils-gdb/libctf
Nick Alcock ee87f50b8d libctf: always name nameless types "", never NULL
The ctf_type_name_raw and ctf_type_aname_raw functions, which return the
raw, unadorned name of CTF types, have one unfortunate wrinkle: they
return NULL not only on error but when returning the name of types
without a name in writable dicts.  This was unintended: it not only
makes it impossible to reliably tell if a given call to
ctf_type_name_raw failed (due to a bad string offset say), but also
complicates all its callers, who now have to check for both NULL and "".

The written-out form of CTF has no concept of a NULL pointer instead of
a string: all null strings are strtab offset 0, "".  So the more we can
do to remove this distinction from the writable form, the less complex
the rest of our code needs to be.

Armour against NULL in multiple places, arranging to return "" from
ctf_type_name_raw if offset 0 is passed in, and removing a risky
optimization from ctf_str_add* that avoided doing anything if a NULL was
passed in: this added needless irregularity to the functions' API
surface, since "" and NULL should be treated identically, and in the
case of ctf_str_add_ref, we shouldn't skip adding the passed-in REF to
the list of references to be updated no matter what the content of the
string happens to be.

This means we can simplify the deduplicator a tiny bit, also fixing a
bug (latent when used by ld) where if the input dict was writable,
we failed to realise when types were nameless and could end up creating
deeply unhelpful synthetic forwards with no name, which we just banned
a few commits ago, so the link failed.

libctf/ChangeLog
2021-01-27  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-string.c (ctf_str_add): Treat adding a NULL as adding "".
	(ctf_str_add_ref): Likewise.
	(ctf_str_add_external): Likewise.
	* ctf-types.c (ctf_type_name_raw): Always return "" for offset 0.
	* ctf-dedup.c (ctf_dedup_multiple_input_dicts): Don't armour
	against NULL name.
	(ctf_dedup_maybe_synthesize_forward): Likewise.
2021-02-04 16:01:53 +00:00
..
testsuite libctf, ld: fix symtypetab and var section population under ld -r 2021-02-04 16:01:53 +00:00
.gitignore
aclocal.m4 Implement a workaround for GNU mak jobserver 2021-01-12 05:45:44 -08:00
ChangeLog libctf: always name nameless types "", never NULL 2021-02-04 16:01:53 +00:00
ChangeLog-2020 libctf: fix old ChangeLog typo 2021-01-05 14:53:40 +00:00
config.h.in
configure Implement a workaround for GNU mak jobserver 2021-01-12 05:45:44 -08:00
configure.ac Implement a workaround for GNU mak jobserver 2021-01-12 05:45:44 -08:00
ctf-archive.c libctf: remove outdated comment about parent dict importing 2021-01-05 14:53:40 +00:00
ctf-create.c libctf: fix uninitialized variable in symbol serialization error handling 2021-02-04 16:01:53 +00:00
ctf-decl.c libctf, ld: dump enums: generally improve dump formatting 2021-01-05 14:53:39 +00:00
ctf-decls.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-dedup.c libctf: always name nameless types "", never NULL 2021-02-04 16:01:53 +00:00
ctf-dump.c libctf, ld: dump enums: generally improve dump formatting 2021-01-05 14:53:39 +00:00
ctf-endian.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-error.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-hash.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-impl.h libctf, ld: fix symtypetab and var section population under ld -r 2021-02-04 16:01:53 +00:00
ctf-inlines.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-intl.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-labels.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-link.c libctf, ld: fix symtypetab and var section population under ld -r 2021-02-04 16:01:53 +00:00
ctf-lookup.c libctf: rip out dead code handling typedefs with no name 2021-02-04 16:01:53 +00:00
ctf-open-bfd.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-open.c libctf: rip out dead code handling typedefs with no name 2021-02-04 16:01:53 +00:00
ctf-qsort_r.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-sha1.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-sha1.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-string.c libctf: always name nameless types "", never NULL 2021-02-04 16:01:53 +00:00
ctf-subr.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-types.c libctf: always name nameless types "", never NULL 2021-02-04 16:01:53 +00:00
ctf-util.c libctf, include: support unnamed structure members better 2021-01-05 14:53:40 +00:00
elf.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
libctf.ver Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
Makefile.am libctf, testsuite: don't run without a suitable compiler 2021-01-05 17:11:20 +00:00
Makefile.in Regen Makefile.in for jobserver.m4 aclocal.m4 dependency 2021-01-13 22:06:02 +10:30
swap.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30