libctf, binutils: dump the CTF header
authorNick Alcock <nick.alcock@oracle.com>
Mon, 8 Jul 2019 12:59:15 +0000 (13:59 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 3 Oct 2019 16:04:55 +0000 (17:04 +0100)
commit9b32cba44ddeb32251092a05f1238d2462eb2345
treee313eb919ec3ae3c75c66829e290736843c8c745
parentfd55eae84d8b94b497c6043e5aa6e111e7f5a225
libctf, binutils: dump the CTF header

The CTF header has before now been thrown away too soon to be dumped
using the ctf_dump() machinery used by objdump and readelf: instead, a
kludge involving debugging-priority dumps of the header offsets on every
open was used.

Replace this with proper first-class dumping machinery just like
everything else in the CTF file, and have objdump and readelf use it.
(The dumper already had an enum value in ctf_sect_names_t for this
purpose, waiting to be used.)

v5: fix tabdamage.

libctf/
* ctf-impl.h (ctf_file_t): New field ctf_openflags.
* ctf-open.c (ctf_bufopen): Set it.  No longer dump header offsets.
* ctf-dump.c (dump_header): New function, dump the CTF header.
(ctf_dump): Call it.
(ctf_dump_header_strfield): New function.
(ctf_dump_header_sectfield): Likewise.

binutils/
* objdump.c (dump_ctf_archive_member): Dump the CTF header.
* readelf.c (dump_section_as_ctf): Likewise.
binutils/ChangeLog
binutils/objdump.c
binutils/readelf.c
libctf/ChangeLog
libctf/ctf-dump.c
libctf/ctf-impl.h
libctf/ctf-open.c