+2020-01-05 Joel Brobecker <brobecker@adacore.com>
+
+ PR binutils/25155:
+ * configure.ac: Add AC_CHECK_DECLS([asprintf]).
+ * configure, config.h.in: Regenerate.
+
+2020-01-01 Alan Modra <amodra@gmail.com>
+
+ Update year range in copyright notice of all files.
+
+2019-10-16 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * swap.h (bswap_16, bswap_32, bswap_64): Make static.
+
+2019-09-30 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-open.c (ctf_bufopen_internal): Fix tabdamage.
+ * ctf-types.c (ctf_type_lname): Likewise.
+
+2019-09-23 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-open.c (ctf_import): Do not leak a ctf_file_t ref on every
+ ctf_import after the first for a given file.
+
+2019-09-23 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-impl.h (ctf_str_append_noerr): Declare.
+ * ctf-util.c (ctf_str_append_noerr): Define in terms of
+ ctf_str_append.
+ * ctf-dump.c (str_append): New, call it.
+ (ctf_dump_format_type): Use str_append, not ctf_str_append.
+ (ctf_dump_label): Likewise.
+ (ctf_dump_objts): Likewise.
+ (ctf_dump_funcs): Likewise.
+ (ctf_dump_var): Likewise.
+ (ctf_dump_member): Likewise.
+ (ctf_dump_type): Likewise.
+ (ctf_dump): Likewise.
+
+2019-09-23 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-impl.h (ctf_alloc): Remove.
+ (ctf_free): Likewise.
+ (ctf_strdup): Likewise.
+ * ctf-subr.c (ctf_alloc): Remove.
+ (ctf_free): Likewise.
+ * ctf-util.c (ctf_strdup): Remove.
+
+ * ctf-create.c (ctf_serialize): Use malloc, not ctf_alloc; free, not
+ ctf_free; strdup, not ctf_strdup.
+ (ctf_dtd_delete): Likewise.
+ (ctf_dvd_delete): Likewise.
+ (ctf_add_generic): Likewise.
+ (ctf_add_function): Likewise.
+ (ctf_add_enumerator): Likewise.
+ (ctf_add_member_offset): Likewise.
+ (ctf_add_variable): Likewise.
+ (membadd): Likewise.
+ (ctf_compress_write): Likewise.
+ (ctf_write_mem): Likewise.
+ * ctf-decl.c (ctf_decl_push): Likewise.
+ (ctf_decl_fini): Likewise.
+ (ctf_decl_sprintf): Likewise. Check for OOM.
+ * ctf-dump.c (ctf_dump_append): Use malloc, not ctf_alloc; free, not
+ ctf_free; strdup, not ctf_strdup.
+ (ctf_dump_free): Likewise.
+ (ctf_dump): Likewise.
+ * ctf-open.c (upgrade_types_v1): Likewise.
+ (init_types): Likewise.
+ (ctf_file_close): Likewise.
+ (ctf_bufopen_internal): Likewise. Check for OOM.
+ (ctf_parent_name_set): Likewise: report the OOM to the caller.
+ (ctf_cuname_set): Likewise.
+ (ctf_import): Likewise.
+ * ctf-string.c (ctf_str_purge_atom_refs): Use malloc, not ctf_alloc;
+ free, not ctf_free; strdup, not ctf_strdup.
+ (ctf_str_free_atom): Likewise.
+ (ctf_str_create_atoms): Likewise.
+ (ctf_str_add_ref_internal): Likewise.
+ (ctf_str_remove_ref): Likewise.
+ (ctf_str_write_strtab): Likewise.
+
+2019-08-09 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-types.c (ctf_type_encoding): Fix the dynamic case to
+ work right for non-int/fps.
+
+2019-08-08 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-types.c (ctf_type_name): Don't strlen a potentially-
+ null pointer.
+
+2019-08-07 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-impl.h (ctf_file_t) <ctf_add_processing>: New.
+ * ctf-open.c (ctf_file_close): Free it.
+ * ctf-create.c (ctf_serialize): Adjust.
+ (membcmp): When reporting a conflict due to an error, report the
+ error.
+ (ctf_add_type): Turn into a ctf_add_processing wrapper. Rename to...
+ (ctf_add_type_internal): ... this. Hand back types we are already
+ in the middle of adding immediately. Hand back structs/unions with
+ the same number of members immediately. Do not walk the dynamic
+ list. Call ctf_add_type_internal, not ctf_add_type. Handle
+ forwards promoted to other types and the inverse case identically.
+ Add structs to the mapping as soon as we intern them, before they
+ gain any members.
+
+2019-08-09 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-impl.h (ctf_names_t): New.
+ (ctf_lookup_t) <ctf_hash>: Now a ctf_names_t, not a ctf_hash_t.
+ (ctf_file_t) <ctf_structs>: Likewise.
+ <ctf_unions>: Likewise.
+ <ctf_enums>: Likewise.
+ <ctf_names>: Likewise.
+ <ctf_lookups>: Improve comment.
+ <ctf_ptrtab_len>: New.
+ <ctf_prov_strtab>: New.
+ <ctf_str_prov_offset>: New.
+ <ctf_dtbyname>: Remove, redundant to the names hashes.
+ <ctf_dtnextid>: Remove, redundant to ctf_typemax.
+ (ctf_dtdef_t) <dtd_name>: Remove.
+ <dtd_data>: Note that the ctt_name is now populated.
+ (ctf_str_atom_t) <csa_offset>: This is now the strtab
+ offset for internal strings too.
+ <csa_external_offset>: New, the external strtab offset.
+ (CTF_INDEX_TO_TYPEPTR): Handle the LCTF_RDWR case.
+ (ctf_name_table): New declaration.
+ (ctf_lookup_by_rawname): Likewise.
+ (ctf_lookup_by_rawhash): Likewise.
+ (ctf_set_ctl_hashes): Likewise.
+ (ctf_serialize): Likewise.
+ (ctf_dtd_insert): Adjust.
+ (ctf_simple_open_internal): Likewise.
+ (ctf_bufopen_internal): Likewise.
+ (ctf_list_empty_p): Likewise.
+ (ctf_str_remove_ref): Likewise.
+ (ctf_str_add): Returns uint32_t now.
+ (ctf_str_add_ref): Likewise.
+ (ctf_str_add_external): Now returns a boolean (int).
+ * ctf-string.c (ctf_strraw_explicit): Check the ctf_prov_strtab
+ for strings in the appropriate range.
+ (ctf_str_create_atoms): Create the ctf_prov_strtab. Detect OOM
+ when adding the null string to the new strtab.
+ (ctf_str_free_atoms): Destroy the ctf_prov_strtab.
+ (ctf_str_add_ref_internal): Add make_provisional argument. If
+ make_provisional, populate the offset and fill in the
+ ctf_prov_strtab accordingly.
+ (ctf_str_add): Return the offset, not the string.
+ (ctf_str_add_ref): Likewise.
+ (ctf_str_add_external): Return a success integer.
+ (ctf_str_remove_ref): New, remove a single ref.
+ (ctf_str_count_strtab): Do not count the initial null string's
+ length or the existence or length of any unreferenced internal
+ atoms.
+ (ctf_str_populate_sorttab): Skip atoms with no refs.
+ (ctf_str_write_strtab): Populate the nullstr earlier. Add one
+ to the cts_len for the null string, since it is no longer done
+ in ctf_str_count_strtab. Adjust for csa_external_offset rename.
+ Populate the csa_offset for both internal and external cases.
+ Flush the ctf_prov_strtab afterwards, and reset the
+ ctf_str_prov_offset.
+ * ctf-create.c (ctf_grow_ptrtab): New.
+ (ctf_create): Call it. Initialize new fields rather than old
+ ones. Tell ctf_bufopen_internal that this is a writable dictionary.
+ Set the ctl hashes and data model.
+ (ctf_update): Rename to...
+ (ctf_serialize): ... this. Leave a compatibility function behind.
+ Tell ctf_simple_open_internal that this is a writable dictionary.
+ Pass the new fields along from the old dictionary. Drop
+ ctf_dtnextid and ctf_dtbyname. Use ctf_strraw, not dtd_name.
+ Do not zero out the DTD's ctt_name.
+ (ctf_prefixed_name): Rename to...
+ (ctf_name_table): ... this. No longer return a prefixed name: return
+ the applicable name table instead.
+ (ctf_dtd_insert): Use it, and use the right name table. Pass in the
+ kind we're adding. Migrate away from dtd_name.
+ (ctf_dtd_delete): Adjust similarly. Remove the ref to the
+ deleted ctt_name.
+ (ctf_dtd_lookup_type_by_name): Remove.
+ (ctf_dynamic_type): Always return NULL on read-only dictionaries.
+ No longer check ctf_dtnextid: check ctf_typemax instead.
+ (ctf_snapshot): No longer use ctf_dtnextid: use ctf_typemax instead.
+ (ctf_rollback): Likewise. No longer fail with ECTF_OVERROLLBACK. Use
+ ctf_name_table and the right name table, and migrate away from
+ dtd_name as in ctf_dtd_delete.
+ (ctf_add_generic): Pass in the kind explicitly and pass it to
+ ctf_dtd_insert. Use ctf_typemax, not ctf_dtnextid. Migrate away
+ from dtd_name to using ctf_str_add_ref to populate the ctt_name.
+ Grow the ptrtab if needed.
+ (ctf_add_encoded): Pass in the kind.
+ (ctf_add_slice): Likewise.
+ (ctf_add_array): Likewise.
+ (ctf_add_function): Likewise.
+ (ctf_add_typedef): Likewise.
+ (ctf_add_reftype): Likewise. Initialize the ctf_ptrtab, checking
+ ctt_name rather than dtd_name.
+ (ctf_add_struct_sized): Pass in the kind. Use
+ ctf_lookup_by_rawname, not ctf_hash_lookup_type /
+ ctf_dtd_lookup_type_by_name.
+ (ctf_add_union_sized): Likewise.
+ (ctf_add_enum): Likewise.
+ (ctf_add_enum_encoded): Likewise.
+ (ctf_add_forward): Likewise.
+ (ctf_add_type): Likewise.
+ (ctf_compress_write): Call ctf_serialize: adjust for ctf_size not
+ being initialized until after the call.
+ (ctf_write_mem): Likewise.
+ (ctf_write): Likewise.
+ * ctf-archive.c (arc_write_one_ctf): Likewise.
+ * ctf-lookup.c (ctf_lookup_by_name): Use ctf_lookuup_by_rawhash, not
+ ctf_hash_lookup_type.
+ (ctf_lookup_by_id): No longer check the readonly types if the
+ dictionary is writable.
+ * ctf-open.c (init_types): Assert that this dictionary is not
+ writable. Adjust to use the new name hashes, ctf_name_table,
+ and ctf_ptrtab_len. GNU style fix for the final ptrtab scan.
+ (ctf_bufopen_internal): New 'writable' parameter. Flip on LCTF_RDWR
+ if set. Drop out early when dictionary is writable. Split the
+ ctf_lookups initialization into...
+ (ctf_set_cth_hashes): ... this new function.
+ (ctf_simple_open_internal): Adjust. New 'writable' parameter.
+ (ctf_simple_open): Adjust accordingly.
+ (ctf_bufopen): Likewise.
+ (ctf_file_close): Destroy the appropriate name hashes. No longer
+ destroy ctf_dtbyname, which is gone.
+ (ctf_getdatasect): Remove spurious "extern".
+ * ctf-types.c (ctf_lookup_by_rawname): New, look up types in the
+ specified name table, given a kind.
+ (ctf_lookup_by_rawhash): Likewise, given a ctf_names_t *.
+ (ctf_member_iter): Add support for iterating over the
+ dynamic type list.
+ (ctf_enum_iter): Likewise.
+ (ctf_variable_iter): Likewise.
+ (ctf_type_rvisit): Likewise.
+ (ctf_member_info): Add support for types in the dynamic type list.
+ (ctf_enum_name): Likewise.
+ (ctf_enum_value): Likewise.
+ (ctf_func_type_info): Likewise.
+ (ctf_func_type_args): Likewise.
+ * ctf-link.c (ctf_accumulate_archive_names): No longer call
+ ctf_update.
+ (ctf_link_write): Likewise.
+ (ctf_link_intern_extern_string): Adjust for new
+ ctf_str_add_external return value.
+ (ctf_link_add_strtab): Likewise.
+ * ctf-util.c (ctf_list_empty_p): New.
+
+2019-08-05 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-types.c (ctf_type_resolve): Return ECTF_NONREPRESENTABLE on
+ type zero.
+ * ctf-create.c (ctf_add_type): Detect and skip nonrepresentable
+ members and types.
+ (ctf_add_variable): Likewise for variables pointing to them.
+ * ctf-link.c (ctf_link_one_type): Do not warn for nonrepresentable
+ type link failure, but do warn for others.
+ * ctf-dump.c (ctf_dump_format_type): Likewise. Do not assume all
+ errors to be ENOMEM.
+ (ctf_dump_member): Likewise.
+ (ctf_dump_type): Likewise.
+ (ctf_dump_header_strfield): Do not assume all errors to be ENOMEM.
+ (ctf_dump_header_sectfield): Do not assume all errors to be ENOMEM.
+ (ctf_dump_header): Likewise.
+ (ctf_dump_label): likewise.
+ (ctf_dump_objts): likewise.
+ (ctf_dump_funcs): likewise.
+ (ctf_dump_var): likewise.
+ (ctf_dump_str): Likewise.
+
+2019-09-30 Nick Alcock <nick.alcock@oracle.com>
+
+ * configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
+ (LT_INIT): Likewise.
+ (AM_INSTALL_LIBBFD): Likewise.
+ (dlopen): Note why this is necessary in a comment.
+ (SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
+ opcodes/.
+ (SHARED_LDFLAGS): Likewise.
+ (BFD_LIBADD): Likewise, for libbfd.
+ (BFD_DEPENDENCIES): Likewise.
+ (VERSION_FLAGS): Initialize, using a version script if ld supports
+ one, or libtool -export-symbols-regex otherwise.
+ (AC_CONFIG_MACRO_DIR): Add ../BFD.
+ * Makefile.am (ACLOCAL_AMFLAGS): Likewise.
+ (INCDIR): New.
+ (AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
+ (noinst_LIBRARIES): Replace with...
+ [INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
+ [!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
+ libctf-nobfd.la as well.
+ [INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
+ [!INSTALL_LIBCTF] (include_HEADERS): New, empty.
+ (libctf_a_SOURCES): Rename to...
+ (libctf_nobfd_la_SOURCES): ... this, all of libctf other than
+ ctf-open-bfd.c.
+ (libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
+ with ctf-open-bfd.c added.
+ (libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
+ (libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
+ (libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
+ * Makefile.am [INSTALL_LIBCTF]: Use it.
+ * aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
+ libtool macros.
+ * libctf.ver: New, everything is version LIBCTF_1.0 currently (even
+ the unstable components).
+ * Makefile.in: Regenerated.
+ * config.h.in: Likewise.
+ * configure: Likewise.
+
+2019-07-30 Nick Alcock <nick.alcock@oracle.com>
+
+ * configure.ac (INSTALL_LIBCTF): New, controlled by
+ --enable-install-libctf.
+ [INSTALL_LIBCTF] (lib_LIBRARIES): Add libctf.a.
+ * Makefile.in: Regenerated.
+ * configure: Regenerated.
+
+2019-07-30 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-archive.c (ctf_arc_close): Call ctfi_bfd_close if set.
+ * ctf-open-bfd.c (ctf_bfdclose): Fix comment.
+
+2019-07-30 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-open-bfd.c (ctf_fdopen): Call bfd_set_cacheable.
+
+2019-07-13 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-impl.h (includes): Include <sys/param.h> here.
+
+2019-07-30 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-open.c (flip_lbls): Eschew for-loop initial declarations.
+ (flip_objts): Likewise.
+ (flip_vars): Likewise.
+ (flip_types): Likewise.
+
+2019-07-30 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-hash.c (ctf_hashtab_insert): Pass in the key and value
+ freeing functions: if set, free the key and value if the slot
+ already exists. Always reassign the key.
+ (ctf_dynhash_insert): Adjust call appropriately.
+ (ctf_hash_insert_type): Likewise.
+
+2019-08-03 Nick Alcock <nick.alcock@oracle.com>
+
+ * 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-07-30 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-impl.h (ctf_file_t) <ctf_link_cu_mappping>: New.
+ <ctf_link_memb_name_changer>: Likewise.
+ <ctf_link_memb_name_changer_arg>: Likewise.
+ * ctf-create.c (ctf_update): Update accordingly.
+ * ctf-open.c (ctf_file_close): Likewise.
+ * ctf-link.c (ctf_create_per_cu): Apply the cu mapping.
+ (ctf_link_add_cu_mapping): New.
+ (ctf_link_set_memb_name_changer): Likewise.
+ (ctf_change_parent_name): New.
+ (ctf_name_list_accum_cb_arg_t) <dynames>: New, storage for names
+ allocated by the caller's ctf_link_memb_name_changer.
+ <ndynames>: Likewise.
+ (ctf_accumulate_archive_names): Call the ctf_link_memb_name_changer.
+ (ctf_link_write): Likewise (for _CTF_SECTION only): also call
+ ctf_change_parent_name. Free any resulting names.
+
+2019-07-13 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-link.c (ctf_create_per_cu): New, refactored out of...
+ (ctf_link_one_type): ... here, with parent-name setting added.
+ (check_variable): New.
+ (ctf_link_one_variable): Likewise.
+ (ctf_link_one_input_archive_member): Call it.
+ * ctf-error.c (_ctf_errlist): Updated with new errors.
+
+2019-07-13 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-impl.h (ctf_file_t): New field ctf_link_type_mapping.
+ (struct ctf_link_type_mapping_key): New.
+ (ctf_hash_type_mapping_key): Likewise.
+ (ctf_hash_eq_type_mapping_key): Likewise.
+ (ctf_add_type_mapping): Likewise.
+ (ctf_type_mapping): Likewise.
+ (ctf_dynhash_empty): Likewise.
+ * ctf-open.c (ctf_file_close): Update accordingly.
+ * ctf-create.c (ctf_update): Likewise.
+ (ctf_add_type): Populate the mapping.
+ * ctf-hash.c (ctf_hash_type_mapping_key): Hash a type mapping key.
+ (ctf_hash_eq_type_mapping_key): Check the key for equality.
+ (ctf_dynhash_insert): Fix comment typo.
+ (ctf_dynhash_empty): New.
+ * ctf-link.c (ctf_add_type_mapping): New.
+ (ctf_type_mapping): Likewise.
+ (empty_link_type_mapping): New.
+ (ctf_link_one_input_archive): Call it.
+
+2019-07-13 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-link.c: New file, linking of the string and type sections.
+ * Makefile.am (libctf_a_SOURCES): Add it.
+ * Makefile.in: Regenerate.
+
+ * ctf-impl.h (ctf_file_t): New fields ctf_link_inputs,
+ ctf_link_outputs.
+ * ctf-create.c (ctf_update): Update accordingly.
+ * ctf-open.c (ctf_file_close): Likewise.
+ * ctf-error.c (_ctf_errlist): Updated with new errors.
+
+2019-07-13 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-dump.c (ctf_dump_funcs): Check the right error value.
+
+2019-07-13 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-dump.c (ctf_dump): Use ctf_type_iter_all to dump types, not
+ ctf_type_iter.
+ (ctf_dump_type): Pass down the flag from ctf_type_iter_all.
+ (ctf_dump_format_type): Add non-root-type { } notation.
+ Add root flag to prototype.
+ (ctf_dump_label): Adjust accordingly.
+ (ctf_dump_objts): Likewise.
+ (ctf_dump_var): Likewise.
+
2019-07-13 Nick Alcock <nick.alcock@oracle.com>
* ctf-create.c (ctf_compress_write): Fix double-free.