8d2229ad1e
This rather large and intertwined pile of changes does three things: First, it transitions from dprintf to ctf_err_warn for things the user might care about: this one file is the major impetus for the ctf_err_warn infrastructure, because things like file names are crucial in linker error messages, and errno values are utterly incapable of communicating them Second, it stabilizes the ctf_link APIs: you can now call ctf_link_add_ctf without a CTF argument (only a NAME), to lazily ctf_open the file with the given NAME when needed, and close it as soon as possible, to save memory. This is not an API change because a null CTF argument was prohibited before now. Since getting CTF directly from files uses ctf_open, passing in only a NAME requires use of libctf, not libctf-nobfd. The linker's behaviour is unchanged, as it still passes in a ctf_archive_t as before. This also let us fix a leak: we were opening ctf_archives and their containing ctf_files, then only closing the files and leaving the archives open. Third, this commit restructures the ctf_link_in_member argument used by the CTF linking machinery and adjusts its users accordingly. We drop two members: - arcname, which is difficult to construct and then only used in error messages (that were only dprintf()ed, so never seen!) - share_mode, since we store the flags passed to ctf_link (including the share mode) in a new ctf_file_t.ctf_link_flags to help dedup get hold of it We rename others whose existing names were fairly dreadful: - done_main_member -> done_parent, using consistent terminology for .ctf as the parent of all archive members - main_input_fp -> in_fp_parent, likewise - file_name -> in_file_name, likewise We add one new member, cu_mapped. Finally, we move the various frees of things like mapping table data to the top-level ctf_link, since deduplicating links will want to do that too. include/ * ctf-api.h (ECTF_NEEDSBFD): New. (ECTF_NERR): Adjust. (ctf_link): Rename share_mode arg to flags. libctf/ * Makefile.am: Set -DNOBFD=1 in libctf-nobfd, and =0 elsewhere. * Makefile.in: Regenerated. * ctf-impl.h (ctf_link_input_name): New. (ctf_file_t) <ctf_link_flags>: New. * ctf-create.c (ctf_serialize): Adjust accordingly. * ctf-link.c: Define ctf_open as weak when PIC. (ctf_arc_close_thunk): Remove unnecessary thunk. (ctf_file_close_thunk): Likewise. (ctf_link_input_name): New. (ctf_link_input_t): New value of the ctf_file_t.ctf_link_input. (ctf_link_input_close): Adjust accordingly. (ctf_link_add_ctf_internal): New, split from... (ctf_link_add_ctf): ... here. Return error if lazy loading of CTF is not possible. Change to just call... (ctf_link_add): ... this new function. (ctf_link_add_cu_mapping): Transition to ctf_err_warn. Drop the ctf_file_close_thunk. (ctf_link_in_member_cb_arg_t) <file_name> Rename to... <in_file_name>: ... this. <arcname>: Drop. <share_mode>: Likewise (migrated to ctf_link_flags). <done_main_member>: Rename to... <done_parent>: ... this. <main_input_fp>: Rename to... <in_fp_parent>: ... this. <cu_mapped>: New. (ctf_link_one_type): Adjuwt accordingly. Transition to ctf_err_warn, removing a TODO. (ctf_link_one_variable): Note a case too common to warn about. Report in the debug stream if a cu-mapped link prevents addition of a conflicting variable. (ctf_link_one_input_archive_member): Adjust. (ctf_link_lazy_open): New, open a CTF archive for linking when needed. (ctf_link_close_one_input_archive): New, close it again. (ctf_link_one_input_archive): Adjust for lazy opening, member renames, and ctf_err_warn transition. Move the empty_link_type_mapping call to... (ctf_link): ... here. Adjut for renamings and thunk removal. Don't spuriously fail if some input contains no CTF data. (ctf_link_write): ctf_err_warn transition. * libctf.ver: Remove not-yet-stable comment.
176 lines
3.0 KiB
Plaintext
176 lines
3.0 KiB
Plaintext
/* Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
|
|
|
This file is part of libctf.
|
|
|
|
libctf is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
version.
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; see the file COPYING. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
LIBCTF_1.0 {
|
|
global:
|
|
/* In libctf and libctf-nobfd. */
|
|
|
|
ctf_bufopen;
|
|
ctf_simple_open;
|
|
ctf_create;
|
|
ctf_close;
|
|
ctf_ref;
|
|
ctf_file_close;
|
|
|
|
ctf_cuname;
|
|
ctf_cuname_set;
|
|
ctf_parent_file;
|
|
ctf_parent_name;
|
|
ctf_parent_name_set;
|
|
ctf_type_isparent;
|
|
ctf_type_ischild;
|
|
|
|
ctf_import;
|
|
ctf_setmodel;
|
|
ctf_getmodel;
|
|
|
|
ctf_setspecific;
|
|
ctf_getspecific;
|
|
|
|
ctf_errno;
|
|
ctf_errmsg;
|
|
ctf_version;
|
|
|
|
ctf_func_info;
|
|
ctf_func_args;
|
|
ctf_func_type_info;
|
|
ctf_func_type_args;
|
|
|
|
ctf_lookup_by_name;
|
|
ctf_lookup_by_symbol;
|
|
ctf_lookup_variable;
|
|
|
|
ctf_type_resolve;
|
|
ctf_type_lname;
|
|
ctf_type_name;
|
|
ctf_type_name_raw;
|
|
ctf_type_aname;
|
|
ctf_type_aname_raw;
|
|
ctf_type_size;
|
|
ctf_type_align;
|
|
ctf_type_kind;
|
|
ctf_type_kind_forwarded;
|
|
ctf_type_reference;
|
|
ctf_type_pointer;
|
|
ctf_type_encoding;
|
|
ctf_type_visit;
|
|
ctf_type_cmp;
|
|
ctf_type_compat;
|
|
|
|
ctf_member_info;
|
|
ctf_member_next;
|
|
ctf_array_info;
|
|
ctf_member_count;
|
|
|
|
ctf_enum_name;
|
|
ctf_enum_value;
|
|
|
|
ctf_label_set;
|
|
ctf_label_get;
|
|
|
|
ctf_label_topmost;
|
|
ctf_label_info;
|
|
|
|
ctf_member_iter;
|
|
ctf_enum_iter;
|
|
ctf_enum_next;
|
|
ctf_type_iter;
|
|
ctf_type_next;
|
|
ctf_type_iter_all;
|
|
ctf_label_iter;
|
|
ctf_variable_iter;
|
|
ctf_variable_next;
|
|
|
|
ctf_next_create;
|
|
ctf_next_destroy;
|
|
ctf_next_copy;
|
|
|
|
ctf_add_array;
|
|
ctf_add_const;
|
|
ctf_add_enum;
|
|
ctf_add_enum_encoded;
|
|
ctf_add_float;
|
|
ctf_add_forward;
|
|
ctf_add_function;
|
|
ctf_add_integer;
|
|
ctf_add_pointer;
|
|
ctf_add_type;
|
|
ctf_add_typedef;
|
|
ctf_add_restrict;
|
|
ctf_add_slice;
|
|
ctf_add_struct;
|
|
ctf_add_union;
|
|
ctf_add_struct_sized;
|
|
ctf_add_union_sized;
|
|
ctf_add_volatile;
|
|
|
|
ctf_add_enumerator;
|
|
ctf_add_member;
|
|
ctf_add_member_offset;
|
|
ctf_add_member_encoded;
|
|
ctf_add_variable;
|
|
|
|
ctf_set_array;
|
|
|
|
ctf_update;
|
|
ctf_discard;
|
|
ctf_snapshot;
|
|
ctf_rollback;
|
|
ctf_write;
|
|
ctf_write_mem;
|
|
ctf_gzwrite;
|
|
ctf_compress_write;
|
|
ctf_getdatasect;
|
|
|
|
ctf_arc_write;
|
|
ctf_arc_write_fd;
|
|
ctf_arc_open;
|
|
ctf_arc_bufopen;
|
|
ctf_arc_close;
|
|
ctf_arc_open_by_name;
|
|
ctf_arc_open_by_name_sections;
|
|
ctf_archive_count;
|
|
ctf_archive_iter;
|
|
ctf_archive_next;
|
|
ctf_archive_raw_iter;
|
|
ctf_get_arc;
|
|
|
|
ctf_dump;
|
|
|
|
ctf_setdebug;
|
|
ctf_getdebug;
|
|
ctf_errwarning_next;
|
|
|
|
ctf_link_add_ctf;
|
|
ctf_link_add_cu_mapping;
|
|
ctf_link_set_memb_name_changer;
|
|
ctf_link;
|
|
ctf_link_add_strtab;
|
|
ctf_link_shuffle_syms;
|
|
ctf_link_write;
|
|
|
|
/* In libctf alone. */
|
|
|
|
ctf_fdopen;
|
|
ctf_open;
|
|
ctf_bfdopen;
|
|
ctf_bfdopen_ctfsect;
|
|
local:
|
|
*;
|
|
};
|