binutils-gdb/libctf
Nick Alcock 2f6ecaed66 libctf, binutils: support CTF archives like objdump
objdump and readelf have one major CTF-related behavioural difference:
objdump can read .ctf sections that contain CTF archives and extract and
dump their members, while readelf cannot.  Since the linker often emits
CTF archives, this means that readelf intermittently and (from the
user's perspective) randomly fails to read CTF in files that ld emits,
with a confusing error message wrongly claiming that the CTF content is
corrupt.  This is purely because the archive-opening code in libctf was
needlessly tangled up with the BFD code, so readelf couldn't use it.

Here, we disentangle it, moving ctf_new_archive_internal from
ctf-open-bfd.c into ctf-archive.c and merging it with the helper
function in ctf-archive.c it was already using.  We add a new public API
function ctf_arc_bufopen, that looks very like ctf_bufopen but returns
an archive given suitable section data rather than a ctf_file_t: the
archive is a ctf_archive_t, so it can be called on raw CTF dictionaries
(with no archive present) and will return a single-member synthetic
"archive".

There is a tiny lifetime tweak here: before now, the archive code could
assume that the symbol section in the ctf_archive_internal wrapper
structure was always owned by BFD if it was present and should always be
freed: now, the caller can pass one in via ctf_arc_bufopen, wihch has
the usual lifetime rules for such sections (caller frees): so we add an
extra field to track whether this is an internal call from ctf-open-bfd,
in which case we still free the symbol section.

include/
	* ctf-api.h (ctf_arc_bufopen): New.
libctf/
	* ctf-impl.h (ctf_new_archive_internal): Declare.
	(ctf_arc_bufopen): Remove.
	(ctf_archive_internal) <ctfi_free_symsect>: New.
	* ctf-archive.c (ctf_arc_close): Use it.
	(ctf_arc_bufopen): Fuse into...
	(ctf_new_archive_internal): ... this, moved across from...
	* ctf-open-bfd.c: ... here.
	(ctf_bfdopen_ctfsect): Use ctf_arc_bufopen.
	* libctf.ver: Add it.
binutils/
	* readelf.c (dump_section_as_ctf): Support .ctf archives using
	ctf_arc_bufopen.  Automatically load the .ctf member of such
	archives as the parent of all other members, unless specifically
	overridden via --ctf-parent.  Split out dumping code into...
	(dump_ctf_archive_member): ... here, as in objdump, and call
	it once per archive member.
	(dump_ctf_indent_lines): Code style fix.
2020-06-26 15:56:39 +01:00
..
ChangeLog libctf, binutils: support CTF archives like objdump 2020-06-26 15:56:39 +01:00
Makefile.am Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Makefile.in Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
aclocal.m4 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
config.h.in libctf: Add configure check for asprintf (for MinGW) 2020-01-05 09:50:27 +04:00
configure libctf: Add configure check for asprintf (for MinGW) 2020-01-05 09:50:27 +04:00
configure.ac libctf: Add configure check for asprintf (for MinGW) 2020-01-05 09:50:27 +04:00
ctf-archive.c libctf, binutils: support CTF archives like objdump 2020-06-26 15:56:39 +01:00
ctf-create.c libctf: create: forwards are always in the namespace of their referent 2020-06-26 15:56:39 +01:00
ctf-decl.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-decls.h Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-dump.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-endian.h Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-error.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-hash.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-impl.h libctf, binutils: support CTF archives like objdump 2020-06-26 15:56:39 +01:00
ctf-labels.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-link.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-lookup.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-open-bfd.c libctf, binutils: support CTF archives like objdump 2020-06-26 15:56:39 +01:00
ctf-open.c libctf: create: non-root-visible types should not appear in name tables 2020-06-26 15:56:39 +01:00
ctf-qsort_r.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-string.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-subr.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-types.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
ctf-util.c Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
elf.h Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
libctf.ver libctf, binutils: support CTF archives like objdump 2020-06-26 15:56:39 +01:00
swap.h libctf: Mark bswap_identity_64 inline function as static. 2020-03-11 17:48:49 +10:30