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