libctf: support getting strings from the ELF strtab
[deliverable/binutils-gdb.git] / libctf / ChangeLog
1 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
2
3 * ctf-impl.h (ctf_str_atom_t) <csa_offset>: New field.
4 (ctf_file_t) <ctf_syn_ext_strtab>: Likewise.
5 (ctf_str_add_ref): Name the last arg.
6 (ctf_str_add_external) New.
7 (ctf_str_add_strraw_explicit): Likewise.
8 (ctf_simple_open_internal): Likewise.
9 (ctf_bufopen_internal): Likewise.
10
11 * ctf-string.c (ctf_strraw_explicit): Split from...
12 (ctf_strraw): ... here, with new support for ctf_syn_ext_strtab.
13 (ctf_str_add_ref_internal): Return the atom, not the
14 string.
15 (ctf_str_add): Adjust accordingly.
16 (ctf_str_add_ref): Likewise. Move up in the file.
17 (ctf_str_add_external): New: update the csa_offset.
18 (ctf_str_count_strtab): Only account for strings with no csa_offset
19 in the internal strtab length.
20 (ctf_str_write_strtab): If the csa_offset is set, update the
21 string's refs without writing the string out, and update the
22 ctf_syn_ext_strtab. Make OOM handling less ugly.
23 * ctf-create.c (struct ctf_sort_var_arg_cb): New.
24 (ctf_update): Handle failure to populate the strtab. Pass in the
25 new ctf_sort_var arg. Adjust for ctf_syn_ext_strtab addition.
26 Call ctf_simple_open_internal, not ctf_simple_open.
27 (ctf_sort_var): Call ctf_strraw_explicit rather than looking up
28 strings by hand.
29 * ctf-hash.c (ctf_hash_insert_type): Likewise (but using
30 ctf_strraw). Adjust to diagnose ECTF_STRTAB nonetheless.
31 * ctf-open.c (init_types): No longer filter out ECTF_STRTAB.
32 (ctf_file_close): Destroy the ctf_syn_ext_strtab.
33 (ctf_simple_open): Rename to, and reimplement as a wrapper around...
34 (ctf_simple_open_internal): ... this new function, which calls
35 ctf_bufopen_internal.
36 (ctf_bufopen): Rename to, and reimplement as a wrapper around...
37 (ctf_bufopen_internal): ... this new function, which sets
38 ctf_syn_ext_strtab.
39
40 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
41
42 * ctf_types.c (ctf_type_iter_all): New.
43
44 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
45
46 * ctf-open.c (init_symtab): Check for overflow against the right
47 section.
48 (upgrade_header): Set cth_objtidxoff, cth_funcidxoff to zero-length.
49 (upgrade_types_v1): Note that these sections are not checked.
50 (flip_header): Endian-swap the header fields.
51 (flip_ctf): Endian-swap the sections.
52 (flip_objts): Update comment.
53 (ctf_bufopen): Check header offsets and alignment for validity.
54
55 2019-07-13 Nick Alcock <nick.alcock@oracle.com>
56
57 * ctf-open-bfd.c: Add <assert.h>.
58 (ctf_bfdopen_ctfsect): Open string and symbol tables using
59 techniques borrowed from bfd_elf_sym_name.
60 (ctf_new_archive_internal): Improve comment.
61 * ctf-archive.c (ctf_arc_close): Do not free the ctfi_strsect.
62 * ctf-open.c (ctf_bufopen): Allow opening with a string section but
63 no symbol section, but not vice versa.
64
65 2019-07-08 Nick Alcock <nick.alcock@oracle.com>
66
67 * ctf-impl.h (ctf_file_t): New field ctf_openflags.
68 * ctf-open.c (ctf_bufopen): Set it. No longer dump header offsets.
69 * ctf-dump.c (dump_header): New function, dump the CTF header.
70 (ctf_dump): Call it.
71 (ctf_dump_header_strfield): New function.
72 (ctf_dump_header_sectfield): Likewise.
73
74 2019-07-06 Nick Alcock <nick.alcock@oracle.com>
75
76 * ctf-impl.h (ctf_file_t): New fields ctf_header, ctf_dynbase,
77 ctf_cuname, ctf_dyncuname: ctf_base and ctf_buf are no longer const.
78 * ctf-open.c (ctf_set_base): Preserve the gap between ctf_buf and
79 ctf_base: do not assume that it is always sizeof (ctf_header_t).
80 Print out ctf_cuname: only print out ctf_parname if set.
81 (ctf_free_base): Removed, ctf_base is no longer freed: free
82 ctf_dynbase instead.
83 (ctf_set_version): Fix spacing.
84 (upgrade_header): New, in-place header upgrading.
85 (upgrade_types): Rename to...
86 (upgrade_types_v1): ... this. Free ctf_dynbase, not ctf_base. No
87 longer track old and new headers separately. No longer allow for
88 header sizes explicitly: squeeze the headers out on upgrade (they
89 are preserved in fp->ctf_header). Set ctf_dynbase, ctf_base and
90 ctf_buf explicitly. Use ctf_free, not ctf_free_base.
91 (upgrade_types): New, also handle ctf_parmax updating.
92 (flip_header): Flip ctf_cuname.
93 (flip_types): Flip BUF explicitly rather than deriving BUF from
94 BASE.
95 (ctf_bufopen): Store the header in fp->ctf_header. Correct minimum
96 required alignment of objtoff and funcoff. No longer store it in
97 the ctf_buf unless that buf is derived unmodified from the input.
98 Set ctf_dynbase where ctf_base is dynamically allocated. Drop locals
99 that duplicate fields in ctf_file: move allocation of ctf_file
100 further up instead. Call upgrade_header as needed. Move
101 version-specific ctf_parmax initialization into upgrade_types. More
102 concise error handling.
103 (ctf_file_close): No longer test for null pointers before freeing.
104 Free ctf_dyncuname, ctf_dynbase, and ctf_header. Do not call
105 ctf_free_base.
106 (ctf_cuname): New.
107 (ctf_cuname_set): New.
108 * ctf-create.c (ctf_update): Populate ctf_cuname.
109 (ctf_gzwrite): Write out the header explicitly. Remove obsolescent
110 comment.
111 (ctf_write): Likewise.
112 (ctf_compress_write): Get the header from ctf_header, not ctf_base.
113 Fix the compression length: fp->ctf_size never counted the CTF
114 header. Simplify the compress call accordingly.
115
116 2019-07-11 Hans-Peter Nilsson <hp@bitrange.com>
117
118 * ctf-endian.h: Don't assume htole64 and le64toh are always
119 present if HAVE_ENDIAN_H; also check if htole64 is defined.
120 [!WORDS_BIGENDIAN] (htole64, le64toh): Define as identity,
121 not bswap_identity_64.
122
123 2019-09-18 Alan Modra <amodra@gmail.com>
124
125 * ctf-open-bfd.c: Update throughout for bfd section macro changes.
126
127 2019-09-09 Phil Blundell <pb@pbcl.net>
128
129 binutils 2.33 branch created.
130
131 2019-07-18 Nick Alcock <nick.alcock@oracle.com>
132
133 * ctf-types.c (ctf_type_aname_raw): New.
134 (ctf_func_type_info): Likewise.
135 (ctf_func_type_args): Likewise.
136 * ctf-error.c (_ctf_errlist): Fix description.
137 * ctf-lookup.c: Fix file description.
138
139 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
140
141 * ctf-create.c (ctf_create): Fix off-by-one error.
142
143 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
144
145 * ctf-impl.h: (struct ctf_strs_writable): New, non-const version of
146 struct ctf_strs.
147 (struct ctf_dtdef): Note that dtd_data.ctt_name is unpopulated.
148 (struct ctf_str_atom): New, disambiguated single string.
149 (struct ctf_str_atom_ref): New, points to some other location that
150 references this string's offset.
151 (struct ctf_file): New members ctf_str_atoms and ctf_str_num_refs.
152 Remove member ctf_dtvstrlen: we no longer track the total strlen
153 as we add strings.
154 (ctf_str_create_atoms): Declare new function in ctf-string.c.
155 (ctf_str_free_atoms): Likewise.
156 (ctf_str_add): Likewise.
157 (ctf_str_add_ref): Likewise.
158 (ctf_str_rollback): Likewise.
159 (ctf_str_purge_refs): Likewise.
160 (ctf_str_write_strtab): Likewise.
161 (ctf_realloc): Declare new function in ctf-util.c.
162
163 * ctf-open.c (ctf_bufopen): Create the atoms table.
164 (ctf_file_close): Destroy it.
165 * ctf-create.c (ctf_update): Copy-and-free it on update. No longer
166 special-case the position of the parname string. Construct the
167 strtab by calling ctf_str_add_ref and ctf_str_write_strtab after the
168 rest of each buffer element is constructed, not via open-coding:
169 realloc the CTF buffer and append the strtab to it. No longer
170 maintain ctf_dtvstrlen. Sort the variable entry table later, after
171 strtab construction.
172 (ctf_copy_membnames): Remove: integrated into ctf_copy_{s,l,e}members.
173 (ctf_copy_smembers): Drop the string offset: call ctf_str_add_ref
174 after buffer element construction instead.
175 (ctf_copy_lmembers): Likewise.
176 (ctf_copy_emembers): Likewise.
177 (ctf_create): No longer maintain the ctf_dtvstrlen.
178 (ctf_dtd_delete): Likewise.
179 (ctf_dvd_delete): Likewise.
180 (ctf_add_generic): Likewise.
181 (ctf_add_enumerator): Likewise.
182 (ctf_add_member_offset): Likewise.
183 (ctf_add_variable): Likewise.
184 (membadd): Likewise.
185 * ctf-util.c (ctf_realloc): New, wrapper around realloc that aborts
186 if there are active ctf_str_num_refs.
187 (ctf_strraw): Move to ctf-string.c.
188 (ctf_strptr): Likewise.
189 * ctf-string.c: New file, strtab manipulation.
190
191 * Makefile.am (libctf_a_SOURCES): Add it.
192 * Makefile.in: Regenerate.
193
194 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
195
196 * ctf-impl.h (ctf_hash_iter_f): New.
197 (ctf_dynhash_iter): New declaration.
198 (ctf_dynhash_iter_remove): New declaration.
199 * ctf-hash.c (ctf_dynhash_iter): Define.
200 (ctf_dynhash_iter_remove): Likewise.
201 (ctf_hashtab_traverse): New.
202 (ctf_hashtab_traverse_remove): Likewise.
203 (struct ctf_traverse_cb_arg): Likewise.
204 (struct ctf_traverse_remove_cb_arg): Likewise.
205
206 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
207
208 * ctf-hash.c (ctf_dynhash_remove): Call with a mocked-up element.
209
210 2019-06-28 Nick Alcock <nick.alcock@oracle.com>
211
212 * ctf-dump.c (ctf_dump_format_type): Prefix hex strings with 0x.
213 (ctf_dump_funcs): Likewise.
214
215 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
216
217 * ctf-open-bfd.c: Add swap.h and ctf-endian.h.
218 (ctf_fdopen): Check for endian-swapped raw CTF magic, and
219 little-endian CTF archive magic. Do not check the CTF version:
220 ctf_simple_open does that in endian-safe ways. Do not dereference
221 null pointers on open failure.
222
223 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
224
225 * ctf-open.c (get_vbytes_common): Return the new slice size.
226 (ctf_bufopen): Flip the endianness of the CTF-section header copy.
227 Remember to copy in the CTF data when opening an uncompressed
228 foreign-endian CTF file. Prune useless variable manipulation.
229
230 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
231
232 * ctf-open.c (ctf_types): Fail when unidentified type kinds are
233 seen.
234
235 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
236
237 * ctf-open.c (ctf_bufopen): Dump header offsets into the debugging
238 output.
239
240 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
241
242 * ctf-subr.c (_PAGESIZE): Remove.
243 (ctf_data_alloc): Likewise.
244 (ctf_data_free): Likewise.
245 (ctf_data_protect): Likewise.
246 * ctf-impl.h: Remove declarations.
247 * ctf-create.c (ctf_update): No longer call ctf_data_protect: use
248 ctf_free, not ctf_data_free.
249 (ctf_compress_write): Use ctf_data_alloc, not ctf_alloc. Free
250 the buffer again on compression error.
251 * ctf-open.c (ctf_set_base): No longer track the size: call
252 ctf_free, not ctf_data_free.
253 (upgrade_types): Likewise. Call ctf_alloc, not ctf_data_alloc.
254 (ctf_bufopen): Likewise. No longer call ctf_data_protect.
255
256 2019-06-19 Nick Alcock <nick.alcock@oracle.com>
257
258 * ctf-create.c (ctf_dtd_insert): Pass on error returns from
259 ctf_dynhash_insert.
260 (ctf_dvd_insert): Likewise.
261 (ctf_add_generic): Likewise.
262 (ctf_add_variable): Likewise.
263 * ctf-impl.h: Adjust declarations.
264
265 2019-06-14 Alan Modra <amodra@gmail.com>
266
267 * configure: Regenerate.
268
269 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
270
271 * ctf-decls.h: Include <libiberty.h>.
272 * ctf-lookup.c (ctf_lookup_by_name): Call xstrndup(), not strndup().
273
274 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
275
276 * ctf-dump.c (ctf_dump_format_type): Cast size_t's used in printf()s.
277 (ctf_dump_objts): Likewise.
278 (ctf_dump_funcs): Likewise.
279 (ctf_dump_member): Likewise.
280 (ctf_dump_str): Likewise.
281
282 2019-06-06 Nick Alcock <nick.alcock@oracle.com>
283
284 * ctf-archive.c (arc_mmap_header): Mark fd as potentially unused.
285 * ctf-subr.c (ctf_data_protect): Mark both args as potentially unused.
286
287 2019-06-05 Nick Alcock <nick.alcock@oracle.com>
288
289 * ctf-archive.c (ctf_arc_write): Eschew %zi format specifier.
290 (ctf_arc_open_by_offset): Likewise.
291 * ctf-create.c (ctf_add_type): Likewise.
292
293 2019-06-04 Tom Tromey <tromey@adacore.com>
294
295 * ctf-create.c (ctf_add_encoded, ctf_add_slice)
296 (ctf_add_member_offset): Use CHAR_BIT, not NBBY.
297
298 2019-06-04 Nick Alcock <nick.alcock@oracle.com>
299
300 * configure.ac: Check for O_CLOEXEC.
301 * ctf-decls.h (O_CLOEXEC): Define (to 0), if need be.
302 * config.h.in: Regenerate.
303 * configure: Likewise.
304
305 2019-06-04 Nick Alcock <nick.alcock@oracle.com>
306
307 * qsort_r.c: Rename to...
308 * ctf-qsort_r.c: ... this.
309 (_quicksort): Define to ctf_qsort_r.
310 * ctf-decls.h (qsort_r): Remove.
311 (ctf_qsort_r): Add.
312 (struct ctf_qsort_arg): New, transport the real ARG and COMPAR.
313 (ctf_qsort_compar_thunk): Rearrange the arguments to COMPAR.
314 * Makefile.am (libctf_a_LIBADD): Remove.
315 (libctf_a_SOURCES): New, add ctf-qsort_r.c.
316 * ctf-archive.c (ctf_arc_write): Call ctf_qsort_r, not qsort_r.
317 * ctf-create.c (ctf_update): Likewise.
318 * configure.ac: Check for BSD versus GNU qsort_r signature.
319 * Makefile.in: Regenerate.
320 * config.h.in: Likewise.
321 * configure: Likewise.
322
323 2019-06-03 Nick Alcock <nick.alcock@oracle.com>
324
325 * ctf-dump.c (ctf_dump_funcs): Free in the right place.
326
327 2019-05-29 Nick Alcock <nick.alcock@oracle.com>
328
329 * Makefile.am (ZLIB): New.
330 (ZLIBINC): Likewise.
331 (AM_CFLAGS): Use them.
332 (libctf_a_LIBADD): New, for LIBOBJS.
333 * configure.ac: Check for zlib, endian.h, and qsort_r.
334 * ctf-endian.h: New, providing htole64 and le64toh.
335 * swap.h: Code style fixes.
336 (bswap_identity_64): New.
337 * qsort_r.c: New, from gnulib (with one added #include).
338 * ctf-decls.h: New, providing a conditional qsort_r declaration,
339 and unconditional definitions of MIN and MAX.
340 * ctf-impl.h: Use it. Do not use <sys/errno.h>.
341 (ctf_set_errno): Now returns unsigned long.
342 * ctf-util.c (ctf_set_errno): Adjust here too.
343 * ctf-archive.c: Use ctf-endian.h.
344 (ctf_arc_open_by_offset): Use memset, not bzero. Drop cts_type,
345 cts_flags and cts_offset.
346 (ctf_arc_write): Drop debugging dependent on the size of off_t.
347 * ctf-create.c: Provide a definition of roundup if not defined.
348 (ctf_create): Drop cts_type, cts_flags and cts_offset.
349 (ctf_add_reftype): Do not check if type IDs are below zero.
350 (ctf_add_slice): Likewise.
351 (ctf_add_typedef): Likewise.
352 (ctf_add_member_offset): Cast error-returning ssize_t's to size_t
353 when known error-free. Drop CTF_ERR usage for functions returning
354 int.
355 (ctf_add_member_encoded): Drop CTF_ERR usage for functions returning
356 int.
357 (ctf_add_variable): Likewise.
358 (enumcmp): Likewise.
359 (enumadd): Likewise.
360 (membcmp): Likewise.
361 (ctf_add_type): Likewise. Cast error-returning ssize_t's to size_t
362 when known error-free.
363 * ctf-dump.c (ctf_is_slice): Drop CTF_ERR usage for functions
364 returning int: use CTF_ERR for functions returning ctf_type_id.
365 (ctf_dump_label): Likewise.
366 (ctf_dump_objts): Likewise.
367 * ctf-labels.c (ctf_label_topmost): Likewise.
368 (ctf_label_iter): Likewise.
369 (ctf_label_info): Likewise.
370 * ctf-lookup.c (ctf_func_args): Likewise.
371 * ctf-open.c (upgrade_types): Cast to size_t where appropriate.
372 (ctf_bufopen): Likewise. Use zlib types as needed.
373 * ctf-types.c (ctf_member_iter): Drop CTF_ERR usage for functions
374 returning int.
375 (ctf_enum_iter): Likewise.
376 (ctf_type_size): Likewise.
377 (ctf_type_align): Likewise. Cast to size_t where appropriate.
378 (ctf_type_kind_unsliced): Likewise.
379 (ctf_type_kind): Likewise.
380 (ctf_type_encoding): Likewise.
381 (ctf_member_info): Likewise.
382 (ctf_array_info): Likewise.
383 (ctf_enum_value): Likewise.
384 (ctf_type_rvisit): Likewise.
385 * ctf-open-bfd.c (ctf_bfdopen): Drop cts_type, cts_flags and
386 cts_offset.
387 (ctf_simple_open): Likewise.
388 (ctf_bfdopen_ctfsect): Likewise. Set cts_size properly.
389 * Makefile.in: Regenerate.
390 * aclocal.m4: Likewise.
391 * config.h: Likewise.
392 * configure: Likewise.
393
394 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
395
396 * configure.in: Check for bfd_section_from_elf_index.
397 * configure: Regenerate.
398 * config.h.in [HAVE_BFD_ELF]: Likewise.
399 * libctf/ctf_open_bfd (ctf_bfdopen_ctfsect): Use it.
400 abfd is potentially unused now.
401
402 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
403
404 * Makefile.am: New.
405 * Makefile.in: Regenerated.
406 * config.h.in: Likewise.
407 * aclocal.m4: Likewise.
408 * configure: Likewise.
409
410 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
411
412 * ctf-dump.c: New.
413
414 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
415
416 * ctf-labels.c: New.
417
418 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
419
420 * ctf-impl.h (_libctf_version): New declaration.
421 * ctf-subr.c (_libctf_version): Define it.
422 (ctf_version): New.
423
424 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
425
426 * ctf-create.c (enumcmp): New.
427 (enumadd): Likewise.
428 (membcmp): Likewise.
429 (membadd): Likewise.
430 (ctf_add_type): Likewise.
431
432 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
433
434 * ctf-lookup.c (isqualifier): New.
435 (ctf_lookup_by_name): Likewise.
436 (struct ctf_lookup_var_key): Likewise.
437 (ctf_lookup_var): Likewise.
438 (ctf_lookup_variable): Likewise.
439 (ctf_lookup_symbol_name): Likewise.
440 (ctf_lookup_by_symbol): Likewise.
441 (ctf_func_info): Likewise.
442 (ctf_func_args): Likewise.
443
444 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
445
446 * ctf-decl.c: New file.
447 * ctf-types.c: Likewise.
448 * ctf-impl.h: New declarations.
449
450 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
451
452 * ctf-open-bfd.c: New file.
453 * ctf-open.c (ctf_close): New.
454 * ctf-impl.h: Include bfd.h.
455 (ctf_file): New members ctf_data_mmapped, ctf_data_mmapped_len.
456 (ctf_archive_internal): New members ctfi_abfd, ctfi_data,
457 ctfi_bfd_close.
458 (ctf_bfdopen_ctfsect): New declaration.
459 (_CTF_SECTION): likewise.
460
461 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
462
463 * ctf-archive.c: New.
464 * ctf-impl.h (ctf_archive_internal): New type.
465 (ctf_arc_open_internal): New declaration.
466 (ctf_arc_bufopen): Likewise.
467 (ctf_arc_close_internal): Likewise.
468
469 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
470
471 * ctf-open.c: New file.
472 * swap.h: Likewise.
473
474 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
475
476 * ctf-create.c: New file.
477 * ctf-lookup.c: New file.
478
479 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
480
481 * ctf-impl.h: New definitions and declarations for type creation
482 and lookup.
483
484 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
485
486 * ctf-hash.c: New file.
487 * ctf-impl.h: New declarations.
488
489 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
490
491 * ctf-error.c: New file.
492
493 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
494
495 * ctf-util.c: New file.
496 * elf.h: Likewise.
497 * ctf-impl.h: Include it, and add declarations.
498
499 2019-05-28 Nick Alcock <nick.alcock@oracle.com>
500
501 * ctf-impl.h: New file.
502 * ctf-subr.c: New file.
503
504 \f
505 Local Variables:
506 mode: change-log
507 left-margin: 8
508 fill-column: 76
509 version-control: never
510 End:
This page took 0.040715 seconds and 4 git commands to generate.