1 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
4 * ctf-archive.c (search_nametbl): No longer global: declare...
5 (ctf_arc_open_by_name_internal): ... here. Use bsearch_r.
6 (search_modent_by_name): Take and use ARG for the nametbl.
8 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
10 * ctf-impl.h (ctf_new_archive_internal): Declare.
11 (ctf_arc_bufopen): Remove.
12 (ctf_archive_internal) <ctfi_free_symsect>: New.
13 * ctf-archive.c (ctf_arc_close): Use it.
14 (ctf_arc_bufopen): Fuse into...
15 (ctf_new_archive_internal): ... this, moved across from...
16 * ctf-open-bfd.c: ... here.
17 (ctf_bfdopen_ctfsect): Use ctf_arc_bufopen.
20 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
22 * ctf-create.c (ctf_add_forward): Intern in the right namespace.
23 (ctf_dtd_delete): Remove correspondingly.
24 (ctf_rollback): Likewise.
26 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
28 * ctf-create.c (ctf_add_type_internal): Hand back existing types
31 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
33 * ctf-create.c (ctf_add_forward): Don't add forwards to
34 types that already exist.
36 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
38 * ctf-open.c (init_types): Only intern root-visible types.
39 * ctf-create.c (ctf_dtd_insert): Likewise.
40 (ctf_dtd_delete): Only remove root-visible types.
41 (ctf_rollback): Likewise.
42 (ctf_add_generic): Adjust.
43 (ctf_add_struct_sized): Adjust comment.
44 (ctf_add_union_sized): Likewise.
45 (ctf_add_enum): Likewise.
46 * ctf-impl.h (ctf_dtd_insert): Adjust prototype.
48 2020-03-11 John Baldwin <jhb@FreeBSD.org>
50 * swap.h (bswap_identity_64): Make static.
52 2020-01-18 Nick Clifton <nickc@redhat.com>
54 Binutils 2.34 branch created.
56 2020-01-05 Joel Brobecker <brobecker@adacore.com>
59 * configure.ac: Add AC_CHECK_DECLS([asprintf]).
60 * configure, config.h.in: Regenerate.
62 2020-01-01 Alan Modra <amodra@gmail.com>
64 Update year range in copyright notice of all files.
66 2019-10-16 Simon Marchi <simon.marchi@polymtl.ca>
68 * swap.h (bswap_16, bswap_32, bswap_64): Make static.
70 2019-09-30 Nick Alcock <nick.alcock@oracle.com>
72 * ctf-open.c (ctf_bufopen_internal): Fix tabdamage.
73 * ctf-types.c (ctf_type_lname): Likewise.
75 2019-09-23 Nick Alcock <nick.alcock@oracle.com>
77 * ctf-open.c (ctf_import): Do not leak a ctf_file_t ref on every
78 ctf_import after the first for a given file.
80 2019-09-23 Nick Alcock <nick.alcock@oracle.com>
82 * ctf-impl.h (ctf_str_append_noerr): Declare.
83 * ctf-util.c (ctf_str_append_noerr): Define in terms of
85 * ctf-dump.c (str_append): New, call it.
86 (ctf_dump_format_type): Use str_append, not ctf_str_append.
87 (ctf_dump_label): Likewise.
88 (ctf_dump_objts): Likewise.
89 (ctf_dump_funcs): Likewise.
90 (ctf_dump_var): Likewise.
91 (ctf_dump_member): Likewise.
92 (ctf_dump_type): Likewise.
95 2019-09-23 Nick Alcock <nick.alcock@oracle.com>
97 * ctf-impl.h (ctf_alloc): Remove.
99 (ctf_strdup): Likewise.
100 * ctf-subr.c (ctf_alloc): Remove.
101 (ctf_free): Likewise.
102 * ctf-util.c (ctf_strdup): Remove.
104 * ctf-create.c (ctf_serialize): Use malloc, not ctf_alloc; free, not
105 ctf_free; strdup, not ctf_strdup.
106 (ctf_dtd_delete): Likewise.
107 (ctf_dvd_delete): Likewise.
108 (ctf_add_generic): Likewise.
109 (ctf_add_function): Likewise.
110 (ctf_add_enumerator): Likewise.
111 (ctf_add_member_offset): Likewise.
112 (ctf_add_variable): Likewise.
114 (ctf_compress_write): Likewise.
115 (ctf_write_mem): Likewise.
116 * ctf-decl.c (ctf_decl_push): Likewise.
117 (ctf_decl_fini): Likewise.
118 (ctf_decl_sprintf): Likewise. Check for OOM.
119 * ctf-dump.c (ctf_dump_append): Use malloc, not ctf_alloc; free, not
120 ctf_free; strdup, not ctf_strdup.
121 (ctf_dump_free): Likewise.
122 (ctf_dump): Likewise.
123 * ctf-open.c (upgrade_types_v1): Likewise.
124 (init_types): Likewise.
125 (ctf_file_close): Likewise.
126 (ctf_bufopen_internal): Likewise. Check for OOM.
127 (ctf_parent_name_set): Likewise: report the OOM to the caller.
128 (ctf_cuname_set): Likewise.
129 (ctf_import): Likewise.
130 * ctf-string.c (ctf_str_purge_atom_refs): Use malloc, not ctf_alloc;
131 free, not ctf_free; strdup, not ctf_strdup.
132 (ctf_str_free_atom): Likewise.
133 (ctf_str_create_atoms): Likewise.
134 (ctf_str_add_ref_internal): Likewise.
135 (ctf_str_remove_ref): Likewise.
136 (ctf_str_write_strtab): Likewise.
138 2019-08-09 Nick Alcock <nick.alcock@oracle.com>
140 * ctf-types.c (ctf_type_encoding): Fix the dynamic case to
141 work right for non-int/fps.
143 2019-08-08 Nick Alcock <nick.alcock@oracle.com>
145 * ctf-types.c (ctf_type_name): Don't strlen a potentially-
148 2019-08-07 Nick Alcock <nick.alcock@oracle.com>
150 * ctf-impl.h (ctf_file_t) <ctf_add_processing>: New.
151 * ctf-open.c (ctf_file_close): Free it.
152 * ctf-create.c (ctf_serialize): Adjust.
153 (membcmp): When reporting a conflict due to an error, report the
155 (ctf_add_type): Turn into a ctf_add_processing wrapper. Rename to...
156 (ctf_add_type_internal): ... this. Hand back types we are already
157 in the middle of adding immediately. Hand back structs/unions with
158 the same number of members immediately. Do not walk the dynamic
159 list. Call ctf_add_type_internal, not ctf_add_type. Handle
160 forwards promoted to other types and the inverse case identically.
161 Add structs to the mapping as soon as we intern them, before they
164 2019-08-09 Nick Alcock <nick.alcock@oracle.com>
166 * ctf-impl.h (ctf_names_t): New.
167 (ctf_lookup_t) <ctf_hash>: Now a ctf_names_t, not a ctf_hash_t.
168 (ctf_file_t) <ctf_structs>: Likewise.
169 <ctf_unions>: Likewise.
170 <ctf_enums>: Likewise.
171 <ctf_names>: Likewise.
172 <ctf_lookups>: Improve comment.
173 <ctf_ptrtab_len>: New.
174 <ctf_prov_strtab>: New.
175 <ctf_str_prov_offset>: New.
176 <ctf_dtbyname>: Remove, redundant to the names hashes.
177 <ctf_dtnextid>: Remove, redundant to ctf_typemax.
178 (ctf_dtdef_t) <dtd_name>: Remove.
179 <dtd_data>: Note that the ctt_name is now populated.
180 (ctf_str_atom_t) <csa_offset>: This is now the strtab
181 offset for internal strings too.
182 <csa_external_offset>: New, the external strtab offset.
183 (CTF_INDEX_TO_TYPEPTR): Handle the LCTF_RDWR case.
184 (ctf_name_table): New declaration.
185 (ctf_lookup_by_rawname): Likewise.
186 (ctf_lookup_by_rawhash): Likewise.
187 (ctf_set_ctl_hashes): Likewise.
188 (ctf_serialize): Likewise.
189 (ctf_dtd_insert): Adjust.
190 (ctf_simple_open_internal): Likewise.
191 (ctf_bufopen_internal): Likewise.
192 (ctf_list_empty_p): Likewise.
193 (ctf_str_remove_ref): Likewise.
194 (ctf_str_add): Returns uint32_t now.
195 (ctf_str_add_ref): Likewise.
196 (ctf_str_add_external): Now returns a boolean (int).
197 * ctf-string.c (ctf_strraw_explicit): Check the ctf_prov_strtab
198 for strings in the appropriate range.
199 (ctf_str_create_atoms): Create the ctf_prov_strtab. Detect OOM
200 when adding the null string to the new strtab.
201 (ctf_str_free_atoms): Destroy the ctf_prov_strtab.
202 (ctf_str_add_ref_internal): Add make_provisional argument. If
203 make_provisional, populate the offset and fill in the
204 ctf_prov_strtab accordingly.
205 (ctf_str_add): Return the offset, not the string.
206 (ctf_str_add_ref): Likewise.
207 (ctf_str_add_external): Return a success integer.
208 (ctf_str_remove_ref): New, remove a single ref.
209 (ctf_str_count_strtab): Do not count the initial null string's
210 length or the existence or length of any unreferenced internal
212 (ctf_str_populate_sorttab): Skip atoms with no refs.
213 (ctf_str_write_strtab): Populate the nullstr earlier. Add one
214 to the cts_len for the null string, since it is no longer done
215 in ctf_str_count_strtab. Adjust for csa_external_offset rename.
216 Populate the csa_offset for both internal and external cases.
217 Flush the ctf_prov_strtab afterwards, and reset the
219 * ctf-create.c (ctf_grow_ptrtab): New.
220 (ctf_create): Call it. Initialize new fields rather than old
221 ones. Tell ctf_bufopen_internal that this is a writable dictionary.
222 Set the ctl hashes and data model.
223 (ctf_update): Rename to...
224 (ctf_serialize): ... this. Leave a compatibility function behind.
225 Tell ctf_simple_open_internal that this is a writable dictionary.
226 Pass the new fields along from the old dictionary. Drop
227 ctf_dtnextid and ctf_dtbyname. Use ctf_strraw, not dtd_name.
228 Do not zero out the DTD's ctt_name.
229 (ctf_prefixed_name): Rename to...
230 (ctf_name_table): ... this. No longer return a prefixed name: return
231 the applicable name table instead.
232 (ctf_dtd_insert): Use it, and use the right name table. Pass in the
233 kind we're adding. Migrate away from dtd_name.
234 (ctf_dtd_delete): Adjust similarly. Remove the ref to the
236 (ctf_dtd_lookup_type_by_name): Remove.
237 (ctf_dynamic_type): Always return NULL on read-only dictionaries.
238 No longer check ctf_dtnextid: check ctf_typemax instead.
239 (ctf_snapshot): No longer use ctf_dtnextid: use ctf_typemax instead.
240 (ctf_rollback): Likewise. No longer fail with ECTF_OVERROLLBACK. Use
241 ctf_name_table and the right name table, and migrate away from
242 dtd_name as in ctf_dtd_delete.
243 (ctf_add_generic): Pass in the kind explicitly and pass it to
244 ctf_dtd_insert. Use ctf_typemax, not ctf_dtnextid. Migrate away
245 from dtd_name to using ctf_str_add_ref to populate the ctt_name.
246 Grow the ptrtab if needed.
247 (ctf_add_encoded): Pass in the kind.
248 (ctf_add_slice): Likewise.
249 (ctf_add_array): Likewise.
250 (ctf_add_function): Likewise.
251 (ctf_add_typedef): Likewise.
252 (ctf_add_reftype): Likewise. Initialize the ctf_ptrtab, checking
253 ctt_name rather than dtd_name.
254 (ctf_add_struct_sized): Pass in the kind. Use
255 ctf_lookup_by_rawname, not ctf_hash_lookup_type /
256 ctf_dtd_lookup_type_by_name.
257 (ctf_add_union_sized): Likewise.
258 (ctf_add_enum): Likewise.
259 (ctf_add_enum_encoded): Likewise.
260 (ctf_add_forward): Likewise.
261 (ctf_add_type): Likewise.
262 (ctf_compress_write): Call ctf_serialize: adjust for ctf_size not
263 being initialized until after the call.
264 (ctf_write_mem): Likewise.
265 (ctf_write): Likewise.
266 * ctf-archive.c (arc_write_one_ctf): Likewise.
267 * ctf-lookup.c (ctf_lookup_by_name): Use ctf_lookuup_by_rawhash, not
268 ctf_hash_lookup_type.
269 (ctf_lookup_by_id): No longer check the readonly types if the
270 dictionary is writable.
271 * ctf-open.c (init_types): Assert that this dictionary is not
272 writable. Adjust to use the new name hashes, ctf_name_table,
273 and ctf_ptrtab_len. GNU style fix for the final ptrtab scan.
274 (ctf_bufopen_internal): New 'writable' parameter. Flip on LCTF_RDWR
275 if set. Drop out early when dictionary is writable. Split the
276 ctf_lookups initialization into...
277 (ctf_set_cth_hashes): ... this new function.
278 (ctf_simple_open_internal): Adjust. New 'writable' parameter.
279 (ctf_simple_open): Adjust accordingly.
280 (ctf_bufopen): Likewise.
281 (ctf_file_close): Destroy the appropriate name hashes. No longer
282 destroy ctf_dtbyname, which is gone.
283 (ctf_getdatasect): Remove spurious "extern".
284 * ctf-types.c (ctf_lookup_by_rawname): New, look up types in the
285 specified name table, given a kind.
286 (ctf_lookup_by_rawhash): Likewise, given a ctf_names_t *.
287 (ctf_member_iter): Add support for iterating over the
289 (ctf_enum_iter): Likewise.
290 (ctf_variable_iter): Likewise.
291 (ctf_type_rvisit): Likewise.
292 (ctf_member_info): Add support for types in the dynamic type list.
293 (ctf_enum_name): Likewise.
294 (ctf_enum_value): Likewise.
295 (ctf_func_type_info): Likewise.
296 (ctf_func_type_args): Likewise.
297 * ctf-link.c (ctf_accumulate_archive_names): No longer call
299 (ctf_link_write): Likewise.
300 (ctf_link_intern_extern_string): Adjust for new
301 ctf_str_add_external return value.
302 (ctf_link_add_strtab): Likewise.
303 * ctf-util.c (ctf_list_empty_p): New.
305 2019-08-05 Nick Alcock <nick.alcock@oracle.com>
307 * ctf-types.c (ctf_type_resolve): Return ECTF_NONREPRESENTABLE on
309 * ctf-create.c (ctf_add_type): Detect and skip nonrepresentable
311 (ctf_add_variable): Likewise for variables pointing to them.
312 * ctf-link.c (ctf_link_one_type): Do not warn for nonrepresentable
313 type link failure, but do warn for others.
314 * ctf-dump.c (ctf_dump_format_type): Likewise. Do not assume all
316 (ctf_dump_member): Likewise.
317 (ctf_dump_type): Likewise.
318 (ctf_dump_header_strfield): Do not assume all errors to be ENOMEM.
319 (ctf_dump_header_sectfield): Do not assume all errors to be ENOMEM.
320 (ctf_dump_header): Likewise.
321 (ctf_dump_label): likewise.
322 (ctf_dump_objts): likewise.
323 (ctf_dump_funcs): likewise.
324 (ctf_dump_var): likewise.
325 (ctf_dump_str): Likewise.
327 2019-09-30 Nick Alcock <nick.alcock@oracle.com>
329 * configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
331 (AM_INSTALL_LIBBFD): Likewise.
332 (dlopen): Note why this is necessary in a comment.
333 (SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
335 (SHARED_LDFLAGS): Likewise.
336 (BFD_LIBADD): Likewise, for libbfd.
337 (BFD_DEPENDENCIES): Likewise.
338 (VERSION_FLAGS): Initialize, using a version script if ld supports
339 one, or libtool -export-symbols-regex otherwise.
340 (AC_CONFIG_MACRO_DIR): Add ../BFD.
341 * Makefile.am (ACLOCAL_AMFLAGS): Likewise.
343 (AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
344 (noinst_LIBRARIES): Replace with...
345 [INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
346 [!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
347 libctf-nobfd.la as well.
348 [INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
349 [!INSTALL_LIBCTF] (include_HEADERS): New, empty.
350 (libctf_a_SOURCES): Rename to...
351 (libctf_nobfd_la_SOURCES): ... this, all of libctf other than
353 (libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
354 with ctf-open-bfd.c added.
355 (libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
356 (libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
357 (libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
358 * Makefile.am [INSTALL_LIBCTF]: Use it.
359 * aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
361 * libctf.ver: New, everything is version LIBCTF_1.0 currently (even
362 the unstable components).
363 * Makefile.in: Regenerated.
364 * config.h.in: Likewise.
365 * configure: Likewise.
367 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
369 * configure.ac (INSTALL_LIBCTF): New, controlled by
370 --enable-install-libctf.
371 [INSTALL_LIBCTF] (lib_LIBRARIES): Add libctf.a.
372 * Makefile.in: Regenerated.
373 * configure: Regenerated.
375 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
377 * ctf-archive.c (ctf_arc_close): Call ctfi_bfd_close if set.
378 * ctf-open-bfd.c (ctf_bfdclose): Fix comment.
380 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
382 * ctf-open-bfd.c (ctf_fdopen): Call bfd_set_cacheable.
384 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
386 * ctf-impl.h (includes): Include <sys/param.h> here.
388 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
390 * ctf-open.c (flip_lbls): Eschew for-loop initial declarations.
391 (flip_objts): Likewise.
392 (flip_vars): Likewise.
393 (flip_types): Likewise.
395 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
397 * ctf-hash.c (ctf_hashtab_insert): Pass in the key and value
398 freeing functions: if set, free the key and value if the slot
399 already exists. Always reassign the key.
400 (ctf_dynhash_insert): Adjust call appropriately.
401 (ctf_hash_insert_type): Likewise.
403 2019-08-03 Nick Alcock <nick.alcock@oracle.com>
405 * ctf-create.c (ctf_add_type): Look up and use the forwarded-to
406 type kind. Allow forwards to unify with pre-existing structs/
409 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
411 * ctf-impl.h (ctf_file_t) <ctf_link_cu_mappping>: New.
412 <ctf_link_memb_name_changer>: Likewise.
413 <ctf_link_memb_name_changer_arg>: Likewise.
414 * ctf-create.c (ctf_update): Update accordingly.
415 * ctf-open.c (ctf_file_close): Likewise.
416 * ctf-link.c (ctf_create_per_cu): Apply the cu mapping.
417 (ctf_link_add_cu_mapping): New.
418 (ctf_link_set_memb_name_changer): Likewise.
419 (ctf_change_parent_name): New.
420 (ctf_name_list_accum_cb_arg_t) <dynames>: New, storage for names
421 allocated by the caller's ctf_link_memb_name_changer.
422 <ndynames>: Likewise.
423 (ctf_accumulate_archive_names): Call the ctf_link_memb_name_changer.
424 (ctf_link_write): Likewise (for _CTF_SECTION only): also call
425 ctf_change_parent_name. Free any resulting names.
427 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
429 * ctf-link.c (ctf_create_per_cu): New, refactored out of...
430 (ctf_link_one_type): ... here, with parent-name setting added.
431 (check_variable): New.
432 (ctf_link_one_variable): Likewise.
433 (ctf_link_one_input_archive_member): Call it.
434 * ctf-error.c (_ctf_errlist): Updated with new errors.
436 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
438 * ctf-impl.h (ctf_file_t): New field ctf_link_type_mapping.
439 (struct ctf_link_type_mapping_key): New.
440 (ctf_hash_type_mapping_key): Likewise.
441 (ctf_hash_eq_type_mapping_key): Likewise.
442 (ctf_add_type_mapping): Likewise.
443 (ctf_type_mapping): Likewise.
444 (ctf_dynhash_empty): Likewise.
445 * ctf-open.c (ctf_file_close): Update accordingly.
446 * ctf-create.c (ctf_update): Likewise.
447 (ctf_add_type): Populate the mapping.
448 * ctf-hash.c (ctf_hash_type_mapping_key): Hash a type mapping key.
449 (ctf_hash_eq_type_mapping_key): Check the key for equality.
450 (ctf_dynhash_insert): Fix comment typo.
451 (ctf_dynhash_empty): New.
452 * ctf-link.c (ctf_add_type_mapping): New.
453 (ctf_type_mapping): Likewise.
454 (empty_link_type_mapping): New.
455 (ctf_link_one_input_archive): Call it.
457 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
459 * ctf-link.c: New file, linking of the string and type sections.
460 * Makefile.am (libctf_a_SOURCES): Add it.
461 * Makefile.in: Regenerate.
463 * ctf-impl.h (ctf_file_t): New fields ctf_link_inputs,
465 * ctf-create.c (ctf_update): Update accordingly.
466 * ctf-open.c (ctf_file_close): Likewise.
467 * ctf-error.c (_ctf_errlist): Updated with new errors.
469 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
471 * ctf-dump.c (ctf_dump_funcs): Check the right error value.
473 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
475 * ctf-dump.c (ctf_dump): Use ctf_type_iter_all to dump types, not
477 (ctf_dump_type): Pass down the flag from ctf_type_iter_all.
478 (ctf_dump_format_type): Add non-root-type { } notation.
479 Add root flag to prototype.
480 (ctf_dump_label): Adjust accordingly.
481 (ctf_dump_objts): Likewise.
482 (ctf_dump_var): Likewise.
484 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
486 * ctf-create.c (ctf_compress_write): Fix double-free.
488 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
490 * ctf-archive.c (ctf_arc_write): Split off, and reimplement in terms
492 (ctf_arc_write_fd): ... this new function.
493 * ctf-create.c (ctf_write_mem): New.
495 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
497 * ctf-impl.h (ctf_str_atom_t) <csa_offset>: New field.
498 (ctf_file_t) <ctf_syn_ext_strtab>: Likewise.
499 (ctf_str_add_ref): Name the last arg.
500 (ctf_str_add_external) New.
501 (ctf_str_add_strraw_explicit): Likewise.
502 (ctf_simple_open_internal): Likewise.
503 (ctf_bufopen_internal): Likewise.
505 * ctf-string.c (ctf_strraw_explicit): Split from...
506 (ctf_strraw): ... here, with new support for ctf_syn_ext_strtab.
507 (ctf_str_add_ref_internal): Return the atom, not the
509 (ctf_str_add): Adjust accordingly.
510 (ctf_str_add_ref): Likewise. Move up in the file.
511 (ctf_str_add_external): New: update the csa_offset.
512 (ctf_str_count_strtab): Only account for strings with no csa_offset
513 in the internal strtab length.
514 (ctf_str_write_strtab): If the csa_offset is set, update the
515 string's refs without writing the string out, and update the
516 ctf_syn_ext_strtab. Make OOM handling less ugly.
517 * ctf-create.c (struct ctf_sort_var_arg_cb): New.
518 (ctf_update): Handle failure to populate the strtab. Pass in the
519 new ctf_sort_var arg. Adjust for ctf_syn_ext_strtab addition.
520 Call ctf_simple_open_internal, not ctf_simple_open.
521 (ctf_sort_var): Call ctf_strraw_explicit rather than looking up
523 * ctf-hash.c (ctf_hash_insert_type): Likewise (but using
524 ctf_strraw). Adjust to diagnose ECTF_STRTAB nonetheless.
525 * ctf-open.c (init_types): No longer filter out ECTF_STRTAB.
526 (ctf_file_close): Destroy the ctf_syn_ext_strtab.
527 (ctf_simple_open): Rename to, and reimplement as a wrapper around...
528 (ctf_simple_open_internal): ... this new function, which calls
529 ctf_bufopen_internal.
530 (ctf_bufopen): Rename to, and reimplement as a wrapper around...
531 (ctf_bufopen_internal): ... this new function, which sets
534 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
536 * ctf_types.c (ctf_type_iter_all): New.
538 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
540 * ctf-open.c (init_symtab): Check for overflow against the right
542 (upgrade_header): Set cth_objtidxoff, cth_funcidxoff to zero-length.
543 (upgrade_types_v1): Note that these sections are not checked.
544 (flip_header): Endian-swap the header fields.
545 (flip_ctf): Endian-swap the sections.
546 (flip_objts): Update comment.
547 (ctf_bufopen): Check header offsets and alignment for validity.
549 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
551 * ctf-open-bfd.c: Add <assert.h>.
552 (ctf_bfdopen_ctfsect): Open string and symbol tables using
553 techniques borrowed from bfd_elf_sym_name.
554 (ctf_new_archive_internal): Improve comment.
555 * ctf-archive.c (ctf_arc_close): Do not free the ctfi_strsect.
556 * ctf-open.c (ctf_bufopen): Allow opening with a string section but
557 no symbol section, but not vice versa.
559 2019-07-08 Nick Alcock <nick.alcock@oracle.com>
561 * ctf-impl.h (ctf_file_t): New field ctf_openflags.
562 * ctf-open.c (ctf_bufopen): Set it. No longer dump header offsets.
563 * ctf-dump.c (dump_header): New function, dump the CTF header.
565 (ctf_dump_header_strfield): New function.
566 (ctf_dump_header_sectfield): Likewise.
568 2019-07-06 Nick Alcock <nick.alcock@oracle.com>
570 * ctf-impl.h (ctf_file_t): New fields ctf_header, ctf_dynbase,
571 ctf_cuname, ctf_dyncuname: ctf_base and ctf_buf are no longer const.
572 * ctf-open.c (ctf_set_base): Preserve the gap between ctf_buf and
573 ctf_base: do not assume that it is always sizeof (ctf_header_t).
574 Print out ctf_cuname: only print out ctf_parname if set.
575 (ctf_free_base): Removed, ctf_base is no longer freed: free
577 (ctf_set_version): Fix spacing.
578 (upgrade_header): New, in-place header upgrading.
579 (upgrade_types): Rename to...
580 (upgrade_types_v1): ... this. Free ctf_dynbase, not ctf_base. No
581 longer track old and new headers separately. No longer allow for
582 header sizes explicitly: squeeze the headers out on upgrade (they
583 are preserved in fp->ctf_header). Set ctf_dynbase, ctf_base and
584 ctf_buf explicitly. Use ctf_free, not ctf_free_base.
585 (upgrade_types): New, also handle ctf_parmax updating.
586 (flip_header): Flip ctf_cuname.
587 (flip_types): Flip BUF explicitly rather than deriving BUF from
589 (ctf_bufopen): Store the header in fp->ctf_header. Correct minimum
590 required alignment of objtoff and funcoff. No longer store it in
591 the ctf_buf unless that buf is derived unmodified from the input.
592 Set ctf_dynbase where ctf_base is dynamically allocated. Drop locals
593 that duplicate fields in ctf_file: move allocation of ctf_file
594 further up instead. Call upgrade_header as needed. Move
595 version-specific ctf_parmax initialization into upgrade_types. More
596 concise error handling.
597 (ctf_file_close): No longer test for null pointers before freeing.
598 Free ctf_dyncuname, ctf_dynbase, and ctf_header. Do not call
601 (ctf_cuname_set): New.
602 * ctf-create.c (ctf_update): Populate ctf_cuname.
603 (ctf_gzwrite): Write out the header explicitly. Remove obsolescent
605 (ctf_write): Likewise.
606 (ctf_compress_write): Get the header from ctf_header, not ctf_base.
607 Fix the compression length: fp->ctf_size never counted the CTF
608 header. Simplify the compress call accordingly.
610 2019-07-11 Hans-Peter Nilsson <hp@bitrange.com>
612 * ctf-endian.h: Don't assume htole64 and le64toh are always
613 present if HAVE_ENDIAN_H; also check if htole64 is defined.
614 [!WORDS_BIGENDIAN] (htole64, le64toh): Define as identity,
615 not bswap_identity_64.
617 2019-09-18 Alan Modra <amodra@gmail.com>
619 * ctf-open-bfd.c: Update throughout for bfd section macro changes.
621 2019-09-09 Phil Blundell <pb@pbcl.net>
623 binutils 2.33 branch created.
625 2019-07-18 Nick Alcock <nick.alcock@oracle.com>
627 * ctf-types.c (ctf_type_aname_raw): New.
628 (ctf_func_type_info): Likewise.
629 (ctf_func_type_args): Likewise.
630 * ctf-error.c (_ctf_errlist): Fix description.
631 * ctf-lookup.c: Fix file description.
633 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
635 * ctf-create.c (ctf_create): Fix off-by-one error.
637 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
639 * ctf-impl.h: (struct ctf_strs_writable): New, non-const version of
641 (struct ctf_dtdef): Note that dtd_data.ctt_name is unpopulated.
642 (struct ctf_str_atom): New, disambiguated single string.
643 (struct ctf_str_atom_ref): New, points to some other location that
644 references this string's offset.
645 (struct ctf_file): New members ctf_str_atoms and ctf_str_num_refs.
646 Remove member ctf_dtvstrlen: we no longer track the total strlen
648 (ctf_str_create_atoms): Declare new function in ctf-string.c.
649 (ctf_str_free_atoms): Likewise.
650 (ctf_str_add): Likewise.
651 (ctf_str_add_ref): Likewise.
652 (ctf_str_rollback): Likewise.
653 (ctf_str_purge_refs): Likewise.
654 (ctf_str_write_strtab): Likewise.
655 (ctf_realloc): Declare new function in ctf-util.c.
657 * ctf-open.c (ctf_bufopen): Create the atoms table.
658 (ctf_file_close): Destroy it.
659 * ctf-create.c (ctf_update): Copy-and-free it on update. No longer
660 special-case the position of the parname string. Construct the
661 strtab by calling ctf_str_add_ref and ctf_str_write_strtab after the
662 rest of each buffer element is constructed, not via open-coding:
663 realloc the CTF buffer and append the strtab to it. No longer
664 maintain ctf_dtvstrlen. Sort the variable entry table later, after
666 (ctf_copy_membnames): Remove: integrated into ctf_copy_{s,l,e}members.
667 (ctf_copy_smembers): Drop the string offset: call ctf_str_add_ref
668 after buffer element construction instead.
669 (ctf_copy_lmembers): Likewise.
670 (ctf_copy_emembers): Likewise.
671 (ctf_create): No longer maintain the ctf_dtvstrlen.
672 (ctf_dtd_delete): Likewise.
673 (ctf_dvd_delete): Likewise.
674 (ctf_add_generic): Likewise.
675 (ctf_add_enumerator): Likewise.
676 (ctf_add_member_offset): Likewise.
677 (ctf_add_variable): Likewise.
679 * ctf-util.c (ctf_realloc): New, wrapper around realloc that aborts
680 if there are active ctf_str_num_refs.
681 (ctf_strraw): Move to ctf-string.c.
682 (ctf_strptr): Likewise.
683 * ctf-string.c: New file, strtab manipulation.
685 * Makefile.am (libctf_a_SOURCES): Add it.
686 * Makefile.in: Regenerate.
688 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
690 * ctf-impl.h (ctf_hash_iter_f): New.
691 (ctf_dynhash_iter): New declaration.
692 (ctf_dynhash_iter_remove): New declaration.
693 * ctf-hash.c (ctf_dynhash_iter): Define.
694 (ctf_dynhash_iter_remove): Likewise.
695 (ctf_hashtab_traverse): New.
696 (ctf_hashtab_traverse_remove): Likewise.
697 (struct ctf_traverse_cb_arg): Likewise.
698 (struct ctf_traverse_remove_cb_arg): Likewise.
700 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
702 * ctf-hash.c (ctf_dynhash_remove): Call with a mocked-up element.
704 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
706 * ctf-dump.c (ctf_dump_format_type): Prefix hex strings with 0x.
707 (ctf_dump_funcs): Likewise.
709 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
711 * ctf-open-bfd.c: Add swap.h and ctf-endian.h.
712 (ctf_fdopen): Check for endian-swapped raw CTF magic, and
713 little-endian CTF archive magic. Do not check the CTF version:
714 ctf_simple_open does that in endian-safe ways. Do not dereference
715 null pointers on open failure.
717 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
719 * ctf-open.c (get_vbytes_common): Return the new slice size.
720 (ctf_bufopen): Flip the endianness of the CTF-section header copy.
721 Remember to copy in the CTF data when opening an uncompressed
722 foreign-endian CTF file. Prune useless variable manipulation.
724 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
726 * ctf-open.c (ctf_types): Fail when unidentified type kinds are
729 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
731 * ctf-open.c (ctf_bufopen): Dump header offsets into the debugging
734 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
736 * ctf-subr.c (_PAGESIZE): Remove.
737 (ctf_data_alloc): Likewise.
738 (ctf_data_free): Likewise.
739 (ctf_data_protect): Likewise.
740 * ctf-impl.h: Remove declarations.
741 * ctf-create.c (ctf_update): No longer call ctf_data_protect: use
742 ctf_free, not ctf_data_free.
743 (ctf_compress_write): Use ctf_data_alloc, not ctf_alloc. Free
744 the buffer again on compression error.
745 * ctf-open.c (ctf_set_base): No longer track the size: call
746 ctf_free, not ctf_data_free.
747 (upgrade_types): Likewise. Call ctf_alloc, not ctf_data_alloc.
748 (ctf_bufopen): Likewise. No longer call ctf_data_protect.
750 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
752 * ctf-create.c (ctf_dtd_insert): Pass on error returns from
754 (ctf_dvd_insert): Likewise.
755 (ctf_add_generic): Likewise.
756 (ctf_add_variable): Likewise.
757 * ctf-impl.h: Adjust declarations.
759 2019-06-14 Alan Modra <amodra@gmail.com>
761 * configure: Regenerate.
763 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
765 * ctf-decls.h: Include <libiberty.h>.
766 * ctf-lookup.c (ctf_lookup_by_name): Call xstrndup(), not strndup().
768 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
770 * ctf-dump.c (ctf_dump_format_type): Cast size_t's used in printf()s.
771 (ctf_dump_objts): Likewise.
772 (ctf_dump_funcs): Likewise.
773 (ctf_dump_member): Likewise.
774 (ctf_dump_str): Likewise.
776 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
778 * ctf-archive.c (arc_mmap_header): Mark fd as potentially unused.
779 * ctf-subr.c (ctf_data_protect): Mark both args as potentially unused.
781 2019-06-05 Nick Alcock <nick.alcock@oracle.com>
783 * ctf-archive.c (ctf_arc_write): Eschew %zi format specifier.
784 (ctf_arc_open_by_offset): Likewise.
785 * ctf-create.c (ctf_add_type): Likewise.
787 2019-06-04 Tom Tromey <tromey@adacore.com>
789 * ctf-create.c (ctf_add_encoded, ctf_add_slice)
790 (ctf_add_member_offset): Use CHAR_BIT, not NBBY.
792 2019-06-04 Nick Alcock <nick.alcock@oracle.com>
794 * configure.ac: Check for O_CLOEXEC.
795 * ctf-decls.h (O_CLOEXEC): Define (to 0), if need be.
796 * config.h.in: Regenerate.
797 * configure: Likewise.
799 2019-06-04 Nick Alcock <nick.alcock@oracle.com>
801 * qsort_r.c: Rename to...
802 * ctf-qsort_r.c: ... this.
803 (_quicksort): Define to ctf_qsort_r.
804 * ctf-decls.h (qsort_r): Remove.
806 (struct ctf_qsort_arg): New, transport the real ARG and COMPAR.
807 (ctf_qsort_compar_thunk): Rearrange the arguments to COMPAR.
808 * Makefile.am (libctf_a_LIBADD): Remove.
809 (libctf_a_SOURCES): New, add ctf-qsort_r.c.
810 * ctf-archive.c (ctf_arc_write): Call ctf_qsort_r, not qsort_r.
811 * ctf-create.c (ctf_update): Likewise.
812 * configure.ac: Check for BSD versus GNU qsort_r signature.
813 * Makefile.in: Regenerate.
814 * config.h.in: Likewise.
815 * configure: Likewise.
817 2019-06-03 Nick Alcock <nick.alcock@oracle.com>
819 * ctf-dump.c (ctf_dump_funcs): Free in the right place.
821 2019-05-29 Nick Alcock <nick.alcock@oracle.com>
823 * Makefile.am (ZLIB): New.
825 (AM_CFLAGS): Use them.
826 (libctf_a_LIBADD): New, for LIBOBJS.
827 * configure.ac: Check for zlib, endian.h, and qsort_r.
828 * ctf-endian.h: New, providing htole64 and le64toh.
829 * swap.h: Code style fixes.
830 (bswap_identity_64): New.
831 * qsort_r.c: New, from gnulib (with one added #include).
832 * ctf-decls.h: New, providing a conditional qsort_r declaration,
833 and unconditional definitions of MIN and MAX.
834 * ctf-impl.h: Use it. Do not use <sys/errno.h>.
835 (ctf_set_errno): Now returns unsigned long.
836 * ctf-util.c (ctf_set_errno): Adjust here too.
837 * ctf-archive.c: Use ctf-endian.h.
838 (ctf_arc_open_by_offset): Use memset, not bzero. Drop cts_type,
839 cts_flags and cts_offset.
840 (ctf_arc_write): Drop debugging dependent on the size of off_t.
841 * ctf-create.c: Provide a definition of roundup if not defined.
842 (ctf_create): Drop cts_type, cts_flags and cts_offset.
843 (ctf_add_reftype): Do not check if type IDs are below zero.
844 (ctf_add_slice): Likewise.
845 (ctf_add_typedef): Likewise.
846 (ctf_add_member_offset): Cast error-returning ssize_t's to size_t
847 when known error-free. Drop CTF_ERR usage for functions returning
849 (ctf_add_member_encoded): Drop CTF_ERR usage for functions returning
851 (ctf_add_variable): Likewise.
855 (ctf_add_type): Likewise. Cast error-returning ssize_t's to size_t
856 when known error-free.
857 * ctf-dump.c (ctf_is_slice): Drop CTF_ERR usage for functions
858 returning int: use CTF_ERR for functions returning ctf_type_id.
859 (ctf_dump_label): Likewise.
860 (ctf_dump_objts): Likewise.
861 * ctf-labels.c (ctf_label_topmost): Likewise.
862 (ctf_label_iter): Likewise.
863 (ctf_label_info): Likewise.
864 * ctf-lookup.c (ctf_func_args): Likewise.
865 * ctf-open.c (upgrade_types): Cast to size_t where appropriate.
866 (ctf_bufopen): Likewise. Use zlib types as needed.
867 * ctf-types.c (ctf_member_iter): Drop CTF_ERR usage for functions
869 (ctf_enum_iter): Likewise.
870 (ctf_type_size): Likewise.
871 (ctf_type_align): Likewise. Cast to size_t where appropriate.
872 (ctf_type_kind_unsliced): Likewise.
873 (ctf_type_kind): Likewise.
874 (ctf_type_encoding): Likewise.
875 (ctf_member_info): Likewise.
876 (ctf_array_info): Likewise.
877 (ctf_enum_value): Likewise.
878 (ctf_type_rvisit): Likewise.
879 * ctf-open-bfd.c (ctf_bfdopen): Drop cts_type, cts_flags and
881 (ctf_simple_open): Likewise.
882 (ctf_bfdopen_ctfsect): Likewise. Set cts_size properly.
883 * Makefile.in: Regenerate.
884 * aclocal.m4: Likewise.
885 * config.h: Likewise.
886 * configure: Likewise.
888 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
890 * configure.in: Check for bfd_section_from_elf_index.
891 * configure: Regenerate.
892 * config.h.in [HAVE_BFD_ELF]: Likewise.
893 * libctf/ctf_open_bfd (ctf_bfdopen_ctfsect): Use it.
894 abfd is potentially unused now.
896 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
899 * Makefile.in: Regenerated.
900 * config.h.in: Likewise.
901 * aclocal.m4: Likewise.
902 * configure: Likewise.
904 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
908 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
912 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
914 * ctf-impl.h (_libctf_version): New declaration.
915 * ctf-subr.c (_libctf_version): Define it.
918 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
920 * ctf-create.c (enumcmp): New.
924 (ctf_add_type): Likewise.
926 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
928 * ctf-lookup.c (isqualifier): New.
929 (ctf_lookup_by_name): Likewise.
930 (struct ctf_lookup_var_key): Likewise.
931 (ctf_lookup_var): Likewise.
932 (ctf_lookup_variable): Likewise.
933 (ctf_lookup_symbol_name): Likewise.
934 (ctf_lookup_by_symbol): Likewise.
935 (ctf_func_info): Likewise.
936 (ctf_func_args): Likewise.
938 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
940 * ctf-decl.c: New file.
941 * ctf-types.c: Likewise.
942 * ctf-impl.h: New declarations.
944 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
946 * ctf-open-bfd.c: New file.
947 * ctf-open.c (ctf_close): New.
948 * ctf-impl.h: Include bfd.h.
949 (ctf_file): New members ctf_data_mmapped, ctf_data_mmapped_len.
950 (ctf_archive_internal): New members ctfi_abfd, ctfi_data,
952 (ctf_bfdopen_ctfsect): New declaration.
953 (_CTF_SECTION): likewise.
955 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
957 * ctf-archive.c: New.
958 * ctf-impl.h (ctf_archive_internal): New type.
959 (ctf_arc_open_internal): New declaration.
960 (ctf_arc_bufopen): Likewise.
961 (ctf_arc_close_internal): Likewise.
963 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
965 * ctf-open.c: New file.
968 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
970 * ctf-create.c: New file.
971 * ctf-lookup.c: New file.
973 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
975 * ctf-impl.h: New definitions and declarations for type creation
978 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
980 * ctf-hash.c: New file.
981 * ctf-impl.h: New declarations.
983 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
985 * ctf-error.c: New file.
987 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
989 * ctf-util.c: New file.
991 * ctf-impl.h: Include it, and add declarations.
993 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
995 * ctf-impl.h: New file.
996 * ctf-subr.c: New file.
1003 version-control: never