binutils-gdb/libctf
Nick Alcock 5de9eada3b libctf: teach ctf_add_type how forwards work
This machinery has been broken for as long as Solaris has existed.
Forwards are meant to encode "struct foo;", "enum foo;" or "union
foo;".  Obviously these all exist in distinct namespaces, so forwards
store the type kind they forward to in their ctt_type member
(which makes conceptual sense if you squint at it).  The addition
machinery uses this to promote forwards to the appropriate type as
needed.

Unfortunately ctf_add_type does not: it checks the global namespace
(which is always wrong), and so fails with a spurious conflict if you
have, say, a typedef and then a forward comes along with the same name,
even if it's a forward to something like a struct.  (This was observed
with <libio.h>, which has "struct _IO_FILE;" and also
"typedef struct _IO_FILE _IO_FILE").  We should look at the recorded
type kind and look in the appropriate namespace.   We should also,
when creating the forward in the new container, use that type kind,
rather than just defaulting to CTF_K_STRUCT and hoping that what
eventually comes along is a struct.

This bug is as old as the first implementation of ctf_add_type in
Solaris.  But we also want a new feature for the linker, closely-related
and touching the same code so we add it here: not only do we want a
forward followed by a struct/union/enum to promote the forward, but
we want want a struct/union/enum followed by a forward to act as a NOP
and return the existing type, because when we're adding many files
in succession to a target link, there will often be already-promoted
forwards (in the shape of a struct/union/enum) that want to unify
with duplicate forwards coming from other object files.

v5: fix tabdamage.

libctf/
	* ctf-create.c (ctf_add_type): Look up and use the forwarded-to
	type kind.  Allow forwards to unify with pre-existing structs/
	unions/enums.
2019-10-03 17:04:55 +01:00
..
aclocal.m4 libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ChangeLog libctf: teach ctf_add_type how forwards work 2019-10-03 17:04:55 +01:00
config.h.in libctf: work on platforms without O_CLOEXEC. 2019-06-04 17:05:08 +01:00
configure Regenerate with approved autotools version 2019-06-14 10:30:35 +09:30
configure.ac libctf: work on platforms without O_CLOEXEC. 2019-06-04 17:05:08 +01:00
ctf-archive.c libctf: write CTF files to memory, and CTF archives to fds 2019-10-03 17:04:55 +01:00
ctf-create.c libctf: teach ctf_add_type how forwards work 2019-10-03 17:04:55 +01:00
ctf-decl.c libctf: core type lookup 2019-05-28 17:08:14 +01:00
ctf-decls.h libctf: avoid strndup 2019-06-07 13:46:39 +01:00
ctf-dump.c libctf: dump: check the right error values when dumping functions 2019-10-03 17:04:55 +01:00
ctf-endian.h libctf: make it compile for old glibc 2019-10-03 17:04:55 +01:00
ctf-error.c libctf: add linking of the variable section 2019-10-03 17:04:55 +01:00
ctf-hash.c libctf: map from old to corresponding newly-added types in ctf_add_type 2019-10-03 17:04:55 +01:00
ctf-impl.h libctf: add CU-mapping machinery 2019-10-03 17:04:55 +01:00
ctf-labels.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-link.c libctf: add CU-mapping machinery 2019-10-03 17:04:55 +01:00
ctf-lookup.c libctf: introduce ctf_func_type_{info,args}, ctf_type_aname_raw 2019-07-18 20:53:57 +01:00
ctf-open-bfd.c libctf, bfd: fix ctf_bfdopen_ctfsect opening symbol and string sections 2019-10-03 17:04:55 +01:00
ctf-open.c libctf: add CU-mapping machinery 2019-10-03 17:04:55 +01:00
ctf-qsort_r.c libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
ctf-string.c libctf: support getting strings from the ELF strtab 2019-10-03 17:04:55 +01:00
ctf-subr.c libctf: drop mmap()-based CTF data allocator 2019-06-21 13:04:02 +01:00
ctf-types.c libctf: Add iteration over non-root types 2019-10-03 17:04:55 +01:00
ctf-util.c libctf: deduplicate and sort the string table 2019-07-01 11:05:59 +01:00
elf.h
Makefile.am libctf: add the ctf_link machinery 2019-10-03 17:04:55 +01:00
Makefile.in libctf: add the ctf_link machinery 2019-10-03 17:04:55 +01:00
swap.h libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00