summaryrefslogtreecommitdiff
path: root/gold/fileread.cc
Commit message (Collapse)AuthorAgeFilesLines
* Update year range in copyright notice of binutils filesAlan Modra2023-01-011-1/+1
| | | | | | The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
* Have gold's File_read::do_read() function check the start parameterNick Clifton2022-06-271-0/+6
| | | | | | PR 23765 * fileread.cc (File_read::do_read): Check start parameter before computing number of bytes to read.
* Update year range in copyright notice of binutils filesAlan Modra2022-01-021-1/+1
| | | | | | | | | | The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
* Update year range in copyright notice of binutils filesAlan Modra2021-01-011-1/+1
|
* gold: ensure file_counts_lock is initialized before usingNick Gasson2020-11-031-0/+1
| | | | | | | | | | | | | | | | | | | | Since upgrading to binutils 2.35 I've been experiencing random memory corruption related crashes with ld.gold --threads. It's caused by multiple threads concurrently pushing elements onto the shared std::vector in File_read::record_file_read(). This vector is supposed to be protected by file_counts_lock, but that is initialized lazily and might be NULL when File_read::open() is called, in which case Hold_optional_lock silently skips locking it. Fix by calling the initialize() method before attempting to acquire the lock, the same as other places that use file_counts_lock. PR 26827 * fileread.cc (File_read::open): Ensure file_counts_lock is initialized. * testsuite/Makefile.am (check_PROGRAMS): Add a test that passes -Wl,--threads. * testsuite/Makefile.in: Regenerate.
* PR 22843: ld, gold: Add --dependency-file option.Roland McGrath2020-06-231-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | gold/ * options.h (class General_options): Add --dependency-file option. * fileread.cc (File_read::files_read): New static variable. (File_read::open): Add the file to the files_read list. (File_read::record_file_read): New static member function. (File_read::write_dependency_file): New static member function. * fileread.h (class File_read): Declare them. * layout.cc (Layout::read_layout_from_file): Call record_file_read. (Close_task_runner::run): Call write_dependency_file if --dependency-file was passed. ld/ * NEWS: Note --dependency-file. * ld.texi (Options): Document --dependency-file. * ldlex.h (enum option_values): Add OPTION_DEPENDENCY_FILE. * ld.h (ld_config_type): New member dependency_file. * lexsup.c (ld_options, parse_args): Parse --dependency-file. * ldmain.c (struct dependency_file): New type. (dependency_files, dependency_files_tail): New static variables. (track_dependency_files): New function. (write_dependency_file): New function. (main): Call it when --dependency-file was passed. * ldfile.c (ldfile_try_open_bfd): Call track_dependency_files. (ldfile_open_command_file_1): Likewise. * ldelf.c (ldelf_try_needed): Likewise. * pe-dll.c (pe_implied_import_dll): Likewise.
* Update year range in copyright notice of binutils filesAlan Modra2020-01-011-1/+1
|
* Update year range in copyright notice of binutils filesAlan Modra2019-01-011-1/+1
|
* Update year range in copyright notice of binutils filesAlan Modra2018-01-031-1/+1
|
* Update year range in copyright notice of all files.Alan Modra2017-01-021-1/+1
|
* Copyright update for binutilsAlan Modra2016-01-011-1/+1
|
* Add extra debugging output for files and descriptors.Cary Coutant2015-02-031-0/+2
| | | | | | | | | | | gold/ * descriptors.cc (Descriptors::open): Set artificially-low limit for file descriptors when debugging enabled. Add debug output. (Descriptors::release): Add debug output. (Descriptors::close_some_descriptor): Likewise. (Descriptors::close_all): Likewise. * fileread.cc (File_read::lock): Likewise. (File_read::unlock): Likewise.
* ChangeLog rotatation and copyright year updateAlan Modra2015-01-021-1/+1
|
* Update copyright yearsAlan Modra2014-03-051-2/+1
|
* gold/Roland McGrath2012-12-101-21/+32
| | | | | | | * testsuite/binary_unittest.cc (read_all): New function. (Sized_binary_test): Use it instead of ::read. * fileread.cc (do_read): Don't assume pread always reads the whole amount in a single call.
* gold/Cary Coutant2012-10-231-0/+10
| | | | | * fileread.cc (Input_file::Input_file): New constructor. * fileread.h (class Input_file): Add new constructor.
* PR gold/13288Cary Coutant2011-10-171-10/+17
| | | | | | * gold/fileread.cc (File_read::find_view): Add assert. (File_read::make_view): Move bounds check (replace with assert)... (File_read::find_or_make_view): ... to here.
* * dirsearch.cc (Dirsearch::find): Replace n1 and n2 parametersIan Lance Taylor2011-05-251-32/+26
| | | | | | with name parameter. Add found_name parameter. * fileread.cc (Input_file::find_file): Adjust code accordingly. * dirsearch.h (class Dirsearch): Update declaration.
* * configure.ac: Check for sys/mman.h and mmap. Check for mremapIan Lance Taylor2011-04-121-21/+67
| | | | | | | | | | | | | | | | | | | | | | | | with MREMAP_MAYMOVE. * output.h (class Output_file): Add map_is_allocated_ field. * output.cc: Only #include <sys/mman.h> if it exists. If mmap is not available, provide stubs. If mremap is not available, #define it to gold_mremap. (MREMAP_MAYMOVE): Define if not defined. (Output_file::Output_file): Initialize map_is_allocated_. (Output_file::resize): Check map_is_allocated_. (Output_file::map_anonymous): If mmap fails, use malloc. (Output_file::unmap): Don't do anything for an anonymous map. * fileread.cc: Only #include <sys/mman.h> if it exists. If mmap is not available, provide stubs. (File_read::View::~View): Use free rather than delete[]. (File_read::make_view): Use malloc rather than new[]. If mmap fails, use malloc. (File_read::find_or_make_view): Use malloc rather than new[]. * gold.h: Remove HAVE_REMAP code. * mremap.c: #include <errno.h>. Only #include <sys/mman.h> if it exists. Rename mremap to gold_mremap. If mmap is not available don't do anything. * configure, config.in: Rebuild.
* * archive.cc (Archive::include_member): Adjust call toCary Coutant2011-04-121-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | report_object. (Add_archive_symbols::run): Track argument serial numbers. (Lib_group::include_member): Likewise. (Add_lib_group_symbols::run): Adjust call to report_archive_begin. * archive.h (Incremental_archive_entry::Archive_member): Initialize arg_serial_. (Archive_member::arg_serial_): New data member. * dynobj.cc (Dynobj::Dynobj): Allow input_file_ to be NULL. (Sized_dynobj::do_add_symbols): Track symbols when doing an incremental link. (Sized_dynobj::do_for_all_local_got_entries): New function. * dynobj.h: (Sized_dynobj::do_for_all_local_got_entries): New function. * fileread.cc (get_mtime): New function. * fileread.h (get_mtime): New function. * gold.cc (queue_initial_tasks): Check for incremental update. (process_incremental_input): New function. (queue_middle_tasks): Don't force valid target for incremental update. * incremental-dump.cc (find_input_containing_global): Adjust size of symbol info entry. (dump_incremental_inputs): Dump argument serial number and in_system_directory flag; bias shndx by 1; print symbol names when dumping per-file symbol lists; use new symbol info readers. * incremental.cc (Output_section_incremental_inputs:update_data_size): New function. (Sized_incremental_binary::setup_readers): Setup input readers for each input file; build maps for files added from libraries and scripts. (Sized_incremental_binary::check_input_args): New function. (Sized_incremental_binary::do_check_inputs): Build map of argument serial numbers to input arguments. (Sized_incremental_binary::do_file_has_changed): Rename do_file_is_unchanged to this; compare file modification times. (Sized_incremental_binary::do_init_layout): New function. (Sized_incremental_binary::do_reserve_layout): New function. (Sized_incremental_binary::do_get_input_reader): Remove. (Sized_incremental_binary::get_symtab_view): New function. (Incremental_checker::can_incrementally_link_output_file): Remove. (Incremental_inputs::report_command_line): Exclude --debug options. (Incremental_inputs::report_archive_begin): Add parameter; track argument serial numbers; don't put input file entry for archive before archive members. (Incremental_inputs::report_archive_end): Put input file entry for archive after archive members. (Incremental_inputs::report_object): Add parameter; track argument serial numbers and in_system_directory flag. (Incremental_inputs::report_script): Add parameter; track argument serial numbers. (Output_section_incremental_inputs::set_final_data_size): Adjust size of symbol info entry; check for forwarding symbols. (Output_section_incremental_inputs::write_input_files): Write in_system_directory flag and argument serial number. (Output_section_incremental_inputs::write_info_blocks): Map section indices between incremental info and original input file; store input section index for each symbol. (class Local_got_offset_visitor): Derive from Got_offset_list::Visitor; change operator() to visit(). (class Global_got_offset_visitor): Likewise. (class Global_symbol_visitor_got_plt): (Output_section_incremental_inputs::write_got_plt): Use new visitor classes. (Sized_incr_relobj::Sized_incr_relobj): New constructor. (Sized_incr_relobj::do_read_symbols): New function. (Sized_incr_relobj::do_layout): New function. (Sized_incr_relobj::do_layout_deferred_sections): New function. (Sized_incr_relobj::do_add_symbols): New function. (Sized_incr_relobj::do_should_include_member): New function. (Sized_incr_relobj::do_for_all_global_symbols): New function. (Sized_incr_relobj::do_for_all_local_got_entries): New function. (Sized_incr_relobj::do_section_size): New function. (Sized_incr_relobj::do_section_name): New function. (Sized_incr_relobj::do_section_contents): New function. (Sized_incr_relobj::do_section_flags): New function. (Sized_incr_relobj::do_section_entsize): New function. (Sized_incr_relobj::do_section_address): New function. (Sized_incr_relobj::do_section_type): New function. (Sized_incr_relobj::do_section_link): New function. (Sized_incr_relobj::do_section_info): New function. (Sized_incr_relobj::do_section_addralign): New function. (Sized_incr_relobj::do_initialize_xindex): New function. (Sized_incr_relobj::do_get_global_symbol_counts): New function. (Sized_incr_relobj::do_read_relocs): New function. (Sized_incr_relobj::do_gc_process_relocs): New function. (Sized_incr_relobj::do_scan_relocs): New function. (Sized_incr_relobj::do_count_local_symbols): New function. (Sized_incr_relobj::do_finalize_local_symbols): New function. (Sized_incr_relobj::do_set_local_dynsym_indexes): New function. (Sized_incr_relobj::do_set_local_dynsym_offset): New function. (Sized_incr_relobj::do_relocate): New function. (Sized_incr_relobj::do_set_section_offset): New function. (Sized_incr_dynobj::Sized_incr_dynobj): New function. (Sized_incr_dynobj::do_read_symbols): New function. (Sized_incr_dynobj::do_layout): New function. (Sized_incr_dynobj::do_add_symbols): New function. (Sized_incr_dynobj::do_should_include_member): New function. (Sized_incr_dynobj::do_for_all_global_symbols): New function. (Sized_incr_dynobj::do_for_all_local_got_entries): New function. (Sized_incr_dynobj::do_section_size): New function. (Sized_incr_dynobj::do_section_name): New function. (Sized_incr_dynobj::do_section_contents): New function. (Sized_incr_dynobj::do_section_flags): New function. (Sized_incr_dynobj::do_section_entsize): New function. (Sized_incr_dynobj::do_section_address): New function. (Sized_incr_dynobj::do_section_type): New function. (Sized_incr_dynobj::do_section_link): New function. (Sized_incr_dynobj::do_section_info): New function. (Sized_incr_dynobj::do_section_addralign): New function. (Sized_incr_dynobj::do_initialize_xindex): New function. (Sized_incr_dynobj::do_get_global_symbol_counts): New function. (make_sized_incremental_object): New function. (Incremental_library::copy_unused_symbols): New function. (Incremental_library::do_for_all_unused_symbols): New function. * incremental.h (enum Incremental_input_flags): New type. (class Incremental_checker): Remove. (Incremental_input_entry::Incremental_input_entry): Add argument serial number. (Incremental_input_entry::arg_serial): New function. (Incremental_input_entry::set_is_in_system_directory): New function. (Incremental_input_entry::is_in_system_directory): New function. (Incremental_input_entry::arg_serial_): New data member. (Incremental_input_entry::is_in_system_directory_): New data member. (class Script_info): Move here from script.h. (Script_info::Script_info): Add filename parameter. (Script_info::filename): New function. (Script_info::filename_): New data member. (Incremental_script_entry::Incremental_script_entry): Add argument serial number. (Incremental_object_entry::Incremental_object_entry): Likewise. (Incremental_object_entry::add_input_section): Build list of input sections with map to original shndx. (Incremental_object_entry::get_input_section_index): New function. (Incremental_object_entry::shndx_): New data member. (Incremental_object_entry::name_key_): Rename; adjust all refs. (Incremental_object_entry::sh_size_): Rename; adjust all refs. (Incremental_archive_entry::Incremental_archive_entry): Add argument serial number. (Incremental_inputs::report_archive_begin): Likewise. (Incremental_inputs::report_object): Likewise. (Incremental_inputs::report_script): Likewise. (class Incremental_global_symbol_reader): New class. (Incremental_input_entry_reader::Incremental_input_entry_reader): Read and store flags and input file type. (Incremental_input_entry_reader::arg_serial): New function. (Incremental_input_entry_reader::type): Extract type from flags. (Incremental_input_entry_reader::is_in_system_directory): New function. (Incremental_input_entry_reader::get_input_section_count): Call accessor function for type. (Incremental_input_entry_reader::get_symbol_offset): Call accessor function for type; adjust size of global symbol entry. (Incremental_input_entry_reader::get_global_symbol_count): Call accessor function for type. (Incremental_input_entry_reader::get_object_count): Likewise. (Incremental_input_entry_reader::get_object_offset): Likewise. (Incremental_input_entry_reader::get_member_count): Likewise. (Incremental_input_entry_reader::get_unused_symbol_count): Likewise. (Incremental_input_entry_reader::get_member_offset): Likewise. (Incremental_input_entry_reader::get_unused_symbol): Likewise. (Incremental_input_entry_reader::Global_symbol_info): Remove. (Incremental_input_entry_reader::get_global_symbol_info): Remove. (Incremental_input_entry_reader::get_global_symbol_reader): New function. (Incremental_input_entry_reader::get_output_symbol_index): New function. (Incremental_input_entry_reader::type_): Remove. (Incremental_input_entry_reader::flags_): New data member. (Incremental_inputs_reader::input_file_offset): New function. (Incremental_inputs_reader::input_file_index): New function. (Incremental_inputs_reader::input_file): Call input_file_offset. (Incremental_inputs_reader::input_file_at_offset): New function. (Incremental_relocs_reader::get_r_type): Reformat. (Incremental_relocs_reader::get_r_shndx): Reformat. (Incremental_relocs_reader::get_r_offset): Reformat. (Incremental_relocs_reader::data): New function. (Incremental_binary::Incremental_binary): Initialize new data members. (Incremental_binary::check_inputs): Add cmdline parameter. (Incremental_binary::file_is_unchanged): Remove. (Input_reader::arg_serial): New function. (Input_reader::get_unused_symbol_count): New function. (Input_reader::get_unused_symbol): New function. (Input_reader::do_arg_serial): New function. (Input_reader::do_get_unused_symbol_count): New function. (Input_reader::do_get_unused_symbol): New function. (Incremental_binary::input_file_count): New function. (Incremental_binary::get_input_reader): Change signature to use index instead of filename. (Incremental_binary::file_has_changed): New function. (Incremental_binary::get_input_argument): New function. (Incremental_binary::get_library): New function. (Incremental_binary::get_script_info): New function. (Incremental_binary::init_layout): New function. (Incremental_binary::reserve_layout): New function. (Incremental_binary::output_file): New function. (Incremental_binary::do_check_inputs): New function. (Incremental_binary::do_file_is_unchanged): Remove. (Incremental_binary::do_file_has_changed): New function. (Incremental_binary::do_init_layout): New function. (Incremental_binary::do_reserve_layout): New function. (Incremental_binary::do_input_file_count): New function. (Incremental_binary::do_get_input_reader): Change signature. (Incremental_binary::input_args_map_): New data member. (Incremental_binary::library_map_): New data member. (Incremental_binary::script_map_): New data member. (Sized_incremental_binary::Sized_incremental_binary): Initialize new data members. (Sized_incremental_binary::output_section): New function. (Sized_incremental_binary::inputs_reader): Add const. (Sized_incremental_binary::symtab_reader): Add const. (Sized_incremental_binary::relocs_reader): Add const. (Sized_incremental_binary::got_plt_reader): Add const. (Sized_incremental_binary::get_symtab_view): New function. (Sized_incremental_binary::Inputs_reader): New typedef. (Sized_incremental_binary::Input_entry_reader): New typedef. (Sized_incremental_binary::do_check_inputs): Add cmdline parameter. (Sized_incremental_binary::do_file_is_unchanged): Remove. (Sized_incremental_binary::do_file_has_changed): New function. (Sized_incremental_binary::do_init_layout): New function. (Sized_incremental_binary::do_reserve_layout): New function. (Sized_input_reader::Inputs_reader): Remove. (Sized_input_reader::Input_entry_reader): Remove. (Sized_input_reader::do_arg_serial): New function. (Sized_input_reader::do_get_unused_symbol_count): New function. (Sized_input_reader::do_get_unused_symbol): New function. (Sized_incremental_binary::do_input_file_count): New function. (Sized_incremental_binary::do_get_input_reader): Change signature; use index instead of filename. (Sized_incremental_binary::section_map_): New data member. (Sized_incremental_binary::input_entry_readers_): New data member. (class Sized_incr_relobj): New class. (class Sized_incr_dynobj): New class. (make_sized_incremental_object): New function. (class Incremental_library): New class. * layout.cc (Free_list::num_lists): New static data member. (Free_list::num_nodes): New static data member. (Free_list::num_removes): New static data member. (Free_list::num_remove_visits): New static data member. (Free_list::num_allocates): New static data member. (Free_list::num_allocate_visits): New static data member. (Free_list::init): New function. (Free_list::remove): New function. (Free_list::allocate): New function. (Free_list::dump): New function. (Free_list::print_stats): New function. (Layout_task_runner::run): Resize output file for incremental updates. (Layout::Layout): Initialize new data members. (Layout::set_incremental_base): New function. (Layout::init_fixed_output_section): New function. (Layout::layout_eh_frame): Do not build .eh_frame_hdr section for incremental updates. (Layout::create_gold_note): Do not create gold note section for incremental updates. (Layout::set_segment_offsets): Do not recalculate RELRO alignment for incremental updates. (Layout::set_section_offsets): For incremental updates, allocate space from free list. (Layout::create_symtab_sections): Layout with offsets relative to start of section; for incremental updates, allocate space from free list. (Layout::create_shdrs): For incremental updates, allocate space from free list. (Layout::finish_dynamic_section): For incremental updates, do not check --as-needed (fixed in subsequent patch). * layout.h (class Free_list): New class. (Layout::set_incremental_base): New function. (Layout::incremental_base): New function. (Layout::init_fixed_output_section): New function. (Layout::allocate): New function. (Layout::incremental_base_): New data member. (Layout::free_list_): New data member. * main.cc (main): Print Free_list statistics. * object.cc (Relobj::finalize_incremental_relocs): Add clear_counts parameter; clear counts only when clear_counts is set. (Sized_relobj::Sized_relobj): Initialize new base class. (Sized_relobj::do_layout): Don't report special sections. (Sized_relobj::do_for_all_local_got_entries): New function. (Sized_relobj::write_local_symbols): Add symtab_off parameter; add symtab_off to all symbol table offsets. (Sized_relobj::do_get_global_symbol_counts): Add typename keyword. * object.h (class Got_offset_list): Move to top of file. (Object::Object): Allow case where input_file == NULL. (Object::~Object): Likewise. (Object::input_file): Assert that input_file != NULL. (Object::lock): Allow case where input_file == NULL. (Object::unlock): Likewise. (Object::is_locked): Likewise. (Object::token): Likewise. (Object::release): Likewise. (Object::is_incremental): New function. (Object::get_mtime): New function. (Object::for_all_local_got_entries): New function. (Object::clear_view_cache_marks): Allow case where input_file == NULL. (Object::set_is_in_system_directory): New function. (Object::is_in_system_directory): New function. (Object::do_is_incremental): New function. (Object::do_get_mtime): New function. (Object::do_for_all_local_got_entries): New function. (Object::is_in_system_directory_): New data member. (Relobj::finalize_incremental_relocs): Add clear_counts parameter. (class Sized_relobj_base): New class. (class Sized_relobj): Derive from Sized_relobj_base. (class Sized_relobj::Symbols): Redeclare from base class. (class Sized_relobj::local_got_offset_list): Remove. (class Sized_relobj::Output_sections): Redeclare from base class. (class Sized_relobj::do_for_all_local_got_entries): New function. (class Sized_relobj::write_local_symbols): Add offset parameter. (class Sized_relobj::local_symbol_offset_): Update comment. (class Sized_relobj::local_dynsym_offset_): Update comment. * options.cc (Input_arguments::add_file): Remove const. * options.h (Input_file_argument::Input_file_argument): Initialize arg_serial_ (all constructors). (Input_file_argument::set_arg_serial): New function. (Input_file_argument::arg_serial): New function. (Input_file_argument::arg_serial_): New data member. (Input_arguments::Input_arguments): Initialize file_count_. (Input_arguments::add_file): Remove const. (Input_arguments::number_of_input_files): New function. (Input_arguments::file_count_): New data member. (Command_line::number_of_input_files): Call Input_arguments::number_of_input_files. * output.cc (Output_segment_headers::Output_segment_headers): Set current size. (Output_section::Input_section::current_data_size): New function. (Output_section::Output_section): Initialize new data members. (Output_section::add_input_section): Don't do merge sections for an incremental link; allocate space from free list for an incremental update. (Output_section::add_output_section_data): Allocate space from free list for an incremental update. (Output_section::update_data_size): New function. (Output_section::set_fixed_layout): New function. (Output_section::reserve): New function. (Output_segment::set_section_addresses): Remove const. (Output_segment::set_section_list_addresses): Remove const; allocate space from free list for an incremental update. (Output_segment::set_offset): Adjust size of RELRO segment for an incremental update. * output.h (Output_data::current_data_size): Move here from child classes. (Output_data::pre_finalize_data_size): New function. (Output_data::update_data_size): New function. (Output_section_headers::update_data_size): new function. (Output_section_data_build::current_data_size): Move to Output_data. (Output_data_strtab::update_data_size): New function. (Output_section::current_data_size): Move to Output_data. (Output_section::set_fixed_layout): New function. (Output_section::has_fixed_layout): New function. (Output_section::reserve): New function. (Output_section::update_data_size): New function. (Output_section::has_fixed_layout_): New data member. (Output_section::free_list_): New data member. (Output_segment::set_section_addresses): Remove const. (Output_segment::set_section_list_addresses): Remove const. * plugin.cc (Sized_pluginobj::do_for_all_local_got_entries): New function. * plugin.h (Sized_pluginobj::do_for_all_local_got_entries): New function. * readsyms.cc (Read_symbols::do_read_symbols): Add library parameter when calling Add_symbols constructor; store argument serial number for members of a lib group. (Add_symbols::locks): Allow case where token == NULL. (Add_symbols::run): Report libraries denoted by --start-lib/--end-lib. (Read_member::~Read_member): New function. (Read_member::is_runnable): New function. (Read_member::locks): New function. (Read_member::run): New function. (Check_script::~Check_script): New function. (Check_script::is_runnable): New function. (Check_script::locks): New function. (Check_script::run): New function. (Check_library::~Check_library): New function. (Check_library::is_runnable): New function. (Check_library::locks): New function. (Check_library::run): New function. * readsyms.h (Add_symbols::Add_symbols): Add library parameter. (Add_symbols::library_): New data member. (class Read_member): New class. (class Check_script): New class. (class Check_library): New class. * reloc.cc (Read_relocs::is_runnable): Allow case where token == NULL. (Read_relocs::locks): Likewise. (Scan_relocs::locks): Likewise. (Relocate_task::locks): Likewise. (Sized_relobj::do_scan_relocs): Tell finalize_incremental_relocs to clear counters. (Sized_relobj::incremental_relocs_scan): Fix comment. (Sized_relobj::do_relocate): Pass output file offset to write_local_symbols. (Sized_relobj::incremental_relocs_write_reltype): Use reloc_size from class declaration. * script.cc (read_input_script): Allocate Script_info; pass argument serial number to report_script. * script.h (class Script_info): Move to incremental.h. * symtab.cc (Symbol_table::add_from_incrobj): New function. * symtab.h (Symbol_table::add_from_incrobj): New function. (Symbol_table::set_file_offset): New function.
* * fileread.cc (File_read::clear_views): Don't delete the wholeIan Lance Taylor2011-03-101-1/+3
| | | | file view.
* PR gold/12525Ian Lance Taylor2011-03-091-2/+14
| | | | | | | | * fileread.cc: #include <climits>. (GOLD_IOV_MAX): Define. (File_read::read_multiple): Limit number of entries by iov_max. * fileread.h (class File_read): Always set max_readv_entries to 128.
* gold: fix race in FileRead::~View.Ralf Wildenhues2010-12-141-10/+17
| | | | | | | | | gold/: * fileread.cc (file_counts_lock, file_counts_initialize_lock) (total_mapped_bytes, current_mapped_bytes, maximum_mapped_bytes): Move definition before File_read::View member definitions. (File_read::View::~View): Initialize and hold lock before updating current_mapped_bytes.
* gold/Richard Sandiford2010-10-121-0/+2
| | | | | * fileread.cc (Input_file::find_file): Initialize *found_name and *namep when using the fallback search for case 4.
* * archive.cc: Formatting fixes: Remove whitespace betweenNick Clifton2010-08-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | typename and following asterisk. Remove whitespace between function name and opening parenthesis. * archive.h: Likewise. * arm.cc: Likewise. * attributes.cc: Likewise. * attributes.h: Likewise. * common.cc: Likewise. * copy-relocs.cc: Likewise. * dirsearch.h: Likewise. * dynobj.cc: Likewise. * ehframe.cc: Likewise. * ehframe.h: Likewise. * expression.cc: Likewise. * fileread.cc: Likewise. * fileread.h: Likewise. * gc.h: Likewise. * gold-threads.cc: Likewise. * gold.cc: Likewise. * i386.cc: Likewise. * icf.h: Likewise. * incremental-dump.cc: Likewise. * incremental.cc: Likewise. * layout.cc: Likewise. * layout.h: Likewise. * main.cc: Likewise. * merge.cc: Likewise. * merge.h: Likewise. * object.cc: Likewise. * object.h: Likewise. * options.cc: Likewise. * options.h: Likewise. * output.cc: Likewise. * output.h: Likewise. * plugin.cc: Likewise. * plugin.h: Likewise. * powerpc.cc: Likewise. * reloc.cc: Likewise. * script-c.h: Likewise. * script-sections.cc: Likewise. * script.cc: Likewise. * stringpool.cc: Likewise. * symtab.cc: Likewise. * symtab.h: Likewise. * target.cc: Likewise. * timer.cc: Likewise. * timer.h: Likewise. * version.cc: Likewise. * x86_64.cc: Likewise.
* 2010-07-13 Rafael Espindola <espindola@google.com>Rafael Ávila de Espíndola2010-07-131-15/+20
| | | | | * fileread.cc (try_extra_search_path, find_file): Move to Input_file. * fileread.h (Input_file): Add try_extra_search_path and find_file.
* 2010-06-21 Rafael Espindola <espindola@google.com>Rafael Ávila de Espíndola2010-06-211-45/+86
| | | | | | | | | | | | | | | | | | * fileread.cc (Input_file::find_fie): New (Input_file::open): Use Input_file::find_fie. * fileread.h (Input_file::find_fie): New * plugin.cc (set_extra_library_path): New. (Plugin::load): Add set_extra_library_path to the transfer vector. (Plugin_manager::set_extra_library_path): New. (Plugin_manager::add_input_file): Use the extra search path if set. (set_extra_library_path(): New. * plugin.h (Plugin_manager): Add set_extra_library_path and extra_search_path_. 2010-06-21 Rafael Espindola <espindola@google.com> * plugin-api.h (ld_plugin_set_extra_library_path): New. (ld_plugin_tag): Add LDPT_SET_EXTRA_LIBRARY_PATH. (ld_plugin_tv): Add tv_set_extra_library_path.
* * fileread.cc: Only #include <sys/uio.h> if HAVE_READV.Ian Lance Taylor2010-06-151-1/+5
| | | | (struct iovec): Correct !HAVE_READV definition.
* * fileread.cc (find_or_make_view): Fix comment.Cary Coutant2010-03-241-1/+1
|
* * fileread.cc (File_read::~File_read): Don't delete whole_file_view_.Cary Coutant2010-03-101-29/+25
| | | | | | | | | | | | | | | | | | | | | | | (File_read::open[1]): Remove initial mapping of whole_file_view_. (File_read::open[2]): Add whole_file_view_ to list of views. (File_read::make_view): Remove test of whole_file_view_. (File_read::find_or_make_view): Create whole_file_view_ if necessary. (File_read::clear_views): Replace bool parameter with enum; adjust all callers. Don't delete views with permanent data; do delete cached views and views from archives if --no-keep-files-mapped is set. Set whole_file_view_ to NULL if clearing the corresponding view. * fileread.h (File_read::Clear_views_mode): New enum. (File_read::View::is_permanent_view): New method. (File_read::clear_views): Replace bool parameter with enum; adjust all callers. * options.h (General_options): Change keep_files_mapped option; add map_whole_files. * readsyms.cc (Add_symbols::run): Delete sd_ object before releasing the file. * reloc.cc (Scan_relocs::run): Delete rd_ object before releasing the file.
* 2010-02-24 Doug Kwan <dougkwan@google.com>Doug Kwan2010-02-241-1/+6
| | | | | | | | | | * arm.cc (Target_arm::do_finalize_sections): Skip processor specific flags and attributes merging if an input file is a binary file. * fileread.cc (Input_file::open): Record format of original file. * fileread.h (Input_file::Format): New enum type. (Input_file::Input_file): Initialize data member format_. (Input_file::format): New method definition. (Input_file::format_):: New data member.
* * gold-threads.h (class Once): Define.Ian Lance Taylor2010-02-121-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (class Initialize_lock): Rewrite as child of Once. * gold-threads.cc (class Once_initialize): Define. (once_pointer_control): New static variable. (once_pointer, once_arg): New static variables. (c_run_once): New static function. (Once::Once, Once::run_once, Once::internal_run): New functions. (class Initialize_lock_once): Remove. (initialize_lock_control): Remove. (initialize_lock_pointer): Remove. (initialize_lock_once): Remove. (Initialize_lock::Initialize_lock): Move to gold-threads.h. (Initialize_lock::initialize): Rewrite. (Initialize_lock::do_run_once): New function. * archive.cc (Archive::interpret_header): Only clear name if it is not already empty. * fileread.cc: Include "gold-threads.h" (file_counts_lock): New static variable. (file_counts_initialize_lock): Likewise. (File_read::release): Only increment counts when using --stats. Use a lock around the increment. * parameters.cc (class Set_parameters_target_once): Define. (set_parameters_target_once): New static variable. (Parameters::Parameters): Move here from parameters.h. (Parameters::set_target): Rewrite. (Parameters::set_target_once): New function. (Parameters::clear_target): Move here and rewrite. * parameters.h (class Parameters): Update declarations. Add set_parameters_target_once_ field. (Parameters::Parameters): Move to parameters.cc. (Parameters::clear_target): Likewise. * readsyms.cc (Read_symbols::do_group): Create a Start_group task. (Start_group::~Start_group): New function. (Start_group::is_runnable): New function. (Start_group::locks, Start_group::run): New functions. (Finish_group::run): Change saw_undefined to size_t. * readsyms.h (class Start_group): Define. (class Finish_group): Change saw_undefined_ field to size_t. (Finish_group::Finish_group): Remove saw_undefined and this_blocker parameters. Change all callers. (Finish_group::set_saw_undefined): New function. (Finish_group::set_blocker): New function. * symtab.h (class Symbol_table): Change saw_undefined to return size_t. Change saw_undefined_ field to size_t. * target-select.cc (Set_target_once::do_run_once): New function. (Target_selector::Target_selector): Initialize set_target_once_ field. Don't initialize lock_ and initialize_lock_ fields. (Target_selector::instantiate_target): Rewrite. (Target_selector::set_target): New function. * target-select.h (class Set_target_once): Define. (class Target_selector): Update declarations. Make Set_target_once a friend. Remove lock_ and initialize_lock_ fields. Add set_target_once_ field.
* Revert -Wshadow changes, all changes from:Ian Lance Taylor2009-12-141-23/+23
| | | | | | 2009-12-11 Doug Kwan <dougkwan@google.com> 2009-12-11 Nick Clifton <nickc@redhat.com> * configure.ac: Remove -Wshadow when setting WARN_CXXFLAGS.
* Add -Wshadow to the gcc command line options used when compiling the binutils.Nick Clifton2009-12-111-23/+23
| | | | Fix up all warnings generated by the addition of this switch.
* * configure.ac: Check for (struct stat)::st_mtimIan Lance Taylor2009-11-061-2/+4
| | | | | | * fileread.cc (File_read::get_mtime): Use st_mtim if available. * config.in: Regenerate. * configure: Regenerate.
* * fileread.cc: (File_read::View::~View): Use the newIan Lance Taylor2009-10-281-13/+46
| | | | | | | | | | | | | | | | | | | | | | | data_ownership_ filed. (File_read::~File_read): Dispose the new whole_file_view_. (File_read::open): Mmap the whole file if needed. (File_read::open): Use whole_file_view_ instead of contents_. (File_read::find_view): Use whole_file_view_ if applicable. (File_read::do_read): Use whole_file_view_ instead of contents_. (File_read::make_view): Use whole_file_view_ instead of contents_, update File_read::View::View call. (File_read::find_or_make_view): Update File_read::View::View call. * fileread.h: (File_read::File_read): Initialize whole_file_view_, remove contents_ (File_read::View::Data_ownership): New enum. (File_read::View::View): Replace bool mapped_ with Data_ownership argument. (File_read::View::mapped_): Remove (replaced by data_ownership_). (File_read::View::data_ownership_): New field. (File_read::contents_): Remove (replaced by whole_file_view_). (File_read::whole_file_view_): New field. * options.h (class General_options): Add --keep-files-mapped.
* 2009-10-10 Chris Demetriou <cgd@google.com>Chris Demetriou2009-10-101-19/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | * options.h (Input_file_argument::Input_file_type): New enum. (Input_file_argument::is_lib_): Replace with... (Input_file_argument::type_): New member. (Input_file_argument::Input_file_argument): Take Input_file_type 'type' rather than boolean 'is_lib' as second argument. (Input_file_argument::is_lib): Use type_. (Input_file_argument::is_searched_file): New function. (Input_file_argument::may_need_search): Handle is_searched_file. * options.cc (General_options::parse_library): Support -l:filename. (General_options::parse_just_symbols): Update for Input_file_argument changes. (Command_line::process): Likewise. * archive.cc (Archive::get_file_and_offset): Likewise. * plugin.cc (Plugin_manager::release_input_file): Likewise. * script.cc (read_script_file, script_add_file): Likewise. * fileread.cc (Input_file::Input_file): Likewise. (Input_file::will_search_for): Handle is_searched_file. (Input_file::open): Likewise. * readsyms.cc (Read_symbols::get_name): Likewise. * testsuite/Makefile.am (searched_file_test): New test. * testsuite/Makefile.in: Regenerate. * testsuite/searched_file_test.cc: New file. * testsuite/searched_file_test_lib.cc: New file.
* * configure.ac: Check for readv function also.Ian Lance Taylor2009-10-091-0/+9
| | | | | | | | * fileread.cc (readv): Define if not HAVE_READV. * fileread.h (File_read:: max_readv_entries): Set to 1 if readv does not exist. * config.in: Regenerate. * configure: Regenerate.
* * object.h (class Object): Remove target_ field, and target,Ian Lance Taylor2009-09-301-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sized_target, and set_target methods. (Object::sized_target): Remove. (class Sized_relobj): Update declarations. Remove sized_target. * object.cc (Sized_relobj::setup): Remove target parameter. Change all callers. (Input_objects::add_object): Don't do anything with the target. (make_elf_sized_object): Add punconfigured parameter. Change all callers. Set or test parameter target. * dynobj.cc (Sized_dynobj::target): Remove target parameter. Change all callers. * parameters.cc (Parameters::set_target): Change parameter type to be non-const. (Parameters::default_target): Remove. (set_parameters_target): Change parameter type to be non-const. (parameters_force_valid_target): New function. (parameters_clear_target): New function. * parameters.h (class Parameters): Update declarations. Remove default_target method. Add sized_target and clear_target methods. Change target_ to be non-const. (set_parameters_target): Update declaration. (parameters_force_valid_target): Declare. (parameters_clear_target): Declare. * readsyms.cc (Read_symbols::do_read_symbols): Pass punconfigured as NULL if we aren't searching. (Add_symbols::run): Don't check for compatible target. * fileread.cc (Input_file::open_binary): Call parameters_force_valid_target. * gold.cc (queue_middle_tasks): Likewise. * plugin.cc (make_sized_plugin_object): Likewise. Don't call set_target on object. * dynobj.h (class Sized_dynobj): Update declarations. * archive.cc (Archive::get_elf_object_for_member): Return NULL if make_elf_object returns NULL. (Archive::include_member): Don't check whether object target is compatible. * output.cc (Output_section::add_input_section): Get target from parameters. (Output_section::relax_input_section): Likewise. * reloc.cc (Sized_relobj::do_gc_process_relocs): Get target from parameters. (Sized_relobj::do_scan_relocs): Likewise. (Sized_relobj::relocate_sections): Likewise. * resolve.cc (Symbol_table::resolve): Likewise. * symtab.cc (Symbol_table::wrap_symbol): Likewise. Remove object parameter. Change all callers. (Symbol_table::add_from_object): Get target from parameters. (Symbol_table::add_from_relobj): Don't check object target. (Symbol_table::add_from_dynobj): Likewise. (Symbol_table::define_special_symbol): Get target from parameters. * symtab.h (class Symbol_table): Update declaration. * testsuite/binary_unittest.cc (gold_testsuite): Remove target parameter. Change all callers. Clear parameter target. (Binary_test): Test target here. * testsuite/object_unittest.cc (gold_testsuite): Remove target_test_pointer parameter. Change all callers. (Object_test): Test target here.
* * fileread.cc (File_read::get_mtime): New method.Ian Lance Taylor2009-07-061-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fileread.h (Timespec): New structure. (File_read::get_mtime): New method. * incremental.cc (Incremental_inputs_entry_data::timestamp_usec): Renamed from timestamp_nsec. (Incremental_inputs_entry_write::timestamp_sec): Fix argument to Elf_Xword. (Incremental_inputs_entry_write::timestamp_usec): Renamed from timestamp_nsec. (Incremental_inputs::report_archive): Save mtime; style fix. (Incremental_inputs::report_obejct): Save mtime; style fix. (Incremental_inputs::report_script): Save mtime; style fix. (Incremental_inputs::finalize_inputs): Style fix. (Incremental_inputs::finalize): Style fix. (Incremental_inputs::create_input_section_data): Store inputs mtime. * incremental.h (Incremental_inputs::report_script): Add mtime argument. (Incremental_inputs::Input_info::Input_info): Intialize only one union member. (Incremental_inputs::Input_info::archive): Move to nameless union. (Incremental_inputs::Input_info::obejct): Move to nameless union. (Incremental_inputs::Input_info::script): Move to nameless union. (Incremental_inputs::mtime): New field. * script.cc (read_input_script): Pass file mtime to Incremental_input. * script.h (Script_info::inputs): Style fix.
* 2009-06-23 Doug Kwan <dougkwan@google.com>Doug Kwan2009-06-231-0/+1
| | | | | | | | | | | | * Makefile.am (libgold_a_LIBADD): New. (ld_new_DEPENDENCIES, ld_new_LDADD): Remove LIBOBJS * Makefile.in: Regenerate. * config.in (HAVE_DECL_MEMMEM, HAVE_DECL_STRNDUP): New. * configure: Regenerate. * configure.ac (AC_CHECK_DECLS): Add strndup and memmem. * fileread.cc: Include sys/state.h * gold.h: Declare memmem and strndup if found missing. * gold_reloc.h: Include byteswap.h if HAVE_BYTESWAP_H is defined.
* * readsyms.cc (Read_symbols::incompatible_warning): New function.Ian Lance Taylor2009-03-141-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Read_symbols::requeue): New function. (Read_symbols::do_read_symbols): If make_elf_object fails because the target type is not configured, and the file was searched for, issue a warning and retry with the next directory. (Add_symbols::run): If the file has an incompatible format, and it was searched for, requeue the Read_symbols task. On error, release the object. * readsyms.h (class Read_symbols): Add dirindex_ field. Add dirindex parameter to constructor. Change all callers. Declare incompatible_warning and requeue. (class Add_symbols): Add dirpath_, dirindex_, mapfile_, input_argument_ and input_group_ fields. Add them to constructor. Change all callers. (class Read_script): Add dirindex_ field. Add it to constructor. Change all callers. * archive.cc (Archive::setup): Remove input_objects parameter. Change all callers. (Archive::get_file_and_offset): Likewise. (Archive::read_all_symbols): Likewise. (Archive::read_symbols): Likewise. (Archive::get_elf_object_for_member): Remove input_objects parameter. Add punconfigured parameter. Change all callers. (Archive::add_symbols): Change return type to bool. Check return value of include_member. (Archive::include_all_members): Likewise. (Archive::include_member): Change return type to bool. Return false if first included object has incompatible target. Set included_member_ field. (Add_archive_symbols::run): If add_symbols returns false, requeue Read_symbols task. * archive.h (class Archive): Add included_member_ field. Initialize it in constructor. Add input_file and searched_for methods. Update declarations. (class Add_archive_symbols): Add dirpath_, dirindex_, and input_argument_ fields. Add them to constructor. Change all callers. * script.cc: Include "target-select.h". (class Parser_closure): Add skip_on_incompatible_target_ and found_incompatible_target_ fields. Add skip_on_incompatible_target parameter to constructor. Change all callers. Add methods skip_on_incompatible_target, clear_skip_on_incompatible_target, found_incompatible_target, and set_found_incompatible_target. (read_input_script): Add dirindex parameter. Change all callers. If parser finds an incompatible target, requeue Read_symbols task. (script_set_symbol): Clear skip_on_incompatible_target in closure. (script_add_assertion, script_parse_option): Likewise. (script_start_sections, script_add_phdr): Likewise. (script_check_output_format): New function. * script.h (read_input_script): Update declaration. * script-c.h (script_check_output_format): Declare. * yyscript.y (file_cmd): Handle OUTPUT_FORMAT. (ignore_cmd): Remove OUTPUT_FORMAT. * fileread.cc (Input_file::Input_file): Add explicit this. (Input_file::will_search_for): New function. (Input_file::open): Add pindex parameter. Change all callers. * fileread.h (class Input_file): Add input_file_argument method. Declare will_search_for. Update declarations. * object.cc (make_elf_object): Add punconfigured parameter. Change all callers. * object.h (class Object): Make input_file public. Add searched_for method. (make_elf_object): Update declaration. * dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to restart search. * dirsearch.h (class Dirsearch): Update declaration. * options.h (class General_options): Add --warn-search-mismatch. * parameters.cc (Parameters::is_compatible_target): New function. * parameters.h (class Parameters): Declare is_compatible_target. * workqueue.cc (Workqueue::add_blocker): New function. * workqueue.h (class Workqueue): Declare add_blocker.
* * fileread.cc (Input_file::open): Remove options parameter.Ian Lance Taylor2009-03-131-6/+4
| | | | | | | | | | | Change all callers. (Input_file::open_binary): Likewise. * script.cc (read_input_script): Likewise. * readsyms.h (class Read_symbols): Remove options_ field. Remove options parameter from constructor. Change all callers. (class Read_script): Likewise. * fileread.h (class Input_file): Update declarations. * script.h (read_input_script): Update declaration.
* PR 6811Ian Lance Taylor2009-02-281-0/+10
| | | | | | | | | | | | | | | | | | | | | * options.h (class Search_directory): Add is_system_directory. (class General_options): Declare is_in_system_directory. * options.cc (get_relative_sysroot): Make static. (get_default_sysroot): Make static. (General_optoins::is_in_system_directory): New function. * fileread.cc (Input_file::is_in_system_directory): New function. * fileread.h (class Input_file): Declare is_in_system_directory. * object.h (class Object): Add is_in_system_directory. (class Input_objects): Remove system_library_directory_ field. * object.cc (Input_objects::add_object): Don't set system_library_directory_. (input_objects::found_in_system_library_directory): Remove. * symtab.cc (Symbol_table::write_globals): Remove input_objects parameter. Change all callers. (Symbol_table::sized_write_globals): Likewise. (Symbol_table::warn_about_undefined_dynobj_symbol): Likewise. Call Object::is_in_system_directory. * symtab.h (class Symbol_table): Update declarations.
* * archive.cc (Archive::get_elf_object_for_member): Remove callCary Coutant2009-01-151-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to File_read::claim_for_plugin. * descriptors.cc (Descriptors::open): Remove reference to is_claimed. (Descriptors::claim_for_plugin): Remove. * descriptors.h (Descriptors::claim_for_plugin): Remove. (Descriptors::is_claimed): Remove. (claim_descriptor_for_plugin): Remove. * fileread.cc (File_read::claim_for_plugin): Remove. * fileread.h (File_read::claim_for_plugin): Remove. (File_read::descriptor): Reopen descriptor if necessary. * plugin.cc (Plugin::load): Add two new APIs to transfer vector. (Plugin_manager::all_symbols_read): Add task parameter. Change all callers. (Plugin_manager::get_input_file): New function. (Plugin_manager::release_input_file): New function. (Pluginobj::Pluginobj): Add filesize parameter and initialize corresponding data member. (Sized_pluginobj::Sized_pluginobj): Add filesize parameter and pass to base constructor. Change all callers. (get_input_file, release_input_file): New functions. (make_sized_plugin_object): Add filesize parameter. Change all callers. * plugin.h (Plugin_manager::Plugin_manager): Initialize task_ member. (Plugin_manager::all_symbols_read): Add task parameter. (Plugin_manager::get_input_file): New function. (Plugin_manager::release_input_file): New function. (Plugin_manager::task_): New data member. (Pluginobj::Pluginobj): Add filesize parameter. (Pluginobj::filename): New function. (Pluginobj::descriptor): New function. (Pluginobj::filesize): New function. (Pluginobj::filesize_): New data member. (Sized_pluginobj::Sized_pluginobj): Add filesize parameter. * readsyms.cc (Read_symbols::do_read_symbols): Remove call to File_read::claim_for_plugin; use Object::unlock to unlock the file. * testsuite/Makefile.am (plugin_test_4): New test case for plugins with archive libraries. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c (struct sym_info): New type. (get_input_file, release_input_file): New static variables. (onload): Capture new transfer vector entries. (claim_file_hook): Stop reading at end of file according to filesize. Factor out parsing of readelf output into separate function. (all_symbols_read_hook): Exercise get_input_file and release_input_file APIs and get the source file name from the symbol table. Convert source file name to corresponding object file name. Print info message when adding new input files. (parse_readelf_line): New function. * testsuite/plugin_test_1.sh: Add checks for new info messages. * testsuite/plugin_test_2.sh: Likewise. * testsuite/plugin_test_3.sh: Likewise. * testsuite/plugin_test_4.sh: New test case.
* Add plugin functionality for link-time optimization (LTO).Cary Coutant2008-09-191-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | include/: * plugin-api.h: New file. gold/: * configure.ac (plugins): Add --enable-plugins option. * configure: Regenerate. * config.in: Regenerate. * Makefile.am (LIBDL): New variable. (CCFILES): Add plugin.cc. (HFILES): Add plugin.h. (ldadd_var): Add LIBDL. * Makefile.in: Regenerate. * archive.cc: Include "plugin.h". (Archive::setup): Don't preread archive symbols when using a plugin. (Archive::get_file_and_offset): Add memsize parameter. Change callers. (Archive::get_elf_object_for_member): Call plugin hooks for claiming files. (Archive::include_member): Add symbols from plugin objects. * archive.h (Archive::get_file_and_offset): Add memsize parameter. * descriptors.cc (Descriptors::open): Check for file descriptors abandoned by plugins. (Descriptors::claim_for_plugin): New function. * descriptors.h (Descriptors::claim_for_plugin): New function. (Open_descriptor::is_claimed): New field. (claim_descriptor_for_plugin): New function. * fileread.cc (File_read::claim_for_plugin): New function. * fileread.h (File_read::claim_for_plugin): New function. (File_read::descriptor): New function. * gold.cc: Include "plugin.h". (queue_initial_tasks): Add task to call plugin hooks for generating new object files. * main.cc: Include "plugin.h". (main): Load plugin libraries. * object.h (Pluginobj): Declare. (Object::pluginobj): New function. (Object::do_pluginobj): New function. (Object::set_target): New function. * options.cc: Include "plugin.h". (General_options::parse_plugin): New function. (General_options::General_options): Initialize plugins_ field. (General_options::add_plugin): New function. * options.h (Plugin_manager): Declare. (General_options): Add --plugin option. (General_options::has_plugins): New function. (General_options::plugins): New function. (General_options::add_plugin): New function. (General_options::plugins_): New field. * plugin.cc: New file. * plugin.h: New file. * readsyms.cc: Include "plugin.h". (Read_symbols::do_read_symbols): Check for archive before checking for ELF file. Call plugin hooks to claim files. * resolve.cc (Symbol_table::resolve): Record when symbol is referenced from a real object file; force override when processing replacement files. * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field. (Symbol::init_base_object): Likewise. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::init_base_undefined): Likewise. (Symbol::output_section): Assert that object is not a plugin. (Symbol_table::add_from_pluginobj): New function. (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as undefined. (Symbol_table::sized_write_globals): Likewise. (Symbol_table::add_from_pluginobj): Instantiate template. * symtab.h (Sized_pluginobj): Declare. (Symbol::in_real_elf): New function. (Symbol::set_in_real_elf): New function. (Symbol::in_real_elf_): New field. (Symbol_table::add_from_pluginobj): New function. * testsuite/Makefile.am (AM_CFLAGS): New variable. (LIBDL): New variable. (LDADD): Add LIBDL. (check_PROGRAMS): Add plugin_test_1 and plugin_test_2. (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh. (check_DATA): Add plugin_test_1.err and plugin_test_2.err. (MOSTLYCLEANFILES): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: New file. * testsuite/plugin_test_1.sh: New file. * testsuite/plugin_test_2.sh: New file.
* * fileread.cc (make_view): Add casts to avoid warning.Ian Lance Taylor2008-09-161-1/+3
|
* 2008-09-05 Cary Coutant <ccoutant@google.com>Cary Coutant2008-09-101-0/+8
| | | | | * fileread.cc (File_read::make_view): Add check for attempt to map beyond end of file.
* 2008-08-20 Craig Silverstein <csilvers@google.com>Craig Silverstein2008-08-211-2/+2
| | | | | * fileread.cc (File_read::open): Do not lock the file unless it was successfully opened.
* PR 5990Ian Lance Taylor2008-07-251-12/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * descriptors.cc: New file. * descriptors.h: New file. * gold-threads.h (class Hold_optional_lock): New class. * fileread.cc: Include "descriptors.h". (File_read::~File_read): Release descriptor rather than closing it. (File_read::open) [file]: Call open_descriptor rather than open. Set is_descriptor_opened_. (File_read::open) [memory]: Assert that descriptor is not open. (File_read::reopen_descriptor): New function. (File_read::release): Release descriptor. (File_read::do_read): Make non-const. Reopen descriptor. (File_read::read): Make non-const. (File_read::make_view): Reopen descriptor. (File_read::do_readv): Likewise. * fileread.h (class File_read): Add is_descriptor_opened_ field. Update declarations. * layout.cc: Include "descriptors.h". (Layout::create_build_id): Use open_descriptor rather than open. * output.cc: Include "descriptors.h". (Output_file::open): Use open_descriptor rather than open. * archive.cc (Archive::const_iterator): Change Archive to be non-const. (Archive::begin, Archive::end): Make non-const. (Archive::count_members): Likewise. * archive.h (class Archive): Update declarations. * object.h (Object::read): Make non-const. * Makefile.am (CCFILES): Add descriptors.cc. (HFILES): Add descriptors.h. * Makefile.in: Rebuild.