libctf: deduplicate and sort the string table
[external/binutils.git] / libctf / ChangeLog
1 2019-06-28  Nick Alcock <nick.alcock@oracle.com>
2
3         * ctf-impl.h: (struct ctf_strs_writable): New, non-const version of
4         struct ctf_strs.
5         (struct ctf_dtdef): Note that dtd_data.ctt_name is unpopulated.
6         (struct ctf_str_atom): New, disambiguated single string.
7         (struct ctf_str_atom_ref): New, points to some other location that
8         references this string's offset.
9         (struct ctf_file): New members ctf_str_atoms and ctf_str_num_refs.
10         Remove member ctf_dtvstrlen: we no longer track the total strlen
11         as we add strings.
12         (ctf_str_create_atoms): Declare new function in ctf-string.c.
13         (ctf_str_free_atoms): Likewise.
14         (ctf_str_add): Likewise.
15         (ctf_str_add_ref): Likewise.
16         (ctf_str_rollback): Likewise.
17         (ctf_str_purge_refs): Likewise.
18         (ctf_str_write_strtab): Likewise.
19         (ctf_realloc): Declare new function in ctf-util.c.
20
21         * ctf-open.c (ctf_bufopen): Create the atoms table.
22         (ctf_file_close): Destroy it.
23         * ctf-create.c (ctf_update): Copy-and-free it on update.  No longer
24         special-case the position of the parname string.  Construct the
25         strtab by calling ctf_str_add_ref and ctf_str_write_strtab after the
26         rest of each buffer element is constructed, not via open-coding:
27         realloc the CTF buffer and append the strtab to it.  No longer
28         maintain ctf_dtvstrlen.  Sort the variable entry table later, after
29         strtab construction.
30         (ctf_copy_membnames): Remove: integrated into ctf_copy_{s,l,e}members.
31         (ctf_copy_smembers): Drop the string offset: call ctf_str_add_ref
32         after buffer element construction instead.
33         (ctf_copy_lmembers): Likewise.
34         (ctf_copy_emembers): Likewise.
35         (ctf_create): No longer maintain the ctf_dtvstrlen.
36         (ctf_dtd_delete): Likewise.
37         (ctf_dvd_delete): Likewise.
38         (ctf_add_generic): Likewise.
39         (ctf_add_enumerator): Likewise.
40         (ctf_add_member_offset): Likewise.
41         (ctf_add_variable): Likewise.
42         (membadd): Likewise.
43         * ctf-util.c (ctf_realloc): New, wrapper around realloc that aborts
44         if there are active ctf_str_num_refs.
45         (ctf_strraw): Move to ctf-string.c.
46         (ctf_strptr): Likewise.
47         * ctf-string.c: New file, strtab manipulation.
48
49         * Makefile.am (libctf_a_SOURCES): Add it.
50         * Makefile.in: Regenerate.
51
52 2019-06-28  Nick Alcock <nick.alcock@oracle.com>
53
54         * ctf-impl.h (ctf_hash_iter_f): New.
55         (ctf_dynhash_iter): New declaration.
56         (ctf_dynhash_iter_remove): New declaration.
57         * ctf-hash.c (ctf_dynhash_iter): Define.
58         (ctf_dynhash_iter_remove): Likewise.
59         (ctf_hashtab_traverse): New.
60         (ctf_hashtab_traverse_remove): Likewise.
61         (struct ctf_traverse_cb_arg): Likewise.
62         (struct ctf_traverse_remove_cb_arg): Likewise.
63
64 2019-06-28  Nick Alcock <nick.alcock@oracle.com>
65
66         * ctf-hash.c (ctf_dynhash_remove): Call with a mocked-up element.
67
68 2019-06-28  Nick Alcock <nick.alcock@oracle.com>
69
70         * ctf-dump.c (ctf_dump_format_type): Prefix hex strings with 0x.
71         (ctf_dump_funcs): Likewise.
72
73 2019-06-19  Nick Alcock <nick.alcock@oracle.com>
74
75         * ctf-open-bfd.c: Add swap.h and ctf-endian.h.
76         (ctf_fdopen): Check for endian-swapped raw CTF magic, and
77         little-endian CTF archive magic.  Do not check the CTF version:
78         ctf_simple_open does that in endian-safe ways.  Do not dereference
79         null pointers on open failure.
80
81 2019-06-19  Nick Alcock <nick.alcock@oracle.com>
82
83         * ctf-open.c (get_vbytes_common): Return the new slice size.
84         (ctf_bufopen): Flip the endianness of the CTF-section header copy.
85         Remember to copy in the CTF data when opening an uncompressed
86         foreign-endian CTF file.  Prune useless variable manipulation.
87
88 2019-06-19  Nick Alcock <nick.alcock@oracle.com>
89
90         * ctf-open.c (ctf_types): Fail when unidentified type kinds are
91         seen.
92
93 2019-06-19  Nick Alcock <nick.alcock@oracle.com>
94
95         * ctf-open.c (ctf_bufopen): Dump header offsets into the debugging
96         output.
97
98 2019-06-19  Nick Alcock <nick.alcock@oracle.com>
99
100         * ctf-subr.c (_PAGESIZE): Remove.
101         (ctf_data_alloc): Likewise.
102         (ctf_data_free): Likewise.
103         (ctf_data_protect): Likewise.
104         * ctf-impl.h: Remove declarations.
105         * ctf-create.c (ctf_update): No longer call ctf_data_protect: use
106         ctf_free, not ctf_data_free.
107         (ctf_compress_write): Use ctf_data_alloc, not ctf_alloc.  Free
108         the buffer again on compression error.
109         * ctf-open.c (ctf_set_base): No longer track the size: call
110         ctf_free, not ctf_data_free.
111         (upgrade_types): Likewise.  Call ctf_alloc, not ctf_data_alloc.
112         (ctf_bufopen): Likewise.  No longer call ctf_data_protect.
113
114 2019-06-19  Nick Alcock <nick.alcock@oracle.com>
115
116         * ctf-create.c (ctf_dtd_insert): Pass on error returns from
117         ctf_dynhash_insert.
118         (ctf_dvd_insert): Likewise.
119         (ctf_add_generic): Likewise.
120         (ctf_add_variable): Likewise.
121         * ctf-impl.h: Adjust declarations.
122
123 2019-06-14  Alan Modra  <amodra@gmail.com>
124
125         * configure: Regenerate.
126
127 2019-06-06  Nick Alcock  <nick.alcock@oracle.com>
128
129         * ctf-decls.h: Include <libiberty.h>.
130         * ctf-lookup.c (ctf_lookup_by_name): Call xstrndup(), not strndup().
131
132 2019-06-06  Nick Alcock  <nick.alcock@oracle.com>
133
134         * ctf-dump.c (ctf_dump_format_type): Cast size_t's used in printf()s.
135         (ctf_dump_objts): Likewise.
136         (ctf_dump_funcs): Likewise.
137         (ctf_dump_member): Likewise.
138         (ctf_dump_str): Likewise.
139
140 2019-06-06  Nick Alcock  <nick.alcock@oracle.com>
141
142         * ctf-archive.c (arc_mmap_header): Mark fd as potentially unused.
143         * ctf-subr.c (ctf_data_protect): Mark both args as potentially unused.
144
145 2019-06-05  Nick Alcock  <nick.alcock@oracle.com>
146
147         * ctf-archive.c (ctf_arc_write): Eschew %zi format specifier.
148         (ctf_arc_open_by_offset): Likewise.
149         * ctf-create.c (ctf_add_type): Likewise.
150
151 2019-06-04  Tom Tromey  <tromey@adacore.com>
152
153         * ctf-create.c (ctf_add_encoded, ctf_add_slice)
154         (ctf_add_member_offset): Use CHAR_BIT, not NBBY.
155
156 2019-06-04  Nick Alcock  <nick.alcock@oracle.com>
157
158         * configure.ac: Check for O_CLOEXEC.
159         * ctf-decls.h (O_CLOEXEC): Define (to 0), if need be.
160         * config.h.in: Regenerate.
161         * configure: Likewise.
162
163 2019-06-04  Nick Alcock  <nick.alcock@oracle.com>
164
165         * qsort_r.c: Rename to...
166         * ctf-qsort_r.c: ... this.
167         (_quicksort): Define to ctf_qsort_r.
168         * ctf-decls.h (qsort_r): Remove.
169         (ctf_qsort_r): Add.
170         (struct ctf_qsort_arg): New, transport the real ARG and COMPAR.
171         (ctf_qsort_compar_thunk): Rearrange the arguments to COMPAR.
172         * Makefile.am (libctf_a_LIBADD): Remove.
173         (libctf_a_SOURCES): New, add ctf-qsort_r.c.
174         * ctf-archive.c (ctf_arc_write): Call ctf_qsort_r, not qsort_r.
175         * ctf-create.c (ctf_update): Likewise.
176         * configure.ac: Check for BSD versus GNU qsort_r signature.
177         * Makefile.in: Regenerate.
178         * config.h.in: Likewise.
179         * configure: Likewise.
180
181 2019-06-03  Nick Alcock  <nick.alcock@oracle.com>
182
183         * ctf-dump.c (ctf_dump_funcs): Free in the right place.
184
185 2019-05-29  Nick Alcock  <nick.alcock@oracle.com>
186
187         * Makefile.am (ZLIB): New.
188         (ZLIBINC): Likewise.
189         (AM_CFLAGS): Use them.
190         (libctf_a_LIBADD): New, for LIBOBJS.
191         * configure.ac: Check for zlib, endian.h, and qsort_r.
192         * ctf-endian.h: New, providing htole64 and le64toh.
193         * swap.h: Code style fixes.
194         (bswap_identity_64): New.
195         * qsort_r.c: New, from gnulib (with one added #include).
196         * ctf-decls.h: New, providing a conditional qsort_r declaration,
197         and unconditional definitions of MIN and MAX.
198         * ctf-impl.h: Use it.  Do not use <sys/errno.h>.
199         (ctf_set_errno): Now returns unsigned long.
200         * ctf-util.c (ctf_set_errno): Adjust here too.
201         * ctf-archive.c: Use ctf-endian.h.
202         (ctf_arc_open_by_offset): Use memset, not bzero.  Drop cts_type,
203         cts_flags and cts_offset.
204         (ctf_arc_write): Drop debugging dependent on the size of off_t.
205         * ctf-create.c: Provide a definition of roundup if not defined.
206         (ctf_create): Drop cts_type, cts_flags and cts_offset.
207         (ctf_add_reftype): Do not check if type IDs are below zero.
208         (ctf_add_slice): Likewise.
209         (ctf_add_typedef): Likewise.
210         (ctf_add_member_offset): Cast error-returning ssize_t's to size_t
211         when known error-free.  Drop CTF_ERR usage for functions returning
212         int.
213         (ctf_add_member_encoded): Drop CTF_ERR usage for functions returning
214         int.
215         (ctf_add_variable): Likewise.
216         (enumcmp): Likewise.
217         (enumadd): Likewise.
218         (membcmp): Likewise.
219         (ctf_add_type): Likewise.  Cast error-returning ssize_t's to size_t
220         when known error-free.
221         * ctf-dump.c (ctf_is_slice): Drop CTF_ERR usage for functions
222         returning int: use CTF_ERR for functions returning ctf_type_id.
223         (ctf_dump_label): Likewise.
224         (ctf_dump_objts): Likewise.
225         * ctf-labels.c (ctf_label_topmost): Likewise.
226         (ctf_label_iter): Likewise.
227         (ctf_label_info): Likewise.
228         * ctf-lookup.c (ctf_func_args): Likewise.
229         * ctf-open.c (upgrade_types): Cast to size_t where appropriate.
230         (ctf_bufopen): Likewise.  Use zlib types as needed.
231         * ctf-types.c (ctf_member_iter): Drop CTF_ERR usage for functions
232         returning int.
233         (ctf_enum_iter): Likewise.
234         (ctf_type_size): Likewise.
235         (ctf_type_align): Likewise.  Cast to size_t where appropriate.
236         (ctf_type_kind_unsliced): Likewise.
237         (ctf_type_kind): Likewise.
238         (ctf_type_encoding): Likewise.
239         (ctf_member_info): Likewise.
240         (ctf_array_info): Likewise.
241         (ctf_enum_value): Likewise.
242         (ctf_type_rvisit): Likewise.
243         * ctf-open-bfd.c (ctf_bfdopen): Drop cts_type, cts_flags and
244         cts_offset.
245         (ctf_simple_open): Likewise.
246         (ctf_bfdopen_ctfsect): Likewise.  Set cts_size properly.
247         * Makefile.in: Regenerate.
248         * aclocal.m4: Likewise.
249         * config.h: Likewise.
250         * configure: Likewise.
251
252 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
253
254         * configure.in: Check for bfd_section_from_elf_index.
255         * configure: Regenerate.
256         * config.h.in [HAVE_BFD_ELF]: Likewise.
257         * libctf/ctf_open_bfd (ctf_bfdopen_ctfsect): Use it.
258         abfd is potentially unused now.
259
260 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
261
262         * Makefile.am: New.
263         * Makefile.in: Regenerated.
264         * config.h.in: Likewise.
265         * aclocal.m4: Likewise.
266         * configure: Likewise.
267
268 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
269
270         * ctf-dump.c: New.
271
272 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
273
274         * ctf-labels.c: New.
275
276 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
277
278         * ctf-impl.h (_libctf_version): New declaration.
279         * ctf-subr.c (_libctf_version): Define it.
280         (ctf_version): New.
281
282 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
283
284         * ctf-create.c (enumcmp): New.
285         (enumadd): Likewise.
286         (membcmp): Likewise.
287         (membadd): Likewise.
288         (ctf_add_type): Likewise.
289
290 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
291
292         * ctf-lookup.c (isqualifier): New.
293         (ctf_lookup_by_name): Likewise.
294         (struct ctf_lookup_var_key): Likewise.
295         (ctf_lookup_var): Likewise.
296         (ctf_lookup_variable): Likewise.
297         (ctf_lookup_symbol_name): Likewise.
298         (ctf_lookup_by_symbol): Likewise.
299         (ctf_func_info): Likewise.
300         (ctf_func_args): Likewise.
301
302 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
303
304         * ctf-decl.c: New file.
305         * ctf-types.c: Likewise.
306         * ctf-impl.h: New declarations.
307
308 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
309
310         * ctf-open-bfd.c: New file.
311         * ctf-open.c (ctf_close): New.
312         * ctf-impl.h: Include bfd.h.
313         (ctf_file): New members ctf_data_mmapped, ctf_data_mmapped_len.
314         (ctf_archive_internal): New members ctfi_abfd, ctfi_data,
315         ctfi_bfd_close.
316         (ctf_bfdopen_ctfsect): New declaration.
317         (_CTF_SECTION): likewise.
318
319 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
320
321         * ctf-archive.c: New.
322         * ctf-impl.h (ctf_archive_internal): New type.
323         (ctf_arc_open_internal): New declaration.
324         (ctf_arc_bufopen): Likewise.
325         (ctf_arc_close_internal): Likewise.
326
327 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
328
329         * ctf-open.c: New file.
330         * swap.h: Likewise.
331
332 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
333
334         * ctf-create.c: New file.
335         * ctf-lookup.c: New file.
336
337 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
338
339         * ctf-impl.h: New definitions and declarations for type creation
340         and lookup.
341
342 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
343
344         * ctf-hash.c: New file.
345         * ctf-impl.h: New declarations.
346
347 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
348
349         * ctf-error.c: New file.
350
351 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
352
353         * ctf-util.c: New file.
354         * elf.h: Likewise.
355         * ctf-impl.h: Include it, and add declarations.
356
357 2019-05-28  Nick Alcock  <nick.alcock@oracle.com>
358
359         * ctf-impl.h: New file.
360         * ctf-subr.c: New file.
361
362 \f
363 Local Variables:
364 mode: change-log
365 left-margin: 8
366 fill-column: 76
367 version-control: never
368 End: