1 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
3 * ctf-link.c (ctf_link_deduplicating): Clean up the ctf_link_outputs
6 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
8 * ctf-create.c (ctf_dtd_insert): Set ENOMEM on the dict if out of memory.
9 (ctf_dvd_insert): Likewise.
10 (ctf_add_function): Report ECTF_RDONLY if this dict is not writable.
11 * ctf-subr.c (ctf_err_warn): Only debug-dump passed-in warnings if
12 the passed-in error code is nonzero: the error on the dict for
13 warnings may relate to a previous error.
15 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
17 * ctf-open.c (ctf_getsymsect): New.
18 (ctf_getstrsect): Likewise.
19 * libctf.ver: Add them.
21 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
23 * ctf-impl.h (struct ctf_archive_internal) <ctfi_dicts>: New, dicts
24 the archive machinery has opened and cached.
25 <ctfi_symdicts>: New, cache of dicts containing symbols looked up.
26 <ctfi_syms>: New, cache of types of symbols looked up.
27 * ctf-archive.c (ctf_arc_close): Free them on close.
28 (enosym): New, flag entry for 'symbol not present'.
29 (ctf_arc_import_parent): New, automatically import the parent from
30 ".ctf" if this is a child in an archive and ".ctf" is present.
31 (ctf_dict_open_sections): Use it.
32 (ctf_archive_iter_internal): Likewise.
33 (ctf_cached_dict_close): New, thunk around ctf_dict_close.
34 (ctf_dict_open_cached): New, open and cache a dict.
35 (ctf_arc_flush_caches): New, flush the caches.
36 (ctf_arc_lookup_symbol): New, look up a symbol in (all members of)
37 an archive, and cache the lookup.
38 (ctf_archive_iter): Note the new caching behaviour.
39 (ctf_archive_next): Use ctf_dict_open_cached.
40 * libctf.ver: Add ctf_arc_lookup_symbol and ctf_arc_flush_caches.
42 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
44 * ctf-dedup.c (ctf_dedup_rhash_type): Null out the names of nameless
45 type kinds, just in case the input has named them.
47 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
49 * ctf-dump.c (ctf_dump_header): Dump the new flags bits and the index
51 (ctf_dump_objts): Report indexed sections. Also dump functions. Use
52 ctf_symbol_next, not manual looping.
53 (ctf_dump_funcs): Delete.
54 (ctf_dump): Use ctf_dump_objts, not ctf_dump_funcs.
56 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
58 * ctf-impl.h (CTF_INDEX_PAD_THRESHOLD): New.
59 (_libctf_nonnull_): Likewise.
60 (ctf_in_flight_dynsym_t): New.
61 (ctf_dict_t) <ctf_funcidx_names>: Likewise.
62 <ctf_objtidx_names>: Likewise.
63 <ctf_nfuncidx>: Likewise.
64 <ctf_nobjtidx>: Likewise.
65 <ctf_funcidx_sxlate>: Likewise.
66 <ctf_objtidx_sxlate>: Likewise.
67 <ctf_objthash>: Likewise.
68 <ctf_funchash>: Likewise.
69 <ctf_dynsyms>: Likewise.
70 <ctf_dynsymidx>: Likewise.
71 <ctf_dynsymmax>: Likewise.
72 <ctf_in_flight_dynsym>: Likewise.
73 (struct ctf_next) <u.ctn_next>: Likewise.
74 (ctf_symtab_skippable): New prototype.
75 (ctf_add_funcobjt_sym): Likewise.
76 (ctf_dynhash_sort_by_name): Likewise.
77 (ctf_sym_to_elf64): Rename to...
78 (ctf_elf32_to_link_sym): ... this, and...
79 (ctf_elf64_to_link_sym): ... this.
80 * ctf-open.c (init_symtab): Check for lack of CTF_F_NEWFUNCINFO
81 flag, and presence of index sections. Refactor out
82 ctf_symtab_skippable and ctf_elf*_to_link_sym, and use them. Use
83 ctf_link_sym_t, not Elf64_Sym. Skip initializing objt or func
84 sxlate sections if corresponding index section is present. Adjust
85 for new func info section format.
86 (ctf_bufopen_internal): Add ctf_err_warn to corrupt-file error
87 handling. Report incorrect-length index sections. Always do an
88 init_symtab, even if there is no symtab section (there may be index
90 (flip_objts): Adjust comment: func and objt sections are actually
91 identical in structure now, no need to caveat.
92 (ctf_dict_close): Free newly-added data structures.
93 * ctf-create.c (ctf_create): Initialize them.
94 (ctf_symtab_skippable): New, refactored out of
95 init_symtab, with st_nameidx_set check added.
96 (ctf_add_funcobjt_sym): New, add a function or object symbol to the
97 ctf_objthash or ctf_funchash, by name.
98 (ctf_add_objt_sym): Call it.
99 (ctf_add_func_sym): Likewise.
100 (symtypetab_delete_nonstatic_vars): New, delete vars also present as
102 (CTF_SYMTYPETAB_EMIT_FUNCTION): New flag to symtypetab emitters:
103 this is a function emission, not a data object emission.
104 (CTF_SYMTYPETAB_EMIT_PAD): New flag to symtypetab emitters: emit
105 pads for symbols with no type (only set for unindexed sections).
106 (CTF_SYMTYPETAB_FORCE_INDEXED): New flag to symtypetab emitters:
108 (symtypetab_density): New, figure out section sizes.
109 (emit_symtypetab): New, emit a symtypetab.
110 (emit_symtypetab_index): New, emit a symtypetab index.
111 (ctf_serialize): Call them, emitting suitably sorted symtypetab
112 sections and indexes. Set suitable header flags. Copy over new
114 * ctf-hash.c (ctf_dynhash_sort_by_name): New, used to impose an
115 order on symtypetab index sections.
116 * ctf-link.c (ctf_add_type_mapping): Delete erroneous comment
117 relating to code that was never committed.
118 (ctf_link_one_variable): Improve variable name.
119 (check_sym): New, symtypetab analogue of check_variable.
120 (ctf_link_deduplicating_one_symtypetab): New.
121 (ctf_link_deduplicating_syms): Likewise.
122 (ctf_link_deduplicating): Call them.
123 (ctf_link_deduplicating_per_cu): Note that we don't call them in
125 (ctf_link_add_strtab): Set the error on the fp correctly.
126 (ctf_link_add_linker_symbol): New (no longer a do-nothing stub), add
127 a linker symbol to the in-flight list.
128 (ctf_link_shuffle_syms): New (no longer a do-nothing stub), turn the
129 in-flight list into a mapping we can use, now its names are
130 resolvable in the external strtab.
131 * ctf-string.c (ctf_str_rollback_atom): Don't roll back atoms with
132 external strtab offsets.
133 (ctf_str_rollback): Adjust comment.
134 (ctf_str_write_strtab): Migrate ctf_syn_ext_strtab population from
136 (ctf_str_add_external): ... to string addition time.
137 * ctf-lookup.c (ctf_lookup_var_key_t): Rename to...
138 (ctf_lookup_idx_key_t): ... this, now we use it for syms too.
139 <clik_names>: New member, a name table.
140 (ctf_lookup_var): Adjust accordingly.
141 (ctf_lookup_variable): Likewise.
142 (ctf_lookup_by_id): Shuffle further up in the file.
143 (ctf_symidx_sort_arg_cb): New, callback for...
144 (sort_symidx_by_name): ... this new function to sort a symidx
145 found to be unsorted (likely originating from the compiler).
146 (ctf_symidx_sort): New, sort a symidx.
147 (ctf_lookup_symbol_name): Support dynamic symbols with indexes
148 provided by the linker. Use ctf_link_sym_t, not Elf64_Sym.
149 Check the parent if a child lookup fails.
150 (ctf_lookup_by_symbol): Likewise. Work for function symbols too.
151 (ctf_symbol_next): New, iterate over symbols with types (without
153 (ctf_lookup_idx_name): New, bsearch for symbol names in indexes.
154 (ctf_try_lookup_indexed): New, attempt an indexed lookup.
155 (ctf_func_info): Reimplement in terms of ctf_lookup_by_symbol.
156 (ctf_func_args): Likewise.
157 (ctf_get_dict): Move...
158 * ctf-types.c (ctf_get_dict): ... here.
159 * ctf-util.c (ctf_sym_to_elf64): Re-express as...
160 (ctf_elf64_to_link_sym): ... this. Add new st_symidx field, and
161 st_nameidx_set (always 0, so st_nameidx can be ignored). Look in
162 the ELF strtab for names.
163 (ctf_elf32_to_link_sym): Likewise, for Elf32_Sym.
164 (ctf_next_destroy): Destroy ctf_next_t.u.ctn_next if need be.
165 * libctf.ver: Add ctf_symbol_next, ctf_add_objt_sym and
168 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
170 * ctf-link.c (ctf_link_shuffle_syms): Adjust.
171 (ctf_link_add_linker_symbol): New, unimplemented stub.
172 * libctf.ver: Add it.
173 * ctf-create.c (ctf_serialize): Set CTF_F_DYNSTR on newly-serialized
175 * ctf-open-bfd.c (ctf_bfdopen_ctfsect): Check for the flag: open the
176 symtab/strtab if not present, dynsym/dynstr otherwise.
177 * ctf-archive.c (ctf_arc_bufpreamble): New, get the preamble from
178 some arbitrary member of a CTF archive.
179 * ctf-impl.h (ctf_arc_bufpreamble): Declare it.
181 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
183 * ctf-archive.c (ctf_arc_open_by_offset): Rename to...
184 (ctf_dict_open_by_offset): ... this. Adjust callers.
185 (ctf_arc_open_by_name_internal): Rename to...
186 (ctf_dict_open_internal): ... this. Adjust callers.
187 (ctf_arc_open_by_name_sections): Rename to...
188 (ctf_dict_open_sections): ... this, keeping compatibility function.
189 (ctf_arc_open_by_name): Rename to...
190 (ctf_dict_open): ... this, keeping compatibility function.
191 * libctf.ver: New functions added.
192 * ctf-link.c (ctf_link_one_input_archive): Adjusted accordingly.
193 (ctf_link_deduplicating_open_inputs): Likewise.
195 2020-11-20 Nick Alcock <nick.alcock@oracle.com>
197 * ctf-impl.h: Rename ctf_file_t to ctf_dict_t: all declarations
199 (ctf_fileops): Rename to...
200 (ctf_dictops): ... this.
201 (ctf_dedup_t) <cd_id_to_file_t>: Rename to...
202 <cd_id_to_dict_t>: ... this.
203 (ctf_file_t): Fix outdated comment.
204 <ctf_fileops>: Rename to...
205 <ctf_dictops>: ... this.
206 (struct ctf_archive_internal) <ctfi_file>: Rename to...
207 <ctfi_dict>: ... this.
208 * ctf-archive.c: Rename ctf_file_t to ctf_dict_t.
209 Rename ctf_archive.ctfa_nfiles to ctfa_ndicts.
210 Rename ctf_file_close to ctf_dict_close. All users adjusted.
211 * ctf-create.c: Likewise. Refer to CTF dicts, not CTF containers.
212 (ctf_bundle_t) <ctb_file>: Rename to...
213 <ctb_dict): ... this.
214 * ctf-decl.c: Rename ctf_file_t to ctf_dict_t.
215 * ctf-dedup.c: Likewise. Rename ctf_file_close to
216 ctf_dict_close. Refer to CTF dicts, not CTF containers.
217 * ctf-dump.c: Likewise.
218 * ctf-error.c: Likewise.
219 * ctf-hash.c: Likewise.
220 * ctf-inlines.h: Likewise.
221 * ctf-labels.c: Likewise.
222 * ctf-link.c: Likewise.
223 * ctf-lookup.c: Likewise.
224 * ctf-open-bfd.c: Likewise.
225 * ctf-string.c: Likewise.
226 * ctf-subr.c: Likewise.
227 * ctf-types.c: Likewise.
228 * ctf-util.c: Likewise.
229 * ctf-open.c: Likewise.
230 (ctf_file_close): Rename to...
231 (ctf_dict_close): ...this.
232 (ctf_file_close): New trivial wrapper around ctf_dict_close, for
234 (ctf_parent_file): Rename to...
235 (ctf_parent_dict): ... this.
236 (ctf_parent_file): New trivial wrapper around ctf_parent_dict, for
238 * libctf.ver: Add ctf_dict_close and ctf_parent_dict.
240 2020-10-21 Tom Tromey <tromey@adacore.com>
242 * mkerrors.sed: Remove.
243 * ctf-error.c (_CTF_FIRST): New define.
244 (_CTF_ITEM): Define this, not _CTF_STR.
245 (_ctf_errlist, _ctf_erridx): Use _CTF_ERRORS.
246 (ERRSTRFIELD): Rewrite.
247 (ERRSTRFIELD1): Remove.
248 * Makefile.in: Rebuild.
249 * Makefile.am (BUILT_SOURCES): Remove.
250 (ctf-error.h): Remove.
252 2020-08-27 Nick Alcock <nick.alcock@oracle.com>
254 * ctf-subr.c (open_errors): New list.
255 (ctf_err_warn): Calls with NULL fp append to open_errors. Add err
256 parameter, and use it to decorate the debug stream with errmsgs.
257 (ctf_err_warn_to_open): Splice errors from a CTF dict into the
259 (ctf_errwarning_next): Calls with NULL fp report from open_errors.
260 New err param to report iteration errors (including end-of-iteration)
262 (ctf_assert_fail_internal): Adjust ctf_err_warn call for new err
263 parameter: gettextize.
264 * ctf-impl.h (ctfo_get_vbytes): Add ctf_file_t parameter.
265 (LCTF_VBYTES): Adjust.
266 (ctf_err_warn_to_open): New.
267 (ctf_err_warn): Adjust.
268 (ctf_bundle): Used in only one place: move...
269 * ctf-create.c: ... here.
270 (enumcmp): Use ctf_err_warn, not ctf_dprintf, passing the err number
271 down as needed. Don't emit the errmsg. Gettextize.
273 (ctf_add_type_internal): Likewise.
274 (ctf_write_mem): Likewise.
275 (ctf_compress_write): Likewise. Report errors writing the header or
277 (ctf_write): Likewise.
278 * ctf-archive.c (ctf_arc_write_fd): Use ctf_err_warn, not
279 ctf_dprintf, and gettextize, as above.
280 (ctf_arc_write): Likewise.
281 (ctf_arc_bufopen): Likewise.
282 (ctf_arc_open_internal): Likewise.
283 * ctf-labels.c (ctf_label_iter): Likewise.
284 * ctf-open-bfd.c (ctf_bfdclose): Likewise.
285 (ctf_bfdopen): Likewise.
286 (ctf_bfdopen_ctfsect): Likewise.
287 (ctf_fdopen): Likewise.
288 * ctf-string.c (ctf_str_write_strtab): Likewise.
289 * ctf-types.c (ctf_type_resolve): Likewise.
290 * ctf-open.c (get_vbytes_common): Likewise. Pass down the ctf dict.
291 (get_vbytes_v1): Pass down the ctf dict.
292 (get_vbytes_v2): Likewise.
293 (flip_ctf): Likewise.
294 (flip_types): Likewise. Use ctf_err_warn, not ctf_dprintf, and
295 gettextize, as above.
296 (upgrade_types_v1): Adjust calls.
297 (init_types): Use ctf_err_warn, not ctf_dprintf, as above.
298 (ctf_bufopen_internal): Likewise. Adjust calls. Transplant errors
299 emitted into individual dicts into the open errors if this turns
300 out to be a failed open in the end.
301 * ctf-dump.c (ctf_dump_format_type): Adjust ctf_err_warn for new err
302 argument. Gettextize. Don't emit the errmsg.
303 (ctf_dump_funcs): Likewise. Collapse err label into its only case.
304 (ctf_dump_type): Likewise.
305 * ctf-link.c (ctf_create_per_cu): Adjust ctf_err_warn for new err
306 argument. Gettextize. Don't emit the errmsg.
307 (ctf_link_one_type): Likewise.
308 (ctf_link_lazy_open): Likewise.
309 (ctf_link_one_input_archive): Likewise.
310 (ctf_link_deduplicating_count_inputs): Likewise.
311 (ctf_link_deduplicating_open_inputs): Likewise.
312 (ctf_link_deduplicating_close_inputs): Likewise.
313 (ctf_link_deduplicating): Likewise.
314 (ctf_link): Likewise.
315 (ctf_link_deduplicating_per_cu): Likewise. Add some missed
316 ctf_set_errnos to obscure error cases.
317 * ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_err_warn for new
318 err argument. Gettextize. Don't emit the errmsg.
319 (ctf_dedup_populate_mappings): Likewise.
320 (ctf_dedup_detect_name_ambiguity): Likewise.
321 (ctf_dedup_init): Likewise.
322 (ctf_dedup_multiple_input_dicts): Likewise.
323 (ctf_dedup_conflictify_unshared): Likewise.
324 (ctf_dedup): Likewise.
325 (ctf_dedup_rwalk_one_output_mapping): Likewise.
326 (ctf_dedup_id_to_target): Likewise.
327 (ctf_dedup_emit_type): Likewise.
328 (ctf_dedup_emit_struct_members): Likewise.
329 (ctf_dedup_populate_type_mapping): Likewise.
330 (ctf_dedup_populate_type_mappings): Likewise.
331 (ctf_dedup_emit): Likewise.
332 (ctf_dedup_hash_type): Likewise. Fix a bit of messed-up error
334 (ctf_dedup_rwalk_one_output_mapping): Likewise. Don't hide
335 unknown-type-kind messages (which signify file corruption).
337 2020-08-27 Nick Alcock <nick.alcock@oracle.com>
339 * configure.ac: Adjust package name to simply 'libctf': arbitrarily
340 declare this to be version 1.2.0.
341 * Makefile.am (AM_CPPFLAGS): Add @INCINTL@.
342 * Makefile.in: Regenerated.
343 * configure: Regenerated.
344 * ctf-intl.h: New file, lightly modified from opcodes/opintl.h.
345 * ctf-impl.h: Include it.
346 * ctf-error.r (_ctf_errlist_t): Mark strings as noop-translatable.
347 (ctf_errmsg): Actually translate them.
349 2020-07-26 Eli Zaretskii <eliz@gnu.org>
352 * ctf-create.c (EOVERFLOW): If not defined by system header,
353 redirect to ERANGE as a poor man's substitute.
354 * ctf-subr.c (ENOTSUP): If not defined, use ENOSYS instead.
356 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
358 * ctf-create.c (ctf_dtd_insert): Add uintptr_t casts.
359 (ctf_dtd_delete): Likewise.
360 (ctf_dtd_lookup): Likewise.
361 (ctf_rollback): Likewise.
362 * ctf-hash.c (ctf_hash_lookup_type): Likewise.
363 * ctf-types.c (ctf_lookup_by_rawhash): Likewise.
365 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
367 * ctf-lookup.c (ctf_lookup_by_name): Adjust.
369 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
371 * ctf-archive.c (ctf_arc_bufopen): Endian-swap the archive magic
374 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
376 * ctf-impl.h (ctf_list_splice): New.
377 * ctf-util.h (ctf_list_splice): Likewise.
378 * ctf-link.c (link_sort_inputs_cb_arg_t): Likewise.
379 (ctf_link_sort_inputs): Likewise.
380 (ctf_link_deduplicating_count_inputs): Likewise.
381 (ctf_link_deduplicating_open_inputs): Likewise.
382 (ctf_link_deduplicating_close_inputs): Likewise.
383 (ctf_link_deduplicating_variables): Likewise.
384 (ctf_link_deduplicating_per_cu): Likewise.
385 (ctf_link_deduplicating): Likewise.
388 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
390 * ctf-link.c (ctf_link_one_input_archive_member): Check
391 CTF_LINK_OMIT_VARIABLES_SECTION.
393 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
395 * ctf-impl.h (ctf_type_id_key): New, the key in the
397 (ctf_dedup): New, core deduplicator state.
398 (ctf_file_t) <ctf_dedup>: New.
399 <ctf_dedup_atoms>: New.
400 <ctf_dedup_atoms_alloc>: New.
401 (ctf_hash_type_id_key): New prototype.
402 (ctf_hash_eq_type_id_key): Likewise.
403 (ctf_dedup_atoms_init): Likewise.
404 * ctf-hash.c (ctf_hash_eq_type_id_key): New.
405 (ctf_dedup_atoms_init): Likewise.
406 * ctf-create.c (ctf_serialize): Adjusted.
407 (ctf_add_encoded): No longer static.
408 (ctf_add_reftype): Likewise.
409 * ctf-open.c (ctf_file_close): Destroy the
410 ctf_dedup_atoms_alloc.
411 * ctf-dedup.c: New file.
412 * ctf-decls.h [!HAVE_DECL_STPCPY]: Add prototype.
413 * configure.ac: Check for stpcpy.
414 * Makefile.am: Add it.
415 * Makefile.in: Regenerate.
416 * config.h.in: Regenerate.
417 * configure: Regenerate.
419 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
421 * configure.ac: Add --enable-libctf-hash-debugging.
422 * aclocal.m4: Pull in enable.m4, for GCC_ENABLE.
423 * Makefile.in: Regenerated.
424 * configure: Likewise.
425 * config.h.in: Likewise.
426 * ctf-impl.h [ENABLE_LIBCTF_HASH_DEBUGGING]
427 (ctf_assert): Define to assert.
429 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
431 * ctf-sha1.h: New, inline wrappers around sha1_init_ctx and
433 * ctf-impl.h: Include it.
434 (ctf_sha1_init): New.
435 (ctf_sha1_add): Likewise.
436 (ctf_sha1_fini): Likewise.
437 * ctf-sha1.c: New, non-inline wrapper around sha1_finish_ctx
439 * Makefile.am: Add file.
440 * Makefile.in: Regenerate.
442 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
444 * libctf.ver (ctf_link_set_variable_filter): Add.
445 * ctf-impl.h (ctf_file_t) <ctf_link_variable_filter>: New.
446 <ctf_link_variable_filter_arg>: Likewise.
447 * ctf-create.c (ctf_serialize): Adjust.
448 * ctf-link.c (ctf_link_set_variable_filter): New, set it.
449 (ctf_link_one_variable): Call it if set.
451 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
453 * ctf-link.c (ctf_link_one_variable): Check the dst_type for
454 conflicts, not the source type.
456 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
458 * ctf-impl.h (ctf_file_t): Improve comments.
459 <ctf_link_cu_mapping>: Split into...
460 <ctf_link_in_cu_mapping>: ... this...
461 <ctf_link_out_cu_mapping>: ... and this.
462 * ctf-create.c (ctf_serialize): Adjust.
463 * ctf-open.c (ctf_file_close): Likewise.
464 * ctf-link.c (ctf_create_per_cu): Look things up in the
465 in_cu_mapping instead of the cu_mapping.
466 (ctf_link_add_cu_mapping): The deduplicating link will define
467 what happens if many FROMs share a TO.
468 (ctf_link_add_cu_mapping): Create in_cu_mapping and
469 out_cu_mapping. Do not create ctf_link_outputs here any more, or
470 create per-CU dicts here: they are already created when needed.
471 (ctf_link_one_variable): Log a debug message if we skip a
472 variable due to its type being concealed in a CU-mapped link.
473 (This is probably too common a case to make into a warning.)
474 (ctf_link): Create empty per-CU dicts if requested.
476 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
478 * ctf-link.c (ctf_link_write): Close the fd.
480 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
482 * Makefile.am: Set -DNOBFD=1 in libctf-nobfd, and =0 elsewhere.
483 * Makefile.in: Regenerated.
484 * ctf-impl.h (ctf_link_input_name): New.
485 (ctf_file_t) <ctf_link_flags>: New.
486 * ctf-create.c (ctf_serialize): Adjust accordingly.
487 * ctf-link.c: Define ctf_open as weak when PIC.
488 (ctf_arc_close_thunk): Remove unnecessary thunk.
489 (ctf_file_close_thunk): Likewise.
490 (ctf_link_input_name): New.
491 (ctf_link_input_t): New value of the ctf_file_t.ctf_link_input.
492 (ctf_link_input_close): Adjust accordingly.
493 (ctf_link_add_ctf_internal): New, split from...
494 (ctf_link_add_ctf): ... here. Return error if lazy loading of
495 CTF is not possible. Change to just call...
496 (ctf_link_add): ... this new function.
497 (ctf_link_add_cu_mapping): Transition to ctf_err_warn. Drop the
498 ctf_file_close_thunk.
499 (ctf_link_in_member_cb_arg_t) <file_name> Rename to...
500 <in_file_name>: ... this.
502 <share_mode>: Likewise (migrated to ctf_link_flags).
503 <done_main_member>: Rename to...
504 <done_parent>: ... this.
505 <main_input_fp>: Rename to...
506 <in_fp_parent>: ... this.
508 (ctf_link_one_type): Adjuwt accordingly. Transition to
509 ctf_err_warn, removing a TODO.
510 (ctf_link_one_variable): Note a case too common to warn about.
511 Report in the debug stream if a cu-mapped link prevents addition
512 of a conflicting variable.
513 (ctf_link_one_input_archive_member): Adjust.
514 (ctf_link_lazy_open): New, open a CTF archive for linking when
516 (ctf_link_close_one_input_archive): New, close it again.
517 (ctf_link_one_input_archive): Adjust for lazy opening, member
518 renames, and ctf_err_warn transition. Move the
519 empty_link_type_mapping call to...
520 (ctf_link): ... here. Adjut for renamings and thunk removal.
521 Don't spuriously fail if some input contains no CTF data.
522 (ctf_link_write): ctf_err_warn transition.
523 * libctf.ver: Remove not-yet-stable comment.
525 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
527 * ctf-impl.h (ctf_strerror): Delete.
528 * ctf-subr.c (ctf_strerror): Likewise.
529 * ctf-error.c (ctf_errmsg): Stop using ctf_strerror: just use
532 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
534 * ctf-impl.c (ctf_file_t) <ctf_parent_unreffed>: New.
535 (ctf_import_unref): New.
536 * ctf-open.c (ctf_file_close) Drop the refcount all the way to
537 zero. Don't recurse back in if the refcount is already zero.
538 (ctf_import): Check ctf_parent_unreffed before deciding whether
539 to close a pre-existing parent. Set it to zero.
540 (ctf_import_unreffed): New, as above, setting
541 ctf_parent_unreffed to 1.
542 * ctf-create.c (ctf_serialize): Do not ctf_import into the new
543 child: use direct assignment, and set unreffed on the new and
545 * ctf-link.c (ctf_create_per_cu): Import the parent using
548 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
550 * ctf-impl.h (ctf_link_type_mapping_key): Rename to...
551 (ctf_link_type_key): ... this, adjusting member prefixes to
553 (ctf_hash_type_mapping_key): Rename to...
554 (ctf_hash_type_key): ... this.
555 (ctf_hash_eq_type_mapping_key): Rename to...
556 (ctf_hash_eq_type_key): ... this.
557 * ctf-hash.c (ctf_hash_type_mapping_key): Rename to...
558 (ctf_hash_type_key): ... this, and adjust for member name
560 (ctf_hash_eq_type_mapping_key): Rename to...
561 (ctf_hash_eq_type_key): ... this, and adjust for member name
563 * ctf-link.c (ctf_add_type_mapping): Adjust. Note the lack of
564 need for out-of-memory checking in this code.
565 (ctf_type_mapping): Adjust.
567 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
569 configure.ac: Check for vasprintf.
570 configure: Regenerated.
571 config.h.in: Likewise.
573 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
575 * ctf-archive.c (ctf_arc_bufopen): Fix message.
577 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
579 * ctf-impl.h (struct ctf_archive_internal) <ctfi_free_strsect>
581 * ctf-open-bfd.c (ctf_bfdopen_ctfsect): Explicitly open a strtab
582 if the input has no symtab, rather than dividing by
583 zero. Arrange to free it later via ctfi_free_ctfsect.
584 * ctf-archive.c (ctf_new_archive_internal): Do not
585 ctfi_free_strsect by default.
586 (ctf_arc_close): Possibly free it here.
588 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
590 * ctf-dump.c (ctf_is_slice): Delete, unnecessary.
591 (ctf_dump_format_type): improve slice formatting. Always print
592 the type size, even of slices.
593 (ctf_dump_member): Print slices (-> bitfields) differently from
594 non-slices. Failure to format a type is not an OOM.
596 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
598 * ctf-dump.c (ctf_dump_format_type): Emit a warning.
599 (ctf_dump_label): Swallow errors from ctf_dump_format_type.
600 (ctf_dump_objts): Likewise.
601 (ctf_dump_var): Likewise.
602 (ctf_dump_type): Do not emit a duplicate message. Move to
603 ctf_err_warning, and swallow all errors.
605 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
607 * ctf-decl.c (ctf_decl_fini): Free the cd_buf.
608 (ctf_decl_buf): Once it escapes, don't try to free it later.
610 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
612 * ctf-types.c (ctf_type_aname): Print arg types here...
613 * ctf-dump.c (ctf_dump_funcs): ... not here: but do substitute
614 in the type name here.
616 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
618 * ctf-impl.h (ctf_assert): New.
619 (ctf_err_warning_t): Likewise.
620 (ctf_file_t) <ctf_errs_warnings>: Likewise.
621 (ctf_err_warn): New prototype.
622 (ctf_assert_fail_internal): Likewise.
623 * ctf-inlines.h (ctf_assert_internal): Likewise.
624 * ctf-open.c (ctf_file_close): Free ctf_errs_warnings.
625 * ctf-create.c (ctf_serialize): Copy it on serialization.
626 * ctf-subr.c (ctf_err_warn): New, add an error/warning.
627 (ctf_errwarning_next): New iterator, free and pass back
628 errors/warnings in succession.
629 * libctf.ver (ctf_errwarning_next): Add.
631 2020-07-22 Egeyar Bagcioglu <egeyar.bagcioglu@oracle.com>
633 * ctf-types.c (ctf_variable_iter): Fix error return.
635 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
637 * ctf-open.c (ctf_bufopen_internal): Diagnose invalid flags.
639 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
641 ctf-decls.h (ctf_qsort_compar_thunk): Fix arg passing.
643 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
645 * ctf-impl.h (ctf_next_hkv_t): New, kv-pairs passed to
647 (ctf_next_t) <u.ctn_sorted_hkv>: New, sorted kv-pairs for
648 ctf_dynhash_next_sorted.
649 <cu.ctn_h>: New, pointer to the dynhash under iteration.
650 <cu.ctn_s>: New, pointer to the dynset under iteration.
651 (ctf_hash_sort_f): Sorting function passed to...
652 (ctf_dynhash_next_sorted): ... this new function.
653 (ctf_dynhash_next): New.
654 (ctf_dynset_next): New.
655 * ctf-inlines.h (ctf_dynhash_cnext_sorted): New.
656 (ctf_dynhash_cnext): New.
657 (ctf_dynset_cnext): New.
658 * ctf-hash.c (ctf_dynhash_next_sorted): New.
659 (ctf_dynhash_next): New.
660 (ctf_dynset_next): New.
661 * ctf-util.c (ctf_next_destroy): Free the u.ctn_sorted_hkv if
663 (ctf_next_copy): Alloc-and-copy the u.ctn_sorted_hkv if needed.
665 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
667 * ctf-impl.h (ctf_next): New.
668 (ctf_get_dict): New prototype.
669 * ctf-lookup.c (ctf_get_dict): New, split out of...
670 (ctf_lookup_by_id): ... here.
671 * ctf-util.c (ctf_next_create): New.
672 (ctf_next_destroy): New.
673 (ctf_next_copy): New.
674 * ctf-types.c (includes): Add <assert.h>.
675 (ctf_member_next): New.
676 (ctf_enum_next): New.
677 (ctf_type_iter): Document the lack of iteration over parent
679 (ctf_type_next): New.
680 (ctf_variable_next): New.
681 * ctf-archive.c (ctf_archive_next): New.
682 * libctf.ver: Add new public functions.
684 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
686 * libctf.ver (ctf_ref): New.
687 * ctf-open.c (ctf_ref): Implement it.
689 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
691 * ctf-inlines.h (ctf_forwardable_kind): New.
692 * ctf-create.c (ctf_add_forward): Use it.
694 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
696 * ctf-impl.h (ctf_get_ctt_size): Move definition from here...
697 * ctf-inlines.h (ctf_get_ctt_size): ... to here.
699 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
701 * ctf-hash.c (ctf_dynset_eq_string): New.
702 (ctf_dynset_create): New.
703 (DYNSET_EMPTY_ENTRY_REPLACEMENT): New.
704 (DYNSET_DELETED_ENTRY_REPLACEMENT): New.
705 (key_to_internal): New.
706 (internal_to_key): New.
707 (ctf_dynset_insert): New.
708 (ctf_dynset_remove): New.
709 (ctf_dynset_destroy): New.
710 (ctf_dynset_lookup): New.
711 (ctf_dynset_exists): New.
712 (ctf_dynset_lookup_any): New.
713 (ctf_hash_insert_type): Coding style.
714 (ctf_hash_define_type): Likewise.
715 * ctf-impl.h (ctf_dynset_t): New.
716 (ctf_dynset_eq_string): New.
717 (ctf_dynset_create): New.
718 (ctf_dynset_insert): New.
719 (ctf_dynset_remove): New.
720 (ctf_dynset_destroy): New.
721 (ctf_dynset_lookup): New.
722 (ctf_dynset_exists): New.
723 (ctf_dynset_lookup_any): New.
724 * ctf-inlines.h (ctf_dynset_cinsert): New.
726 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
728 * ctf-hash.c (ctf_helem_t) <key_free>: Remove.
729 <value_free>: Likewise.
731 (ctf_dynhash_item_free): Indirect through the owner.
732 (ctf_dynhash_create): Only pass in ctf_dynhash_item_free and
733 allocate space for the key_free and value_free fields fields
735 (ctf_hashtab_insert): Likewise. Fix OOM errno value.
736 (ctf_dynhash_insert): Only access ctf_hashtab's key_free and
737 value_free if they will exist. Set the slot's owner, but only
739 (ctf_dynhash_remove): Adjust.
741 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
743 * ctf-hash.c (ctf_hashtab_insert): Free the key passed in if
744 there is a key-freeing function and the key already exists.
746 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
748 * ctf-inlines.h: New file.
749 * ctf-impl.h: Include it.
750 (ctf_hash_iter_find_f): New typedef.
751 (ctf_dynhash_elements): New.
752 (ctf_dynhash_lookup_kv): New.
753 (ctf_dynhash_iter_find): New.
754 * ctf-hash.c (ctf_dynhash_lookup_kv): New.
755 (ctf_traverse_find_cb_arg_t): New.
756 (ctf_hashtab_traverse_find): New.
757 (ctf_dynhash_iter_find): New.
758 (ctf_dynhash_elements): New.
760 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
762 * ctf-impl.h [!__GNUC__] (__extension__): Define to nothing.
764 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
766 * ctf-archive.c (ctf_archive_count): New.
767 * libctf.ver: New public function.
769 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
771 * ctf-types.c (ctf_member_count): New.
772 * libctf.ver: New public function.
774 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
776 * ctf-types.c (ctf_type_kind_forwarded): New.
778 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
780 * ctf-types.c (ctf_type_name_raw): New.
781 (ctf_type_aname_raw): Reimplement accordingly.
783 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
785 * ctf-subr.c (ctf_dprintf): _libctf_debug is unlikely to be set.
787 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
789 * ctf-impl.h (struct ctf_archive_internal)
790 <ctfi_unmap_on_close>: New.
791 (ctf_new_archive_internal): Adjust.
792 * ctf-archive.c (ctf_new_archive_internal): Likewise.
793 Initialize ctfi_unmap_on_close. Adjust error path.
794 (ctf_arc_bufopen): Adjust ctf_new_archive_internal call
795 (unmap_on_close is 0).
796 (ctf_arc_close): Only unmap if ctfi_unmap_on_close.
797 * ctf-open-bfd.c (ctf_fdopen): Adjust.
799 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
801 * ctf-types.c (ctf_type_aname): Return ECTF_CORRUPT if
802 ints, floats or typedefs have no name. Fix comment typo.
804 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
806 * ctf-create.c (ctf_add_slice): Support slices of any kind that
807 resolves to an integral type.
808 * ctf-types.c (ctf_type_encoding): Resolve the type before
809 fishing its encoding out.
811 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
813 * ctf-create.c (ctf_create): Mark dirty.
815 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
817 * ctf-create.c (membcmp) Skip nameless members.
819 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
821 * ctf-create.c (ctf_add_member_offset): Support names of ""
822 as if they were the null pointer.
824 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
826 * ctf-open.c (init_types): Remove typeless CTF_K_FORWARD
829 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
831 * ctf-types.c (ctf_type_reference): Add support for dynamic slices.
833 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
835 * ctf-create.c (ctf_serialize): Add cast.
836 (ctf_add_slice): Likewise.
838 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
840 * ctf-impl.h (ctf_dtdef_t) <dtu_argv>: Fix type.
841 * ctf-create.c (ctf_add_function): Check for unimplemented type
842 and populate at the same time. Populate one-by-one, not via
844 (ctf_serialize): Remove unnecessary cast.
845 * ctf-types.c (ctf_func_type_info): Likewise.
846 (ctf_func_type_args): Likewise. Fix comment typo.
848 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
850 * ctf-create.c (ctf_add_reftype): Support refs to type zero.
851 (ctf_add_array): Support array contents of type zero.
852 (ctf_add_function): Support arguments and return types of
854 (ctf_add_typedef): Support typedefs to type zero.
855 (ctf_add_member_offset): Support members of type zero,
856 unless added at unspecified (naturally-aligned) offset.
858 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
860 * ctf-error.c: Include <stddef.h>, for offsetof.
861 (_ctf_errlist): Migrate to...
862 (_ctf_errlist_t): ... this.
863 (_ctf_erridx): New, indexes into _ctf_errlist_t.
865 (ctf_errmsg): Adjust accordingly.
866 * Makefile.am (BUILT_SOURCES): Note...
867 (ctf-error.h): ... this new rule.
868 * Makefile.in: Regenerate.
869 * mkerrors.sed: New, process ctf-api.h to generate ctf-error.h.
870 * .gitignore: New, ignore ctf-error.h.
872 2020-07-22 Nick Alcock <nick.alcock@oracle.com>
874 * ctf-impl.h: Fix typos in comments.
876 2020-07-22 Nick Clifton <nickc@redhat.com>
878 * ctf-archive.c (ctf_arc_write): Avoid calling close twice on the
879 same file descriptor.
881 2020-07-04 Nick Clifton <nickc@redhat.com>
883 Binutils 2.35 branch created.
885 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
887 * aclocal.m4: Add config/gettext-sister.m4: Shuffle into
889 * configure.ac: Add ZW_GNU_GETTEXT_SISTER_DIR.
890 * config.h.in: Regenerated.
891 * Makefile.in: Likewise.
892 * configure: Likewise.
894 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
896 * ctf-create.c: Include <unistd.h>.
897 * ctf-open-bfd.c: Likewise.
899 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
902 * configure.ac: Check for bswap_16, bswap_32, and bswap_64 decls.
903 * swap.h (bswap_16): Do not assume that presence of <byteswap.h>
904 means this is declared.
905 (bswap_32): Likewise.
906 (bswap_64): Likewise.
907 (bswap_identity_64): Remove, unused.
908 * configure: Regenerated.
909 * config.h.in: Likewise.
911 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
914 * ctf-impl.h (_libctf_printflike_): Add non-GNU-C fallback.
915 (_libctf_unlikely_): Likewise.
916 (_libctf_unused): Likewise.
917 (_libctf_malloc_): Likewise.
919 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
922 * ctf-archive.c (search_nametbl): No longer global: declare...
923 (ctf_arc_open_by_name_internal): ... here. Use bsearch_r.
924 (search_modent_by_name): Take and use ARG for the nametbl.
926 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
928 * ctf-impl.h (ctf_new_archive_internal): Declare.
929 (ctf_arc_bufopen): Remove.
930 (ctf_archive_internal) <ctfi_free_symsect>: New.
931 * ctf-archive.c (ctf_arc_close): Use it.
932 (ctf_arc_bufopen): Fuse into...
933 (ctf_new_archive_internal): ... this, moved across from...
934 * ctf-open-bfd.c: ... here.
935 (ctf_bfdopen_ctfsect): Use ctf_arc_bufopen.
936 * libctf.ver: Add it.
938 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
940 * ctf-create.c (ctf_add_forward): Intern in the right namespace.
941 (ctf_dtd_delete): Remove correspondingly.
942 (ctf_rollback): Likewise.
944 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
946 * ctf-create.c (ctf_add_type_internal): Hand back existing types
949 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
951 * ctf-create.c (ctf_add_forward): Don't add forwards to
952 types that already exist.
954 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
956 * ctf-open.c (init_types): Only intern root-visible types.
957 * ctf-create.c (ctf_dtd_insert): Likewise.
958 (ctf_dtd_delete): Only remove root-visible types.
959 (ctf_rollback): Likewise.
960 (ctf_add_generic): Adjust.
961 (ctf_add_struct_sized): Adjust comment.
962 (ctf_add_union_sized): Likewise.
963 (ctf_add_enum): Likewise.
964 * ctf-impl.h (ctf_dtd_insert): Adjust prototype.
966 2020-03-11 John Baldwin <jhb@FreeBSD.org>
968 * swap.h (bswap_identity_64): Make static.
970 2020-01-18 Nick Clifton <nickc@redhat.com>
972 Binutils 2.34 branch created.
974 2020-01-05 Joel Brobecker <brobecker@adacore.com>
977 * configure.ac: Add AC_CHECK_DECLS([asprintf]).
978 * configure, config.h.in: Regenerate.
980 2020-01-01 Alan Modra <amodra@gmail.com>
982 Update year range in copyright notice of all files.
984 2019-10-16 Simon Marchi <simon.marchi@polymtl.ca>
986 * swap.h (bswap_16, bswap_32, bswap_64): Make static.
988 2019-09-30 Nick Alcock <nick.alcock@oracle.com>
990 * ctf-open.c (ctf_bufopen_internal): Fix tabdamage.
991 * ctf-types.c (ctf_type_lname): Likewise.
993 2019-09-23 Nick Alcock <nick.alcock@oracle.com>
995 * ctf-open.c (ctf_import): Do not leak a ctf_file_t ref on every
996 ctf_import after the first for a given file.
998 2019-09-23 Nick Alcock <nick.alcock@oracle.com>
1000 * ctf-impl.h (ctf_str_append_noerr): Declare.
1001 * ctf-util.c (ctf_str_append_noerr): Define in terms of
1003 * ctf-dump.c (str_append): New, call it.
1004 (ctf_dump_format_type): Use str_append, not ctf_str_append.
1005 (ctf_dump_label): Likewise.
1006 (ctf_dump_objts): Likewise.
1007 (ctf_dump_funcs): Likewise.
1008 (ctf_dump_var): Likewise.
1009 (ctf_dump_member): Likewise.
1010 (ctf_dump_type): Likewise.
1011 (ctf_dump): Likewise.
1013 2019-09-23 Nick Alcock <nick.alcock@oracle.com>
1015 * ctf-impl.h (ctf_alloc): Remove.
1016 (ctf_free): Likewise.
1017 (ctf_strdup): Likewise.
1018 * ctf-subr.c (ctf_alloc): Remove.
1019 (ctf_free): Likewise.
1020 * ctf-util.c (ctf_strdup): Remove.
1022 * ctf-create.c (ctf_serialize): Use malloc, not ctf_alloc; free, not
1023 ctf_free; strdup, not ctf_strdup.
1024 (ctf_dtd_delete): Likewise.
1025 (ctf_dvd_delete): Likewise.
1026 (ctf_add_generic): Likewise.
1027 (ctf_add_function): Likewise.
1028 (ctf_add_enumerator): Likewise.
1029 (ctf_add_member_offset): Likewise.
1030 (ctf_add_variable): Likewise.
1031 (membadd): Likewise.
1032 (ctf_compress_write): Likewise.
1033 (ctf_write_mem): Likewise.
1034 * ctf-decl.c (ctf_decl_push): Likewise.
1035 (ctf_decl_fini): Likewise.
1036 (ctf_decl_sprintf): Likewise. Check for OOM.
1037 * ctf-dump.c (ctf_dump_append): Use malloc, not ctf_alloc; free, not
1038 ctf_free; strdup, not ctf_strdup.
1039 (ctf_dump_free): Likewise.
1040 (ctf_dump): Likewise.
1041 * ctf-open.c (upgrade_types_v1): Likewise.
1042 (init_types): Likewise.
1043 (ctf_file_close): Likewise.
1044 (ctf_bufopen_internal): Likewise. Check for OOM.
1045 (ctf_parent_name_set): Likewise: report the OOM to the caller.
1046 (ctf_cuname_set): Likewise.
1047 (ctf_import): Likewise.
1048 * ctf-string.c (ctf_str_purge_atom_refs): Use malloc, not ctf_alloc;
1049 free, not ctf_free; strdup, not ctf_strdup.
1050 (ctf_str_free_atom): Likewise.
1051 (ctf_str_create_atoms): Likewise.
1052 (ctf_str_add_ref_internal): Likewise.
1053 (ctf_str_remove_ref): Likewise.
1054 (ctf_str_write_strtab): Likewise.
1056 2019-08-09 Nick Alcock <nick.alcock@oracle.com>
1058 * ctf-types.c (ctf_type_encoding): Fix the dynamic case to
1059 work right for non-int/fps.
1061 2019-08-08 Nick Alcock <nick.alcock@oracle.com>
1063 * ctf-types.c (ctf_type_name): Don't strlen a potentially-
1066 2019-08-07 Nick Alcock <nick.alcock@oracle.com>
1068 * ctf-impl.h (ctf_file_t) <ctf_add_processing>: New.
1069 * ctf-open.c (ctf_file_close): Free it.
1070 * ctf-create.c (ctf_serialize): Adjust.
1071 (membcmp): When reporting a conflict due to an error, report the
1073 (ctf_add_type): Turn into a ctf_add_processing wrapper. Rename to...
1074 (ctf_add_type_internal): ... this. Hand back types we are already
1075 in the middle of adding immediately. Hand back structs/unions with
1076 the same number of members immediately. Do not walk the dynamic
1077 list. Call ctf_add_type_internal, not ctf_add_type. Handle
1078 forwards promoted to other types and the inverse case identically.
1079 Add structs to the mapping as soon as we intern them, before they
1082 2019-08-09 Nick Alcock <nick.alcock@oracle.com>
1084 * ctf-impl.h (ctf_names_t): New.
1085 (ctf_lookup_t) <ctf_hash>: Now a ctf_names_t, not a ctf_hash_t.
1086 (ctf_file_t) <ctf_structs>: Likewise.
1087 <ctf_unions>: Likewise.
1088 <ctf_enums>: Likewise.
1089 <ctf_names>: Likewise.
1090 <ctf_lookups>: Improve comment.
1091 <ctf_ptrtab_len>: New.
1092 <ctf_prov_strtab>: New.
1093 <ctf_str_prov_offset>: New.
1094 <ctf_dtbyname>: Remove, redundant to the names hashes.
1095 <ctf_dtnextid>: Remove, redundant to ctf_typemax.
1096 (ctf_dtdef_t) <dtd_name>: Remove.
1097 <dtd_data>: Note that the ctt_name is now populated.
1098 (ctf_str_atom_t) <csa_offset>: This is now the strtab
1099 offset for internal strings too.
1100 <csa_external_offset>: New, the external strtab offset.
1101 (CTF_INDEX_TO_TYPEPTR): Handle the LCTF_RDWR case.
1102 (ctf_name_table): New declaration.
1103 (ctf_lookup_by_rawname): Likewise.
1104 (ctf_lookup_by_rawhash): Likewise.
1105 (ctf_set_ctl_hashes): Likewise.
1106 (ctf_serialize): Likewise.
1107 (ctf_dtd_insert): Adjust.
1108 (ctf_simple_open_internal): Likewise.
1109 (ctf_bufopen_internal): Likewise.
1110 (ctf_list_empty_p): Likewise.
1111 (ctf_str_remove_ref): Likewise.
1112 (ctf_str_add): Returns uint32_t now.
1113 (ctf_str_add_ref): Likewise.
1114 (ctf_str_add_external): Now returns a boolean (int).
1115 * ctf-string.c (ctf_strraw_explicit): Check the ctf_prov_strtab
1116 for strings in the appropriate range.
1117 (ctf_str_create_atoms): Create the ctf_prov_strtab. Detect OOM
1118 when adding the null string to the new strtab.
1119 (ctf_str_free_atoms): Destroy the ctf_prov_strtab.
1120 (ctf_str_add_ref_internal): Add make_provisional argument. If
1121 make_provisional, populate the offset and fill in the
1122 ctf_prov_strtab accordingly.
1123 (ctf_str_add): Return the offset, not the string.
1124 (ctf_str_add_ref): Likewise.
1125 (ctf_str_add_external): Return a success integer.
1126 (ctf_str_remove_ref): New, remove a single ref.
1127 (ctf_str_count_strtab): Do not count the initial null string's
1128 length or the existence or length of any unreferenced internal
1130 (ctf_str_populate_sorttab): Skip atoms with no refs.
1131 (ctf_str_write_strtab): Populate the nullstr earlier. Add one
1132 to the cts_len for the null string, since it is no longer done
1133 in ctf_str_count_strtab. Adjust for csa_external_offset rename.
1134 Populate the csa_offset for both internal and external cases.
1135 Flush the ctf_prov_strtab afterwards, and reset the
1136 ctf_str_prov_offset.
1137 * ctf-create.c (ctf_grow_ptrtab): New.
1138 (ctf_create): Call it. Initialize new fields rather than old
1139 ones. Tell ctf_bufopen_internal that this is a writable dictionary.
1140 Set the ctl hashes and data model.
1141 (ctf_update): Rename to...
1142 (ctf_serialize): ... this. Leave a compatibility function behind.
1143 Tell ctf_simple_open_internal that this is a writable dictionary.
1144 Pass the new fields along from the old dictionary. Drop
1145 ctf_dtnextid and ctf_dtbyname. Use ctf_strraw, not dtd_name.
1146 Do not zero out the DTD's ctt_name.
1147 (ctf_prefixed_name): Rename to...
1148 (ctf_name_table): ... this. No longer return a prefixed name: return
1149 the applicable name table instead.
1150 (ctf_dtd_insert): Use it, and use the right name table. Pass in the
1151 kind we're adding. Migrate away from dtd_name.
1152 (ctf_dtd_delete): Adjust similarly. Remove the ref to the
1154 (ctf_dtd_lookup_type_by_name): Remove.
1155 (ctf_dynamic_type): Always return NULL on read-only dictionaries.
1156 No longer check ctf_dtnextid: check ctf_typemax instead.
1157 (ctf_snapshot): No longer use ctf_dtnextid: use ctf_typemax instead.
1158 (ctf_rollback): Likewise. No longer fail with ECTF_OVERROLLBACK. Use
1159 ctf_name_table and the right name table, and migrate away from
1160 dtd_name as in ctf_dtd_delete.
1161 (ctf_add_generic): Pass in the kind explicitly and pass it to
1162 ctf_dtd_insert. Use ctf_typemax, not ctf_dtnextid. Migrate away
1163 from dtd_name to using ctf_str_add_ref to populate the ctt_name.
1164 Grow the ptrtab if needed.
1165 (ctf_add_encoded): Pass in the kind.
1166 (ctf_add_slice): Likewise.
1167 (ctf_add_array): Likewise.
1168 (ctf_add_function): Likewise.
1169 (ctf_add_typedef): Likewise.
1170 (ctf_add_reftype): Likewise. Initialize the ctf_ptrtab, checking
1171 ctt_name rather than dtd_name.
1172 (ctf_add_struct_sized): Pass in the kind. Use
1173 ctf_lookup_by_rawname, not ctf_hash_lookup_type /
1174 ctf_dtd_lookup_type_by_name.
1175 (ctf_add_union_sized): Likewise.
1176 (ctf_add_enum): Likewise.
1177 (ctf_add_enum_encoded): Likewise.
1178 (ctf_add_forward): Likewise.
1179 (ctf_add_type): Likewise.
1180 (ctf_compress_write): Call ctf_serialize: adjust for ctf_size not
1181 being initialized until after the call.
1182 (ctf_write_mem): Likewise.
1183 (ctf_write): Likewise.
1184 * ctf-archive.c (arc_write_one_ctf): Likewise.
1185 * ctf-lookup.c (ctf_lookup_by_name): Use ctf_lookuup_by_rawhash, not
1186 ctf_hash_lookup_type.
1187 (ctf_lookup_by_id): No longer check the readonly types if the
1188 dictionary is writable.
1189 * ctf-open.c (init_types): Assert that this dictionary is not
1190 writable. Adjust to use the new name hashes, ctf_name_table,
1191 and ctf_ptrtab_len. GNU style fix for the final ptrtab scan.
1192 (ctf_bufopen_internal): New 'writable' parameter. Flip on LCTF_RDWR
1193 if set. Drop out early when dictionary is writable. Split the
1194 ctf_lookups initialization into...
1195 (ctf_set_cth_hashes): ... this new function.
1196 (ctf_simple_open_internal): Adjust. New 'writable' parameter.
1197 (ctf_simple_open): Adjust accordingly.
1198 (ctf_bufopen): Likewise.
1199 (ctf_file_close): Destroy the appropriate name hashes. No longer
1200 destroy ctf_dtbyname, which is gone.
1201 (ctf_getdatasect): Remove spurious "extern".
1202 * ctf-types.c (ctf_lookup_by_rawname): New, look up types in the
1203 specified name table, given a kind.
1204 (ctf_lookup_by_rawhash): Likewise, given a ctf_names_t *.
1205 (ctf_member_iter): Add support for iterating over the
1207 (ctf_enum_iter): Likewise.
1208 (ctf_variable_iter): Likewise.
1209 (ctf_type_rvisit): Likewise.
1210 (ctf_member_info): Add support for types in the dynamic type list.
1211 (ctf_enum_name): Likewise.
1212 (ctf_enum_value): Likewise.
1213 (ctf_func_type_info): Likewise.
1214 (ctf_func_type_args): Likewise.
1215 * ctf-link.c (ctf_accumulate_archive_names): No longer call
1217 (ctf_link_write): Likewise.
1218 (ctf_link_intern_extern_string): Adjust for new
1219 ctf_str_add_external return value.
1220 (ctf_link_add_strtab): Likewise.
1221 * ctf-util.c (ctf_list_empty_p): New.
1223 2019-08-05 Nick Alcock <nick.alcock@oracle.com>
1225 * ctf-types.c (ctf_type_resolve): Return ECTF_NONREPRESENTABLE on
1227 * ctf-create.c (ctf_add_type): Detect and skip nonrepresentable
1229 (ctf_add_variable): Likewise for variables pointing to them.
1230 * ctf-link.c (ctf_link_one_type): Do not warn for nonrepresentable
1231 type link failure, but do warn for others.
1232 * ctf-dump.c (ctf_dump_format_type): Likewise. Do not assume all
1233 errors to be ENOMEM.
1234 (ctf_dump_member): Likewise.
1235 (ctf_dump_type): Likewise.
1236 (ctf_dump_header_strfield): Do not assume all errors to be ENOMEM.
1237 (ctf_dump_header_sectfield): Do not assume all errors to be ENOMEM.
1238 (ctf_dump_header): Likewise.
1239 (ctf_dump_label): likewise.
1240 (ctf_dump_objts): likewise.
1241 (ctf_dump_funcs): likewise.
1242 (ctf_dump_var): likewise.
1243 (ctf_dump_str): Likewise.
1245 2019-09-30 Nick Alcock <nick.alcock@oracle.com>
1247 * configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
1248 (LT_INIT): Likewise.
1249 (AM_INSTALL_LIBBFD): Likewise.
1250 (dlopen): Note why this is necessary in a comment.
1251 (SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
1253 (SHARED_LDFLAGS): Likewise.
1254 (BFD_LIBADD): Likewise, for libbfd.
1255 (BFD_DEPENDENCIES): Likewise.
1256 (VERSION_FLAGS): Initialize, using a version script if ld supports
1257 one, or libtool -export-symbols-regex otherwise.
1258 (AC_CONFIG_MACRO_DIR): Add ../BFD.
1259 * Makefile.am (ACLOCAL_AMFLAGS): Likewise.
1261 (AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
1262 (noinst_LIBRARIES): Replace with...
1263 [INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
1264 [!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
1265 libctf-nobfd.la as well.
1266 [INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
1267 [!INSTALL_LIBCTF] (include_HEADERS): New, empty.
1268 (libctf_a_SOURCES): Rename to...
1269 (libctf_nobfd_la_SOURCES): ... this, all of libctf other than
1271 (libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
1272 with ctf-open-bfd.c added.
1273 (libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
1274 (libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
1275 (libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
1276 * Makefile.am [INSTALL_LIBCTF]: Use it.
1277 * aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
1279 * libctf.ver: New, everything is version LIBCTF_1.0 currently (even
1280 the unstable components).
1281 * Makefile.in: Regenerated.
1282 * config.h.in: Likewise.
1283 * configure: Likewise.
1285 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
1287 * configure.ac (INSTALL_LIBCTF): New, controlled by
1288 --enable-install-libctf.
1289 [INSTALL_LIBCTF] (lib_LIBRARIES): Add libctf.a.
1290 * Makefile.in: Regenerated.
1291 * configure: Regenerated.
1293 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
1295 * ctf-archive.c (ctf_arc_close): Call ctfi_bfd_close if set.
1296 * ctf-open-bfd.c (ctf_bfdclose): Fix comment.
1298 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
1300 * ctf-open-bfd.c (ctf_fdopen): Call bfd_set_cacheable.
1302 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1304 * ctf-impl.h (includes): Include <sys/param.h> here.
1306 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
1308 * ctf-open.c (flip_lbls): Eschew for-loop initial declarations.
1309 (flip_objts): Likewise.
1310 (flip_vars): Likewise.
1311 (flip_types): Likewise.
1313 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
1315 * ctf-hash.c (ctf_hashtab_insert): Pass in the key and value
1316 freeing functions: if set, free the key and value if the slot
1317 already exists. Always reassign the key.
1318 (ctf_dynhash_insert): Adjust call appropriately.
1319 (ctf_hash_insert_type): Likewise.
1321 2019-08-03 Nick Alcock <nick.alcock@oracle.com>
1323 * ctf-create.c (ctf_add_type): Look up and use the forwarded-to
1324 type kind. Allow forwards to unify with pre-existing structs/
1327 2019-07-30 Nick Alcock <nick.alcock@oracle.com>
1329 * ctf-impl.h (ctf_file_t) <ctf_link_cu_mappping>: New.
1330 <ctf_link_memb_name_changer>: Likewise.
1331 <ctf_link_memb_name_changer_arg>: Likewise.
1332 * ctf-create.c (ctf_update): Update accordingly.
1333 * ctf-open.c (ctf_file_close): Likewise.
1334 * ctf-link.c (ctf_create_per_cu): Apply the cu mapping.
1335 (ctf_link_add_cu_mapping): New.
1336 (ctf_link_set_memb_name_changer): Likewise.
1337 (ctf_change_parent_name): New.
1338 (ctf_name_list_accum_cb_arg_t) <dynames>: New, storage for names
1339 allocated by the caller's ctf_link_memb_name_changer.
1340 <ndynames>: Likewise.
1341 (ctf_accumulate_archive_names): Call the ctf_link_memb_name_changer.
1342 (ctf_link_write): Likewise (for _CTF_SECTION only): also call
1343 ctf_change_parent_name. Free any resulting names.
1345 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1347 * ctf-link.c (ctf_create_per_cu): New, refactored out of...
1348 (ctf_link_one_type): ... here, with parent-name setting added.
1349 (check_variable): New.
1350 (ctf_link_one_variable): Likewise.
1351 (ctf_link_one_input_archive_member): Call it.
1352 * ctf-error.c (_ctf_errlist): Updated with new errors.
1354 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1356 * ctf-impl.h (ctf_file_t): New field ctf_link_type_mapping.
1357 (struct ctf_link_type_mapping_key): New.
1358 (ctf_hash_type_mapping_key): Likewise.
1359 (ctf_hash_eq_type_mapping_key): Likewise.
1360 (ctf_add_type_mapping): Likewise.
1361 (ctf_type_mapping): Likewise.
1362 (ctf_dynhash_empty): Likewise.
1363 * ctf-open.c (ctf_file_close): Update accordingly.
1364 * ctf-create.c (ctf_update): Likewise.
1365 (ctf_add_type): Populate the mapping.
1366 * ctf-hash.c (ctf_hash_type_mapping_key): Hash a type mapping key.
1367 (ctf_hash_eq_type_mapping_key): Check the key for equality.
1368 (ctf_dynhash_insert): Fix comment typo.
1369 (ctf_dynhash_empty): New.
1370 * ctf-link.c (ctf_add_type_mapping): New.
1371 (ctf_type_mapping): Likewise.
1372 (empty_link_type_mapping): New.
1373 (ctf_link_one_input_archive): Call it.
1375 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1377 * ctf-link.c: New file, linking of the string and type sections.
1378 * Makefile.am (libctf_a_SOURCES): Add it.
1379 * Makefile.in: Regenerate.
1381 * ctf-impl.h (ctf_file_t): New fields ctf_link_inputs,
1383 * ctf-create.c (ctf_update): Update accordingly.
1384 * ctf-open.c (ctf_file_close): Likewise.
1385 * ctf-error.c (_ctf_errlist): Updated with new errors.
1387 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1389 * ctf-dump.c (ctf_dump_funcs): Check the right error value.
1391 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1393 * ctf-dump.c (ctf_dump): Use ctf_type_iter_all to dump types, not
1395 (ctf_dump_type): Pass down the flag from ctf_type_iter_all.
1396 (ctf_dump_format_type): Add non-root-type { } notation.
1397 Add root flag to prototype.
1398 (ctf_dump_label): Adjust accordingly.
1399 (ctf_dump_objts): Likewise.
1400 (ctf_dump_var): Likewise.
1402 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1404 * ctf-create.c (ctf_compress_write): Fix double-free.
1406 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1408 * ctf-archive.c (ctf_arc_write): Split off, and reimplement in terms
1410 (ctf_arc_write_fd): ... this new function.
1411 * ctf-create.c (ctf_write_mem): New.
1413 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1415 * ctf-impl.h (ctf_str_atom_t) <csa_offset>: New field.
1416 (ctf_file_t) <ctf_syn_ext_strtab>: Likewise.
1417 (ctf_str_add_ref): Name the last arg.
1418 (ctf_str_add_external) New.
1419 (ctf_str_add_strraw_explicit): Likewise.
1420 (ctf_simple_open_internal): Likewise.
1421 (ctf_bufopen_internal): Likewise.
1423 * ctf-string.c (ctf_strraw_explicit): Split from...
1424 (ctf_strraw): ... here, with new support for ctf_syn_ext_strtab.
1425 (ctf_str_add_ref_internal): Return the atom, not the
1427 (ctf_str_add): Adjust accordingly.
1428 (ctf_str_add_ref): Likewise. Move up in the file.
1429 (ctf_str_add_external): New: update the csa_offset.
1430 (ctf_str_count_strtab): Only account for strings with no csa_offset
1431 in the internal strtab length.
1432 (ctf_str_write_strtab): If the csa_offset is set, update the
1433 string's refs without writing the string out, and update the
1434 ctf_syn_ext_strtab. Make OOM handling less ugly.
1435 * ctf-create.c (struct ctf_sort_var_arg_cb): New.
1436 (ctf_update): Handle failure to populate the strtab. Pass in the
1437 new ctf_sort_var arg. Adjust for ctf_syn_ext_strtab addition.
1438 Call ctf_simple_open_internal, not ctf_simple_open.
1439 (ctf_sort_var): Call ctf_strraw_explicit rather than looking up
1441 * ctf-hash.c (ctf_hash_insert_type): Likewise (but using
1442 ctf_strraw). Adjust to diagnose ECTF_STRTAB nonetheless.
1443 * ctf-open.c (init_types): No longer filter out ECTF_STRTAB.
1444 (ctf_file_close): Destroy the ctf_syn_ext_strtab.
1445 (ctf_simple_open): Rename to, and reimplement as a wrapper around...
1446 (ctf_simple_open_internal): ... this new function, which calls
1447 ctf_bufopen_internal.
1448 (ctf_bufopen): Rename to, and reimplement as a wrapper around...
1449 (ctf_bufopen_internal): ... this new function, which sets
1452 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1454 * ctf_types.c (ctf_type_iter_all): New.
1456 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1458 * ctf-open.c (init_symtab): Check for overflow against the right
1460 (upgrade_header): Set cth_objtidxoff, cth_funcidxoff to zero-length.
1461 (upgrade_types_v1): Note that these sections are not checked.
1462 (flip_header): Endian-swap the header fields.
1463 (flip_ctf): Endian-swap the sections.
1464 (flip_objts): Update comment.
1465 (ctf_bufopen): Check header offsets and alignment for validity.
1467 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
1469 * ctf-open-bfd.c: Add <assert.h>.
1470 (ctf_bfdopen_ctfsect): Open string and symbol tables using
1471 techniques borrowed from bfd_elf_sym_name.
1472 (ctf_new_archive_internal): Improve comment.
1473 * ctf-archive.c (ctf_arc_close): Do not free the ctfi_strsect.
1474 * ctf-open.c (ctf_bufopen): Allow opening with a string section but
1475 no symbol section, but not vice versa.
1477 2019-07-08 Nick Alcock <nick.alcock@oracle.com>
1479 * ctf-impl.h (ctf_file_t): New field ctf_openflags.
1480 * ctf-open.c (ctf_bufopen): Set it. No longer dump header offsets.
1481 * ctf-dump.c (dump_header): New function, dump the CTF header.
1482 (ctf_dump): Call it.
1483 (ctf_dump_header_strfield): New function.
1484 (ctf_dump_header_sectfield): Likewise.
1486 2019-07-06 Nick Alcock <nick.alcock@oracle.com>
1488 * ctf-impl.h (ctf_file_t): New fields ctf_header, ctf_dynbase,
1489 ctf_cuname, ctf_dyncuname: ctf_base and ctf_buf are no longer const.
1490 * ctf-open.c (ctf_set_base): Preserve the gap between ctf_buf and
1491 ctf_base: do not assume that it is always sizeof (ctf_header_t).
1492 Print out ctf_cuname: only print out ctf_parname if set.
1493 (ctf_free_base): Removed, ctf_base is no longer freed: free
1494 ctf_dynbase instead.
1495 (ctf_set_version): Fix spacing.
1496 (upgrade_header): New, in-place header upgrading.
1497 (upgrade_types): Rename to...
1498 (upgrade_types_v1): ... this. Free ctf_dynbase, not ctf_base. No
1499 longer track old and new headers separately. No longer allow for
1500 header sizes explicitly: squeeze the headers out on upgrade (they
1501 are preserved in fp->ctf_header). Set ctf_dynbase, ctf_base and
1502 ctf_buf explicitly. Use ctf_free, not ctf_free_base.
1503 (upgrade_types): New, also handle ctf_parmax updating.
1504 (flip_header): Flip ctf_cuname.
1505 (flip_types): Flip BUF explicitly rather than deriving BUF from
1507 (ctf_bufopen): Store the header in fp->ctf_header. Correct minimum
1508 required alignment of objtoff and funcoff. No longer store it in
1509 the ctf_buf unless that buf is derived unmodified from the input.
1510 Set ctf_dynbase where ctf_base is dynamically allocated. Drop locals
1511 that duplicate fields in ctf_file: move allocation of ctf_file
1512 further up instead. Call upgrade_header as needed. Move
1513 version-specific ctf_parmax initialization into upgrade_types. More
1514 concise error handling.
1515 (ctf_file_close): No longer test for null pointers before freeing.
1516 Free ctf_dyncuname, ctf_dynbase, and ctf_header. Do not call
1519 (ctf_cuname_set): New.
1520 * ctf-create.c (ctf_update): Populate ctf_cuname.
1521 (ctf_gzwrite): Write out the header explicitly. Remove obsolescent
1523 (ctf_write): Likewise.
1524 (ctf_compress_write): Get the header from ctf_header, not ctf_base.
1525 Fix the compression length: fp->ctf_size never counted the CTF
1526 header. Simplify the compress call accordingly.
1528 2019-07-11 Hans-Peter Nilsson <hp@bitrange.com>
1530 * ctf-endian.h: Don't assume htole64 and le64toh are always
1531 present if HAVE_ENDIAN_H; also check if htole64 is defined.
1532 [!WORDS_BIGENDIAN] (htole64, le64toh): Define as identity,
1533 not bswap_identity_64.
1535 2019-09-18 Alan Modra <amodra@gmail.com>
1537 * ctf-open-bfd.c: Update throughout for bfd section macro changes.
1539 2019-09-09 Phil Blundell <pb@pbcl.net>
1541 binutils 2.33 branch created.
1543 2019-07-18 Nick Alcock <nick.alcock@oracle.com>
1545 * ctf-types.c (ctf_type_aname_raw): New.
1546 (ctf_func_type_info): Likewise.
1547 (ctf_func_type_args): Likewise.
1548 * ctf-error.c (_ctf_errlist): Fix description.
1549 * ctf-lookup.c: Fix file description.
1551 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
1553 * ctf-create.c (ctf_create): Fix off-by-one error.
1555 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
1557 * ctf-impl.h: (struct ctf_strs_writable): New, non-const version of
1559 (struct ctf_dtdef): Note that dtd_data.ctt_name is unpopulated.
1560 (struct ctf_str_atom): New, disambiguated single string.
1561 (struct ctf_str_atom_ref): New, points to some other location that
1562 references this string's offset.
1563 (struct ctf_file): New members ctf_str_atoms and ctf_str_num_refs.
1564 Remove member ctf_dtvstrlen: we no longer track the total strlen
1566 (ctf_str_create_atoms): Declare new function in ctf-string.c.
1567 (ctf_str_free_atoms): Likewise.
1568 (ctf_str_add): Likewise.
1569 (ctf_str_add_ref): Likewise.
1570 (ctf_str_rollback): Likewise.
1571 (ctf_str_purge_refs): Likewise.
1572 (ctf_str_write_strtab): Likewise.
1573 (ctf_realloc): Declare new function in ctf-util.c.
1575 * ctf-open.c (ctf_bufopen): Create the atoms table.
1576 (ctf_file_close): Destroy it.
1577 * ctf-create.c (ctf_update): Copy-and-free it on update. No longer
1578 special-case the position of the parname string. Construct the
1579 strtab by calling ctf_str_add_ref and ctf_str_write_strtab after the
1580 rest of each buffer element is constructed, not via open-coding:
1581 realloc the CTF buffer and append the strtab to it. No longer
1582 maintain ctf_dtvstrlen. Sort the variable entry table later, after
1583 strtab construction.
1584 (ctf_copy_membnames): Remove: integrated into ctf_copy_{s,l,e}members.
1585 (ctf_copy_smembers): Drop the string offset: call ctf_str_add_ref
1586 after buffer element construction instead.
1587 (ctf_copy_lmembers): Likewise.
1588 (ctf_copy_emembers): Likewise.
1589 (ctf_create): No longer maintain the ctf_dtvstrlen.
1590 (ctf_dtd_delete): Likewise.
1591 (ctf_dvd_delete): Likewise.
1592 (ctf_add_generic): Likewise.
1593 (ctf_add_enumerator): Likewise.
1594 (ctf_add_member_offset): Likewise.
1595 (ctf_add_variable): Likewise.
1596 (membadd): Likewise.
1597 * ctf-util.c (ctf_realloc): New, wrapper around realloc that aborts
1598 if there are active ctf_str_num_refs.
1599 (ctf_strraw): Move to ctf-string.c.
1600 (ctf_strptr): Likewise.
1601 * ctf-string.c: New file, strtab manipulation.
1603 * Makefile.am (libctf_a_SOURCES): Add it.
1604 * Makefile.in: Regenerate.
1606 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
1608 * ctf-impl.h (ctf_hash_iter_f): New.
1609 (ctf_dynhash_iter): New declaration.
1610 (ctf_dynhash_iter_remove): New declaration.
1611 * ctf-hash.c (ctf_dynhash_iter): Define.
1612 (ctf_dynhash_iter_remove): Likewise.
1613 (ctf_hashtab_traverse): New.
1614 (ctf_hashtab_traverse_remove): Likewise.
1615 (struct ctf_traverse_cb_arg): Likewise.
1616 (struct ctf_traverse_remove_cb_arg): Likewise.
1618 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
1620 * ctf-hash.c (ctf_dynhash_remove): Call with a mocked-up element.
1622 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
1624 * ctf-dump.c (ctf_dump_format_type): Prefix hex strings with 0x.
1625 (ctf_dump_funcs): Likewise.
1627 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
1629 * ctf-open-bfd.c: Add swap.h and ctf-endian.h.
1630 (ctf_fdopen): Check for endian-swapped raw CTF magic, and
1631 little-endian CTF archive magic. Do not check the CTF version:
1632 ctf_simple_open does that in endian-safe ways. Do not dereference
1633 null pointers on open failure.
1635 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
1637 * ctf-open.c (get_vbytes_common): Return the new slice size.
1638 (ctf_bufopen): Flip the endianness of the CTF-section header copy.
1639 Remember to copy in the CTF data when opening an uncompressed
1640 foreign-endian CTF file. Prune useless variable manipulation.
1642 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
1644 * ctf-open.c (ctf_types): Fail when unidentified type kinds are
1647 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
1649 * ctf-open.c (ctf_bufopen): Dump header offsets into the debugging
1652 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
1654 * ctf-subr.c (_PAGESIZE): Remove.
1655 (ctf_data_alloc): Likewise.
1656 (ctf_data_free): Likewise.
1657 (ctf_data_protect): Likewise.
1658 * ctf-impl.h: Remove declarations.
1659 * ctf-create.c (ctf_update): No longer call ctf_data_protect: use
1660 ctf_free, not ctf_data_free.
1661 (ctf_compress_write): Use ctf_data_alloc, not ctf_alloc. Free
1662 the buffer again on compression error.
1663 * ctf-open.c (ctf_set_base): No longer track the size: call
1664 ctf_free, not ctf_data_free.
1665 (upgrade_types): Likewise. Call ctf_alloc, not ctf_data_alloc.
1666 (ctf_bufopen): Likewise. No longer call ctf_data_protect.
1668 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
1670 * ctf-create.c (ctf_dtd_insert): Pass on error returns from
1672 (ctf_dvd_insert): Likewise.
1673 (ctf_add_generic): Likewise.
1674 (ctf_add_variable): Likewise.
1675 * ctf-impl.h: Adjust declarations.
1677 2019-06-14 Alan Modra <amodra@gmail.com>
1679 * configure: Regenerate.
1681 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
1683 * ctf-decls.h: Include <libiberty.h>.
1684 * ctf-lookup.c (ctf_lookup_by_name): Call xstrndup(), not strndup().
1686 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
1688 * ctf-dump.c (ctf_dump_format_type): Cast size_t's used in printf()s.
1689 (ctf_dump_objts): Likewise.
1690 (ctf_dump_funcs): Likewise.
1691 (ctf_dump_member): Likewise.
1692 (ctf_dump_str): Likewise.
1694 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
1696 * ctf-archive.c (arc_mmap_header): Mark fd as potentially unused.
1697 * ctf-subr.c (ctf_data_protect): Mark both args as potentially unused.
1699 2019-06-05 Nick Alcock <nick.alcock@oracle.com>
1701 * ctf-archive.c (ctf_arc_write): Eschew %zi format specifier.
1702 (ctf_arc_open_by_offset): Likewise.
1703 * ctf-create.c (ctf_add_type): Likewise.
1705 2019-06-04 Tom Tromey <tromey@adacore.com>
1707 * ctf-create.c (ctf_add_encoded, ctf_add_slice)
1708 (ctf_add_member_offset): Use CHAR_BIT, not NBBY.
1710 2019-06-04 Nick Alcock <nick.alcock@oracle.com>
1712 * configure.ac: Check for O_CLOEXEC.
1713 * ctf-decls.h (O_CLOEXEC): Define (to 0), if need be.
1714 * config.h.in: Regenerate.
1715 * configure: Likewise.
1717 2019-06-04 Nick Alcock <nick.alcock@oracle.com>
1719 * qsort_r.c: Rename to...
1720 * ctf-qsort_r.c: ... this.
1721 (_quicksort): Define to ctf_qsort_r.
1722 * ctf-decls.h (qsort_r): Remove.
1724 (struct ctf_qsort_arg): New, transport the real ARG and COMPAR.
1725 (ctf_qsort_compar_thunk): Rearrange the arguments to COMPAR.
1726 * Makefile.am (libctf_a_LIBADD): Remove.
1727 (libctf_a_SOURCES): New, add ctf-qsort_r.c.
1728 * ctf-archive.c (ctf_arc_write): Call ctf_qsort_r, not qsort_r.
1729 * ctf-create.c (ctf_update): Likewise.
1730 * configure.ac: Check for BSD versus GNU qsort_r signature.
1731 * Makefile.in: Regenerate.
1732 * config.h.in: Likewise.
1733 * configure: Likewise.
1735 2019-06-03 Nick Alcock <nick.alcock@oracle.com>
1737 * ctf-dump.c (ctf_dump_funcs): Free in the right place.
1739 2019-05-29 Nick Alcock <nick.alcock@oracle.com>
1741 * Makefile.am (ZLIB): New.
1742 (ZLIBINC): Likewise.
1743 (AM_CFLAGS): Use them.
1744 (libctf_a_LIBADD): New, for LIBOBJS.
1745 * configure.ac: Check for zlib, endian.h, and qsort_r.
1746 * ctf-endian.h: New, providing htole64 and le64toh.
1747 * swap.h: Code style fixes.
1748 (bswap_identity_64): New.
1749 * qsort_r.c: New, from gnulib (with one added #include).
1750 * ctf-decls.h: New, providing a conditional qsort_r declaration,
1751 and unconditional definitions of MIN and MAX.
1752 * ctf-impl.h: Use it. Do not use <sys/errno.h>.
1753 (ctf_set_errno): Now returns unsigned long.
1754 * ctf-util.c (ctf_set_errno): Adjust here too.
1755 * ctf-archive.c: Use ctf-endian.h.
1756 (ctf_arc_open_by_offset): Use memset, not bzero. Drop cts_type,
1757 cts_flags and cts_offset.
1758 (ctf_arc_write): Drop debugging dependent on the size of off_t.
1759 * ctf-create.c: Provide a definition of roundup if not defined.
1760 (ctf_create): Drop cts_type, cts_flags and cts_offset.
1761 (ctf_add_reftype): Do not check if type IDs are below zero.
1762 (ctf_add_slice): Likewise.
1763 (ctf_add_typedef): Likewise.
1764 (ctf_add_member_offset): Cast error-returning ssize_t's to size_t
1765 when known error-free. Drop CTF_ERR usage for functions returning
1767 (ctf_add_member_encoded): Drop CTF_ERR usage for functions returning
1769 (ctf_add_variable): Likewise.
1770 (enumcmp): Likewise.
1771 (enumadd): Likewise.
1772 (membcmp): Likewise.
1773 (ctf_add_type): Likewise. Cast error-returning ssize_t's to size_t
1774 when known error-free.
1775 * ctf-dump.c (ctf_is_slice): Drop CTF_ERR usage for functions
1776 returning int: use CTF_ERR for functions returning ctf_type_id.
1777 (ctf_dump_label): Likewise.
1778 (ctf_dump_objts): Likewise.
1779 * ctf-labels.c (ctf_label_topmost): Likewise.
1780 (ctf_label_iter): Likewise.
1781 (ctf_label_info): Likewise.
1782 * ctf-lookup.c (ctf_func_args): Likewise.
1783 * ctf-open.c (upgrade_types): Cast to size_t where appropriate.
1784 (ctf_bufopen): Likewise. Use zlib types as needed.
1785 * ctf-types.c (ctf_member_iter): Drop CTF_ERR usage for functions
1787 (ctf_enum_iter): Likewise.
1788 (ctf_type_size): Likewise.
1789 (ctf_type_align): Likewise. Cast to size_t where appropriate.
1790 (ctf_type_kind_unsliced): Likewise.
1791 (ctf_type_kind): Likewise.
1792 (ctf_type_encoding): Likewise.
1793 (ctf_member_info): Likewise.
1794 (ctf_array_info): Likewise.
1795 (ctf_enum_value): Likewise.
1796 (ctf_type_rvisit): Likewise.
1797 * ctf-open-bfd.c (ctf_bfdopen): Drop cts_type, cts_flags and
1799 (ctf_simple_open): Likewise.
1800 (ctf_bfdopen_ctfsect): Likewise. Set cts_size properly.
1801 * Makefile.in: Regenerate.
1802 * aclocal.m4: Likewise.
1803 * config.h: Likewise.
1804 * configure: Likewise.
1806 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1808 * configure.in: Check for bfd_section_from_elf_index.
1809 * configure: Regenerate.
1810 * config.h.in [HAVE_BFD_ELF]: Likewise.
1811 * libctf/ctf_open_bfd (ctf_bfdopen_ctfsect): Use it.
1812 abfd is potentially unused now.
1814 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1817 * Makefile.in: Regenerated.
1818 * config.h.in: Likewise.
1819 * aclocal.m4: Likewise.
1820 * configure: Likewise.
1822 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1826 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1828 * ctf-labels.c: New.
1830 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1832 * ctf-impl.h (_libctf_version): New declaration.
1833 * ctf-subr.c (_libctf_version): Define it.
1836 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1838 * ctf-create.c (enumcmp): New.
1839 (enumadd): Likewise.
1840 (membcmp): Likewise.
1841 (membadd): Likewise.
1842 (ctf_add_type): Likewise.
1844 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1846 * ctf-lookup.c (isqualifier): New.
1847 (ctf_lookup_by_name): Likewise.
1848 (struct ctf_lookup_var_key): Likewise.
1849 (ctf_lookup_var): Likewise.
1850 (ctf_lookup_variable): Likewise.
1851 (ctf_lookup_symbol_name): Likewise.
1852 (ctf_lookup_by_symbol): Likewise.
1853 (ctf_func_info): Likewise.
1854 (ctf_func_args): Likewise.
1856 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1858 * ctf-decl.c: New file.
1859 * ctf-types.c: Likewise.
1860 * ctf-impl.h: New declarations.
1862 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1864 * ctf-open-bfd.c: New file.
1865 * ctf-open.c (ctf_close): New.
1866 * ctf-impl.h: Include bfd.h.
1867 (ctf_file): New members ctf_data_mmapped, ctf_data_mmapped_len.
1868 (ctf_archive_internal): New members ctfi_abfd, ctfi_data,
1870 (ctf_bfdopen_ctfsect): New declaration.
1871 (_CTF_SECTION): likewise.
1873 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1875 * ctf-archive.c: New.
1876 * ctf-impl.h (ctf_archive_internal): New type.
1877 (ctf_arc_open_internal): New declaration.
1878 (ctf_arc_bufopen): Likewise.
1879 (ctf_arc_close_internal): Likewise.
1881 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1883 * ctf-open.c: New file.
1886 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1888 * ctf-create.c: New file.
1889 * ctf-lookup.c: New file.
1891 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1893 * ctf-impl.h: New definitions and declarations for type creation
1896 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1898 * ctf-hash.c: New file.
1899 * ctf-impl.h: New declarations.
1901 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1903 * ctf-error.c: New file.
1905 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1907 * ctf-util.c: New file.
1909 * ctf-impl.h: Include it, and add declarations.
1911 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
1913 * ctf-impl.h: New file.
1914 * ctf-subr.c: New file.
1921 version-control: never