Commit Graph

742 Commits

Author SHA1 Message Date
Ian Lance Taylor 1caf2c519a PR 10419
* x86_64.cc (Target_x86_64::do_code_fill): Correct nop sequences.
2009-07-21 05:22:54 +00:00
Ian Lance Taylor 1ef4d87fe8 PR 10400
* layout.h: #include <map>.
	(class Kept_section): Change from struct to class.  Add accessors
	and setters.  Add section size to Comdat_group mapping.  Change
	Comdat_group to std::map.  Add is_comdat_ field.  Add
	linkonce_size field in union.
	(class Layout): Update declaration of find_or_add_kept_section.
	Don't declare find_kept_object.
	* layout.cc (Layout::find_or_add_kept_section): Remove candidate
	parameter.  Add object, shndx, is_comdat, and is_group_name
	parameters.  Change all callers.  Adjust for new Kept_section.
	(Layout::find_kept_object): Remove.
	* object.cc (Sized_relobj::include_section_group): Update use of
	Kept_section.  Rename secnum to shndx.  Only record
	Kept_comdat_section if sections are the same size.
	(Sized_relobj::include_linkonce_section): Update use of
	Kept_section.  Only record Kept_comdat_section if sections are the
	same size.  Set size of linkonce section.
	(Sized_relobj::map_to_kept_section): Update call to
	get_kept_comdat_section.
	* object.h (class Sized_relobj): Rename fields in
	Kept_comdat_section to drop trailing underscores; change object
	field to Relobj*.  Change Kept_comdat_section_table to store
	struct rather than pointer.
	(Sized_relobj::set_kept_comdat_section): Remove kept parameter.
	Add kept_object and kept_shndx parameters.  Change all callers.
	(Sized_relobj::get_kept_comdat_section): Change return type to
	bool.  Add kept_object and kept_shndx parameters.  Change all
	callers.
	* plugin.cc (Pluginobj::include_comdat_group): Update call to
	Layout::find_or_add_kept_section.
2009-07-17 01:07:33 +00:00
Ian Lance Taylor 37c3b7b014 * merge.cc (Object_merge_map::initialize_input_to_output_map):
Reserve space in the hash table.
2009-07-09 23:29:55 +00:00
Ian Lance Taylor 98fa85cb42 * fileread.cc (File_read::get_mtime): New method.
* 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-07-06 23:11:21 +00:00
Ian Lance Taylor c9d707578e * freebsd.h (Target_freebsd::do_adjust_elf_header): Use size
instead of 32.
2009-07-01 16:21:36 +00:00
Ian Lance Taylor 9c547ec3ac PR 10156
* layout.cc (Layout::choose_output_section): If we find an
	existing section, update the flags.
	(Layout::create_notes): New function, broken out of
	Layout::finalize.
	(Layout::finalize): Don't create note sections.
	(Layout::create_note): Don't crash if linker script discards
	section.
	(Layout::create_gold_note): Likewise.
	(Layout::create_build_id): Likewise.  Don't set
	after_input_sections on the section.
	(Layout::create_executable_stack_info): Remove target parameter.
	Change caller.
	* layout.h (class Layout): Declare create_notes.  Update
	declaration of create_executable_stack_info.
	* gold.cc (queue_middle_tasks): Call create_notes.
	* output.cc (Output_section::update_flags_for_input_section): Move
	here from output.h.  If SHF_ALLOC flag is newly set, mark address
	invalid.
	* output.h (Output_data::mark_address_invalid): New function.
	(class Output_section): Only declare, not define,
	update_flags_for_input_section.  Remove set_flags.
2009-06-24 19:48:51 +00:00
Ian Lance Taylor 554585003d * script-sections.cc (Output_section_definition::
set_section_addresses): Rename shadowing local load_address to
	laddr.
2009-06-24 19:00:15 +00:00
Ian Lance Taylor 1307d6cd4a PR 10244
* reloc.cc (relocate_sections): Skip empty relocation sections.
2009-06-24 14:36:14 +00:00
Ian Lance Taylor ec3f783efd PR 10156
* layout.cc (Layout::create_note): Use choose_output_section
	rather than make_output_section.
2009-06-24 05:09:11 +00:00
Ian Lance Taylor 459c9f1c5f PR 10237
* options.cc (General_options::parse_V): Set printed_version_.
	(General_options::General_options): Initialize printed_version_.
	* options.h (class General_options): Add printed_version_ field.
	* gold.cc (queue_initial_tasks): If there are no input files,
	don't give a fatal error if we printed the version information.
	(queue_middle_tasks): If using -r with a shared object, give a
	fatal error rather than an ordinary error.
2009-06-24 05:01:17 +00:00
Ian Lance Taylor 1518dc8f89 PR 10219
* layout.cc (Layout::Layout): Initialize have_stabstr_section_.
	(Layout::make_output_section): Set have_stabstr_section_ if we see
	a .stab*str section.
	(Layout::finalize): Call link_stabs_sections.
	(Layout::link_stabs_sections): New file.
	* layout.h (class Layout): Add have_stabstr_section_ field.
	Declare link_stabs_sections.
2009-06-24 00:38:00 +00:00
Doug Kwan 3d857b98f5 2009-06-23 Doug Kwan <dougkwan@google.com>
* 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.
2009-06-23 18:10:42 +00:00
Ian Lance Taylor 0639a6f662 * configure.ac: Call AC_CHECK_DECLS using C, not C++.
* configure: Rebuild.
2009-06-23 14:37:24 +00:00
Ian Lance Taylor 8d63875c54 PR 10147
* object.cc (Object::section_contents): Don't try to get a view if
	the section has length zero.
	(Object::handle_gnu_warning_section): If the section is empty, use
	the name of the section as the warning.
2009-06-23 07:19:35 +00:00
Ian Lance Taylor f7c8a183e8 PR 10133
* stringpool.h (class Stringpool_template): Add optimize_ field.
	(Stringpool_template::set_optimize): New function.
	* stringpool.cc (Stringpool_template::Stringpool_template):
	Initialize optimize_ field.
	(Stringpool_template::set_string_offsets): Test local optimize
	fild rather than parameter.
	* layout.cc (Layout::Layout): Call set_optimize on the section
	name stringpool.
2009-06-23 07:04:10 +00:00
Ian Lance Taylor e6a307bae3 PR 10030
* yyscript.y: Parse TARGET.
	* script.cc (script_set_target): New function.
	* script-c.h (script_set_target): Declare.
	* options.cc (General_options::string_to_object_format): Rename
	from string_to_object_format in anonymous namespace.  Change
	callers.
	* options.h (class General_options): Declare
	string_to_object_format.
2009-06-23 06:39:47 +00:00
Ian Lance Taylor 3ee173de46 * script-sections.cc (Script_sections::create_segments): Don't put
program headers in a PT_LOAD segment if -n or -N.
2009-06-23 06:07:50 +00:00
Ian Lance Taylor e1c74d6051 PR 10141
* options.h (class General_options): Add -z lazy and -z now.  Sort
	-z options into alphabetical order.
	* layout.cc (Layout::finish_dynamic_section): Handle -z now.
2009-06-22 20:23:21 +00:00
Ian Lance Taylor cd6739a176 Fix ChangeLog e-mail address. 2009-06-22 06:52:11 +00:00
Ian Lance Taylor 8a5e3e08a6 * layout.cc (Layout::make_output_section): Call
Target::new_output_section.
	(Layout::attach_allocated_section_to_segment): Put large section
	sections in a separate load segment with the large segment flag
	set.
	(Layout::segment_precedes): Sort large data segments after other
	load segments.
	(align_file_offset): New static function.
	(Layout::set_segment_offsets): Use align_file_offset.
	* output.h (class Output_section): Add is_small_section_ and
	is_large_section_ fields.
	(Output_section::is_small_section): New function.
	(Output_section::set_is_small_section):  New function.
	(Output_section::is_large_section): New function.
	(Output_section::set_is_large_section): New function.
	(Output_section::is_large_data_section): New function.
	(class Output_segment): Add is_large_data_segment_ field.
	(Output_segment::is_large_data_segment): New function.
	(Output_segment::set_is_large_data_segment): New function.
	* output.cc (Output_section::Output_section): Initialize new
	fields.
	(Output_segment::Output_segment): Likewise.
	(Output_segment::add_output_section): Add assertion that large
	data sections always go in large data segments.  Force small data
	sections to the end of the list of data sections.  Force small BSS
	sections to the start of the list of BSS sections.  For large BSS
	sections to the end of the list of BSS sections.
	* symtab.h (class Symbol): Declare is_common_shndx.
	(Symbol::is_defined): Check Symbol::is_common_shndx.
	(Symbol::is_common): Likewise.
	(class Symbol_table): Define enum Commons_section_type.  Update
	declarations.  Add small_commons_ and large_commons_ fields.
	* symtab.cc (Symbol::is_common_shndx): New function.
	(Symbol_table::Symbol_table): Initialize new fields.
	(Symbol_table::add_from_object): Put small and large common
	symbols in the right list.
	(Symbol_table::sized_finalized_symbol): Check
	Symbol::is_common_shndx.
	(Symbol_table::sized_write_globals): Likewise.
	* common.cc (Symbol_table::do_allocate_commons): Allocate new
	common symbol lists.  Don't call do_allocate_commons_list if the
	list is empty.
	(Symbol_table::do_allocate_commons_list): Remove is_tls
	parameter.  Add comons_section_type parameter.  Change all
	callers.  Handle small and large common symbols.
	* object.cc (Sized_relobj::do_finalize_local_symbols): Check
	Symbol::is_common_shndx.
	* resolve.cc (symbol_to_bits): Likewise.
	* target.h (Target::small_common_shndx): New function.
	(Target::small_common_section_flags): New function.
	(Target::large_common_shndx): New function.
	(Target::large_common_section_flags): New function.
	(Target::new_output_section): New function.
	(Target::Target_info): Add small_common_shndx, large_common_shndx,
	small_common_section_flags, and large_common_section_flags
	fields.
	(Target::do_new_output_section): New virtual function.
	* arm.cc (Target_arm::arm_info): Initialize new fields.
	* i386.cc (Target_i386::i386_info): Likewise.
	* powerpc.cc (Target_powerpc::powerpc_info) [all versions]:
	Likewise.
	* sparc.c (Target_sparc::sparc_info) [all versions]: Likewise.
	* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
	(Target_x86_64::do_new_output_section): New function.
	* configure.ac: Define conditional MCMODEL_MEDIUM.
	* testsuite/Makefile.am (check_PROGRAMS): Add large.
	(large_SOURCES, large_CFLAGS, large_DEPENDENCIES): Define.
	(large_LDFLAGS): Define.
	* testsuite/large.c: New file.
	* testsuite/testfile.cc (Target_test::test_target_info):
	Initialize new fields.
	* configure, testsuite/Makefile.in: Rebuild.
2009-06-22 06:51:53 +00:00
Doug Kwan bb04269c74 2009-06-05 Doug Kwan <dougkwan@google.com>
* Makefile.am (CCFILES): Add target.cc.
	* Makefile.in: Regenerate.
	* i386.cc (class Target_i386): Define new virtual method to
	override do_is_local_label_name in parent.
	* object.cc (Sized_relobj::do_count_local_symbols): Discard
	local symbols if --discard-locals or -X is given.
	* options.h (class General_options): Declare new options
	'--discard-locals' and '-X' for discarding locals.
	* target.h (class Target): Define new methods is_local_label_name.
	Declare new virtual method do_is_local_label_name.
	* target.cc: New file.
	* testsuite/Makefile.am (check_PROGRAMS): Add discard_locals_test.
	(check_SCRIPTS): Add discard_locals_test.sh.
	(check_DATA): Add discard_local_tests.syms.
	(discard_locals_test_SOURCES, discard_locals_test_LDFLAGS): Define.
	(discard_local_tests.syms, discard_locals_test.o): New make rules.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/discard_locals_test.c: New file.
	* testsuite/discard_locals_test.sh: Same.
2009-06-05 21:32:57 +00:00
Doug Kwan 805bb01c4b 2009-06-05 Doug Kwan <dougkwan@google.com>
* object.cc (Sized_relobj::Sized_relobj): Initialize
	discarded_eh_frame_shndx_ to -1U.
	(Sized_relobj::do_layout): Record index of a discard .eh_frame
	section.
	(Sized_relobj::do_count_local_symbols): Skip local symbols in
	a discarded .eh_frame section.
	(Sized_relobj::do_finalize_local_symbols): Ditto.
	* object.h (class Sized_relobj): Declare new member
	discarded_eh_frame_shndx_.
	* testsuite/Makefile.am (check_PROGRAMS): Add local_labels_test.
	(local_labels_test.o, local_labels_test): New rules.
	* testsuite/Makefile.in: Regenerate.
2009-06-05 18:16:31 +00:00
Doug Kwan 1dcd334d34 2009-06-04 Doug Kwan <dougkwan@google.com>
* layout.cc (Layout::section_name_mapping): Add mapping for
	special ARM sections.
2009-06-04 21:14:11 +00:00
Doug Kwan 96d493066d 2009-06-03 Doug Kwan <dougkwan@google.com>
* arm.cc (utils::sign_extend): Reverse test in gold_assert.
	(utils::has_overflow): Same.
2009-06-04 01:31:01 +00:00
Ian Lance Taylor dff1629750 * layout.cc (Layout::section_name_mapping): New array, replacing
Layout::linkonce_mapping.
	(Layout::section_name_mapping_count): New variable, replacing
	Layout::linkonce_mapping_count.
	(Layout::linkonce_output_name): Remove.
	(Layout::output_section_name): Rewrite.
	* layout.h (class Layout): Rename Linkonce_mapping to
	Section_name_mapping, linkonce_mapping to section_name_mapping,
	linkonce_mapping_count to section_name_mapping_count.  Don't
	declare linkonce_output_name.
2009-06-04 00:43:11 +00:00
Doug Kwan c121c67179 2009-06-03 Doug Kwan <dougkwan@google.com>
* gold/arm.cc (namespace utils): New.
	(Target_arm::reloc_is_non_pic): Define new method.
	(class Arm_relocate_functions): New.
	(Target_arm::Relocate::relocate): Handle relocation types used by
	Android.
2009-06-03 19:33:05 +00:00
Ian Lance Taylor 07800fab6e * arm.cc (Target_arm::scan::global): Use || instead of |. 2009-06-03 14:05:07 +00:00
Doug Kwan bec53400ce 2009-06-02 Doug Kwan <dougkwan@google.com>
* gold/arm.cc (Target_arm::Scan::Scan):  Initialize
	issued_non_pic_error_.
	(class Target_arm::Scan): Declare new method check_non_pic.
	Define new method symbol_needs_plt_entry.
	Declare new data member issued_non_pic_error_.
	(class Target_arm::Relocate): Declare new method
	should_apply_static_reloc.
	(Target_arm::may_need_copy_reloc): Handle STT_ARM_TFUNC.
	(Target_arm::Scan::check_non_pic): Define new method.
	(Target_arm::Scan::local): Handle a small subset of reloc types used
	by Android.
	(Target_arm::Scan::local): Same.
	(Target_arm::Relocate::should_apply_statci_reloc): Define new method.
2009-06-03 00:06:15 +00:00
Ian Lance Taylor b19b0c6d0f * incremental.cc (Incremental_inputs::report_command_line): Filter
out --incremental-* options.
2009-05-31 23:07:26 +00:00
Doug Kwan 94cdfcffc3 2009-05-29 Doug Kwan <dougkwan@google.com>
* gold/arm.cc (Output_data_plt_arm): Forward declaration for new
	template class.
	(class Target_arm): Update comment.
	(Target_arm::Target_arm): Initialize new data members GOT_,
	PLT_, GOT_PLT_, REL_DYN_, COPY_RELOCS_ and DYNBSS_.
	Declare new methods Target_arm::got_section, Target_arm::make_plt_entry
	and Target_arm::rel_dyn_section.
	Declare new_enum Target_arm::Got_type.
	Declare new data members GOT_, PLT_, GOT_PLT_, REL_DYN_, COPY_RELOCS_
	and DYNBSS_.
	Update commments for member do_dynsym_value.
	(Target_arm::got_size, Target_arm::plt_section,
	Target_arm::may_need_copy_reloc and Target_arm::copy_reloc): Define
	new methods inside class defintion.
	(Target_arm::got_section): Define new method.
	(Target_arm::rel_dyn_section): Same.
	(Output_data_plt_arm): New template class.
	(Output_data_plt_arm::Output_data_plt_arm): Define constructor.
	(Output_data_plt_arm:do_adjust_output_section): Define new method.
	(Output_data_plt_arm::add_entry): Same.
	(Output_data_plt_arm::first_plt_entry): Define new
	static data member for PLT instruction template.
	(Output_data_plt_arm::plt_entry): Same.
	(Output_data_plt_arm::do_write): Define new method.
	(Target_arm::make_plt_entry): Same.
	(Target_arm::do_finalize_sections): Same.
	(Target_arm::do_dynsym_value): Same.
2009-05-30 00:55:42 +00:00
Doug Kwan 4a657b0d92 2009-05-28 Doug Kwan <dougkwan@google.com>
* configure.ac: Support gold for target arm*-*-*.
        * configure: Regenerate.
        * gold/Makefile.am (TARGETSOURCES): Add arm.cc.
        (ALL_TARGETOBJECTS): Add arm.$(OBJEXT)
        * gold/Makefile.in: Regenerate.
        * gold/arm.cc: New file.
        * gold/configure.tgt: Add armbe*-*-*, armeb*-*-* and arm*-*-* targets.
2009-05-29 00:15:12 +00:00
Doug Kwan e7ae8c368d Add missing ChangeLog entry in previous check-in 2009-05-26 23:05:00 +00:00
Doug Kwan 2fdd743f6d 2009-05-26 Doug Kwan <dougkwan@google.com>
* options.cc (General_options::parse_exclude_libs).  Fix a comment.
        (General_options::check_excluded_libs): Strip off directories in
        archive name before matching like GNU ld does.
        * testsuite/Makefile.am (MOSTLYCLEANFILES,
        exclude_libs_test_DEPENDENCIES): Add alt/libexclude_libs_test_3.a
        (exclude_libs_test_LDFLAGS): Add linker option
        -Wl,--exclude-libs,libexclude_libs_test_3
        (exclude_libs_test_LADD): Add alt/libexclude_libs_test_3.a as
        an explicit archive without using -l.
        (alt/libexclude_libs_test_3.a): New make rule.
        * testsuite/Makefile.in: Regenerate.
        * testsuite/exclude_libs_test.c : Declare lib3_default().
        (main): Call it.
        * exclude_libs_test.sh: Add tests for alt/exclude_libs_test_3.a.
        * exclude_libs_test_3.c: New file.
2009-05-26 22:52:56 +00:00
Nick Clifton f12e7348b2 Update Indonesian translations.
Update translation templates.
2009-05-26 16:49:41 +00:00
Sriraman Tallam 4daadc0d02 * testsuite/Makefile.am: Add -ffunction-sections to compile
gc_comdat_test files.  Add -Wl,--gc-sections to build
	gc_comdat_test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/gc_comdat_test.sh: Fix the condition around grep.
2009-05-22 20:27:52 +00:00
Sriraman Tallam 531813adfc * object.cc (Sized_relobj::map_to_kept_section): Return NULL if the
kept comdat section was garbage collected.
	* testsuite/Makefile.am: Add test gc_comdat_test.sh.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/gc_comdat_test.sh: New file.
	* testsuite/gc_comdat_test_1.cc: New file.
	* testsuite/gc_comdat_test_2.cc: New file.
2009-05-22 18:31:22 +00:00
Cary Coutant 6551490093 2009-05-19 Doug Kwan <dougkwan@google.com>
* archive.cc (Archive::Archive): Move constructor from archive.h
	to here.  Initialize no_export_.
	(Archive::get_elf_object_for_member): Set no_export flag of object.
	* archive.h (Archive::Archive): Move constructor body to
	archive.cc.
	(Archive::no_export): New method.
	(Archive::no_export_): New field.
	* object.h (Object::Object): Initialize no_export_ to false.
	(Object::no_export, Object::set_no_export): New methods.
	(Object::no_export_): New field.
	* options.cc (General_options::parse_exclude_libs): New method.
	(General_options::check_excluded_libs) Same.
	* options.h (exclude_libs): New option.
	(General_options::check_excluded_libs): New method declaration.
	(General_options::excluded_libs_): New field.
	* symtab.cc (Symbol_table::add_from_relobj): Hide symbols with
	default or protected visibility if an object has no-export flag set.
	testsuite/Makefile.am (check_PROGRAMS): Add exclude_libs_test.
	(check_SCRIPTS): Add exclude_libs_test.sh.
	(check_DATA): Add exclude_libs_test.syms.
	(MOSTLYCLEANFILES): Add exclude_libs_test.syms,
	libexclude_libs_test_1.a and libexclude_libs_test_2.a.
	(exclude_libs_test_SOURCES, exclude_libs_test_DEPENDENCIES,
	exclude_libs_test_LDFLAGS and exclude_libs_test_LDADD): Define.
	(exclude_libs_test.syms, libexclude_libs_test_1.a,
	libexclude_libs_test_2.a): New rules.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/exclude_libs_test.c: New file.
	* testsuite/exclude_libs_test.sh: Ditto.
	* testsuite/exclude_libs_test_1.c: Ditto.
	* testsuite/exclude_libs_test_2.c: Ditto.
2009-05-19 22:14:17 +00:00
Ian Lance Taylor 1b77ea505f * configure.ac: Check for declarations for cases where libiberty.h
checks HAVE_DECL_xxx.
	* configure, config.in: Rebuild.
2009-05-15 18:32:13 +00:00
Ian Lance Taylor 072fe7ce7a * gold.h (Incremental_argument_list): Remove (invalid) forward
declaration.
	* incremental.cc (Incremental_inputs::report_achive): New method.
	(Incremental_inputs::report_object): New method.
	(Incremental_inputs::report_script): New method.
	(Incremental_inputs::finalize_inputs): New method.
	(Incremental_inputs::finalize): Call finalize_inputs().
	(Incremental_inputs::sized_create_incremental_inputs_section_data):
	Create inputs entries.
	* incremental.h (Incremental_input_type): New enum.
	(Incremental_inputs::Incremental_input): Initialize new fields.
	(Incremental_inputs::report_inputs): New method.
	(Incremental_inputs::report_achive): New method.
	(Incremental_inputs::report_object): New method.
	(Incremental_inputs::report_script): New method.
	(Incremental_inputs::finalize_inputs): New method.
	(Incremental_inputs::Input_info): New struct.
	(Incremental_inputs::Input_info_map): New typedef.
	(Incremental_inputs::lock_): New field.
	(Incremental_inputs::Inputs_): New field.
	(Incremental_inputs::Inputs_map): New field.
	* main.cc (main): Call Incremental_input::report_inputs.
	* options.h (Input_argument_list): Typedef moved from
	Input_arguments.
	(Input_file_group::Files): Remove, use ::Input_argument_list.
	(Input_file_group::Input_argument_list): Remove, use
	::Input_argument_list.
	* plugin.cc (Plugin_manager::add_input_file): Add error in
	incremental build.
	* read_syms.cc (do_read_syms): Call Incremental_input::report_*
	functions.
	* script.cc (read_input_script): Call
	Incremental_input::report_script.
	* script.h (Script_info): New class.
2009-05-15 17:01:04 +00:00
Chris Demetriou b22a5a4185 Fix date in revision 1.220. (Was 2008-04-23, should have been 2009-04-23). 2009-04-30 06:02:09 +00:00
Ian Lance Taylor b0481b0b2c * x86_64.cc (do_adjust_output_section): Set entsize to
plt_entry_size.
2009-04-27 16:23:57 +00:00
Chris Demetriou 6d1e3092b4 2008-04-23 Elliott Hughes <enh@google.com>
* output.cc (Output_file::close): After short writes, continue
        writing from the correct offset in the buffer being written.
2009-04-24 19:48:21 +00:00
Chris Demetriou 40fde48809 2009-04-23 Chris Demetriou <cgd@google.com>
* configure.ac (HAVE_TR1_UNORDERED_MAP_REHASH): New define.
        * configure: Regenerate.
        * config.in: Regenerate.
        * gold.h: Avoid std::tr1::unordered_map and std::tr1::unordered_set
        if HAVE_TR1_UNORDERED_MAP_REHASH is not defined.
2009-04-24 19:33:42 +00:00
Ian Lance Taylor 3ce2c28e3f * incremental.cc (Incremental_inputs_header_data): Renamed from
Incremental_input_header_data.
	(Incremental_inputs_header_data::data_size): New field.
	(Incremental_inputs_header_data::put_input_file_count): Renamed
	from input_file_count.
	(Incremental_inputs_header_data::put_command_line_offset): Renamed
	from command_line_offset.
	(Incremental_inputs_header_data::put_reserved): Renamed from
	put_reserved.
	(Incremental_inputs_entry_data): Renamed from
	Incremental_input_entry_data.
	(Incremental_inputs_entry_data::data_size): New field.
	(Incremental_inputs::report_command_line): New method.
	(Incremental_inputs::finalize): New method.
	(Incremental_inputs::create_incremental_inputs_data): New method.
	(Incremental_inputs::sized_create_incremental_inputs_data): New method.
	* incremental.h: New file.
	* layout.cc (Layout::Layout): Handle new incremental_inputs_.
       (Layout::finalize): Create incremental inputs section in
	incremental builds.
       (Layout::create_incremental_info_sections): New method.
	* layout.h (Layout::incremental_inputs): New method.
       (Layout::create_incremental_info_sections): New method.
       (Layout::incremental_inputs_): New field.
	* main.cc (main): Notify Incremental_input of the command line.
2009-04-24 15:44:02 +00:00
Ian Lance Taylor e55bde5eb0 * gold.h (reserve_unordered_map): Define, three versions, one for
each version of Unordered_map.
	* layout.cc (Layout::Layout): Remove options parameter.  Add
	number_of_input_files parameter.  Don't initialize options_.
	Initialize number_of_input_files_ and resized_signatures_.  Move
	sections_are_attached_.
	(Layout::layout_group): Reserve space for group_signatures_.
	(Layout::find_or_add_kept_section): Change name parameter to be a
	reference.  Resize signatures_ map when it gets large enough.
	(Layout::layout_eh_frame): Use parameters->options() instead of
	this->options_.
	(Layout::make_output_section): Likewise.
	(Layout::attach_allocated_section_to_segment): Likewise.
	(Layout::finalize, Layout::create_executable_stack): Likewise.
	(Layout::set_segment_offsets, Layout::create_interp): Likewise.
	(Layout::finish_dynamic_section, Layout::write_binary): Likewise.
	* layout.h (class Layout): Update declarations.  Remove options_
	field.  Add number_of_input_files_ and resized_signatures_
	fields.  Move sections_are_attached_ field.
	* main.cc (main): Pass number of input files to Layout
	constructor.  Don't pass options.
2009-04-02 04:19:03 +00:00
Ian Lance Taylor 154b857c95 * ffsll.c (ffsll): Correct implementation. 2009-03-30 23:17:11 +00:00
Ian Lance Taylor fd03461a93 * ffsll.c: New file.
* configure.ac: Call AC_REPLACE_FUNCS on ffsll.
	* gold.h (ffsll): Declare if HAVE_FFSLL is not defined.
	* ftruncate.c (ftruncate): Declare before definition.
	* mremap.c (mremap): Likewise.
	* pread.c (pread): Likewise.
	* configure, Makefile.in, config.in: Rebuild.
2009-03-28 05:22:30 +00:00
Ian Lance Taylor 2f35ab9b82 * mremap.c: New file.
* configure.ac: Call AC_REPLACE_FUNCS on mremap.
	* gold.h (MREMAP_MAYMOVE): Define if HAVE_MREMAP is not defined.
	(mremap): Declare if HAVE_MREMAP is not defined.
	* configure, Makefile.in, config.in: Rebuild.
2009-03-27 23:21:09 +00:00
Cary Coutant 33aea2fd65 * powerpc.cc (Target_powerpc::check_non_pic): Assert that output is
position independent.
	* sparc.cc (Target_sparc::check_non_pic): Likewise.
	* x86_64.cc (Target_x86_64::check_non_pic): Likewise.
2009-03-27 18:19:09 +00:00
Cary Coutant 6d4796192d * symtab.h (needs_plt_entry): Check for unsatisfied reference from
an executable.
	(needs_dynamic_reloc): Likewise.
2009-03-25 01:34:25 +00:00
Ian Lance Taylor afc06bb828 * yyscript.y (file_cmd): Recognize EXTERN.
(extern_name_list, extern_name_list_body): New nonterminals.
	* script.cc (script_add_extern): Define.
	* script-c.h (script_add_extern): Declare.
2009-03-24 19:08:37 +00:00
Ian Lance Taylor f6060a4d43 * object.cc (is_elf_object): Define.
* object.h (is_elf_object): Declare.
	* archive.cc (Archive::get_elf_object_for_member): Call
	is_elf_object.
	* readsymc.cc (Read_symbols::do_read_symbols): Likewise.
2009-03-24 18:42:10 +00:00
Ian Lance Taylor 26736d8ec1 * output.cc (Output_file::map_anonymous): Define.
(Output_file::map): Use map_anonymous.  If the regular mmap fails,
	try an anonymous one.  Report the size if the mmap fails.
	* output.h (class Output_file): Declare map_anonymous.
2009-03-24 18:04:26 +00:00
Ian Lance Taylor 22fd9730a0 * target-select.cc (instantiate_target): Don't acquire the lock if
the instantiated_target_ field has already been set.
2009-03-24 17:32:43 +00:00
Ian Lance Taylor 7f055c204a 2009-03-23 Ian Lance Taylor <iant@google.com>
* gold-threads.h (class Initialize_lock): Define.
	* gold-threads.cc (class Initialize_lock_once): Define.
	(initialize_lock_control): New static variable.
	(initialize_lock_pointer): New static variable.
	(initialize_lock_once): New static function.
	(Initialize_lock::Initialize_lock): Define.
	(Initialize_lock::initialize): Define.
	* target-select.h: Include "gold-threads.h".
	(class Target_selector): Add lock_ and initialize_lock_ fields.
	Don't define instantiate_target, just declare it.
	* target-select.cc (Target_selector::Target_selector): Initialize
	new fields.
	(Target_selector::instantiate_target): Define.
	* descriptors.h: Include "gold-threads.h".
	(class Descriptors): Add initialize_lock_ field.
	* descriptors.cc (Descriptors::Descriptors): Initialize new
	field.
	(Descriptors::open): Use initialize_lock_ field
	* errors.h (class Errors): Add initialize_lock_ field.
	* errors.cc (Errors::Errors): Initialize new field.
	(Errors::initialize_lock): Use initialize_lock_ field.
	* powerpc.cc (class Target_selector_powerpc): Remove
	instantiated_target_ field.  In do_recognize call
	instantiate_target rather than do_instantiate_target.  In
	do_instantiate_target just allocate a new target.
	* sparc.cc (class Target_selector_sparc): Likewise.
2009-03-24 04:50:32 +00:00
Ian Lance Taylor 3695968186 2009-03-23 Ian Lance Taylor <iant@google.com>
* freebsd.h: New file.
	* i386.cc: Include "freebsd.h".
	(Target_i386): Derive from Target_freebsd rather than
	Sized_target.
	(Target_selector_i386): Derive from Target_selector_freebsd rather
	than Target_selector.
	* x86_64.cc: Include "freebsd.h".
	(Target_x86_64): Derive from Target_freebsd rather than
	Sized_target.
	(Target_selector_x86_64): Derive from Target_selector_freebsd
	rather than Target_selector.
	* target.h (class Target): Add adjust_elf_header and
	do_adjust_elf_header.
	* output.cc (Output_file_header:: do_sized_write): Call target
	adjust_elf_header routine.
	* configure.tgt: Set targ_osabi.
	* configure.ac: Define GOLD_DEFAULT_OSABI.
	* parameters.cc (Parameters::default_target): Pass
	GOLD_DEFAULT_OSABI to select_target.
	* target-select.h (class Target_selector): Make instantiate_target
	protected rather than private.
	* Makefile.am (HFILES): Add freebsd.h.
	* configure, Makefile.in, config.in: Rebuild.
2009-03-24 00:31:29 +00:00
Ian Lance Taylor cb010894ee * merge.cc (do_add_input_section): Correct pend value. Change
message about last entry not being null terminated from error to
	warning.
2009-03-23 21:15:08 +00:00
Ian Lance Taylor 0e87992779 include/elf:
* common.h (SHT_GNU_INCREMENTAL_INPUTS): Define.
elfcpp:
	* elfcpp.h (SHT_GNU_INCREMENTAL_INPUTS): Define.
gold:
	* incremental.cc: New file.
	* Makefile.am (CCFILES): Add incremental.cc.
	* Makefile.in: Rebuild.
2009-03-20 23:37:51 +00:00
Paul Pluzhnikov 4110593748 2009-03-19 Paul Pluzhnikov <ppluzhnikov@google.com>
* layout.cc (Layout::output_section_name): Preserve names
	of '.note.' sections.
2009-03-19 19:39:32 +00:00
Ian Lance Taylor 604399204f * descriptors.cc (Descriptors::open): Check that the options are
valid before using them.
2009-03-19 19:02:53 +00:00
Ian Lance Taylor 0d371ad356 * script-sections.h: Include <list>.
(class Script_sections): Change Sections_elements from std::vector
	to std::list.  Typedef public Elements_iterator.  Add
	orphan_section_placement_, data_segment_align_start_, and
	saw_data_segment_align_ fields.  Remove data_segment_align_index_
	field.
	* script-sections.cc (class Orphan_section_placement): New class.
	(class Sections_element): Add virtual functions is_relro and
	orphan_section_init.  Remove virtual function place_orphan_here.
	(class Output_section_definition): Add is_relro and
	orphan_section_init.  Remove place_orphan_here.
	(class Orphan_output_section): Likewise.
	(Script_sections::Script_sections): Update for field changes.
	(Script_sections::data_segment_align): Set saw_data_segment_align_
	and data_segment_align_start_, not data_segment_align_index.
	(Script_sections::data_segment_relro_end): Check
	saw_data_segment_align_.  Use data_segment_align_start_ rather
	than data_segment_align_index_.
	(Script_sections::place_orphan): Rewrite to use
	Orphan_section_placement.
2009-03-19 05:51:49 +00:00
Ian Lance Taylor 9c5b8369ab * archive.cc (Archive::add_symbols): Check for a version attached
to the symbol name in the archive map.
	* testsuite/Makefile.am (check_PROGRAMS): Add ver_test_11.
	(ver_test_11_SOURCES, ver_test_11_DEPENDENCIES): Define.
	(ver_test_11_LDFLAGS, ver_test_11_LDADD): Define.
	(ver_test_11.a): New target.
	* testsuite/Makefile.in: Rebuild.
2009-03-18 05:09:52 +00:00
Ian Lance Taylor 9201d89491 * configure.ac: Check for chsize and posix_fallocate. Replace
ftruncate.
	* ftruncate.c: New file, from gnulib.
	* output.cc (posix_fallocate): Define dummy version if not
	HAVE_POSIX_FALLOCATE.
	(Output_file::map): Call posix_fallocate rather than lseek and
	write.
	* gold.h (ftruncate): Declare if not HAVE_FTRUNCATE.
	* configure, Makefile.in, config.in: Rebuild.
2009-03-17 22:25:30 +00:00
Paul Pluzhnikov ef4ab7a818 2009-03-17 Paul Pluzhnikov <ppluzhnikov@google.com>
* layout.h (Layout::create_note): Add section_name parameter.
	* layout.cc (Layout::create_note): Likewise.
	(Layout::create_build_id, Layout::create_gold_note): Fix callers.
2009-03-17 20:36:30 +00:00
Ian Lance Taylor e85b18e10c * descriptors.cc: Include "options.h".
(FD_CLOEXEC, O_CLOEXEC): Define if not defined.
	(Descriptors::open): Always use O_CLOEXEC when opening a new
	descriptor.  If we have a plugin, and O_CLOEXEC was not defined,
	then set FD_CLOEXEC.
2009-03-17 17:09:44 +00:00
Ian Lance Taylor 9efe6174dc * sparc.cc (class Target_sparc): Add has_got_section.
(Target_sparc::Scan::global): If we see _GLOBAL_OFFSET_TABLE_,
	make sure we have a GOT section.

	* sparc.cc (optimize_tls_reloc): Recognize R_SPARC_TLS_IE_ADD.
	(Target_sparc::Scan::local): Likewise.
	(Target_sparc::Scan::global): Likewise.
	(Target_sparc::Relocate::relocate): Likewise.
	(Target_sparc::Relocate::relocate_tls): Likewise.
2009-03-17 07:19:10 +00:00
Ian Lance Taylor 8c50070107 * symtab.cc (Symbol_table::define_default_version): New function,
broken out of add_from_object.
	(Symbol_table::add_from_object): Call define_default_version.
	(Symbol_table::define_special_symbol): Add resolve_oldsym
	parameter.  Change all callers.  If the version for a symbol comes
	from a version script, resolve it with the symbol with the same
	name with no version.  Also add the symbol without a version if
	appropriate.
	(do_define_in_output_data): If resolving with oldsym, don't delete
	sym.
	(do_define_in_output_segment): Likewise.
	(do_define_as_constant): Likewise.
	* symtab.h (class Symbol_table): Update declarations.
2009-03-17 07:07:21 +00:00
Ian Lance Taylor 15f8229bbf * readsyms.cc (Read_symbols::incompatible_warning): New function.
(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.
2009-03-14 05:56:46 +00:00
Ian Lance Taylor f1ed28fb81 * fileread.cc (Input_file::open): Remove options parameter.
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.
2009-03-13 21:30:06 +00:00
Nick Clifton 34dd024a28 Add Spanish translation to gold.
Update Indonesian translation for opcodes.
2009-03-10 09:21:01 +00:00
Cary Coutant 6d71b17c42 * options.cc (parse_short_option): Keep dash_z from registering itself. 2009-03-06 23:12:37 +00:00
Ian Lance Taylor 031cdbed18 PR 9918
* target-reloc.h (relocate_section): Pass output_section to
	relocate.
	* i386.cc (Target_i386::should_apply_static_reloc): Add
	output_section parameter.  Change all callers.
	(Target_i386::Relocate::relocate): Add output_section parameter.
	* x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
	* sparc.cc (Target_sparc::Relocate::relocate): Likewise.
	* powerpc.cc (Target_powerpc::Relocate::relocate): Likewise.
	* testsuite/two_file_shared.sh: New script.
	* testsuite/Makefile.am (check_SCRIPTS): Add two_file_shared.sh.
	(check_DATA): Add two_file_shared.dbg.
	(two_file_shared.dbg): New target.
	* testsuite/Makefile.in: Rebuild.
2009-03-04 06:46:27 +00:00
Ian Lance Taylor 15d5fa1607 elfcpp:/
* elfcpp_swap.h: #include "config.h".  Only #include <byteswap.h>
	if HAVE_BYTESWAP_H is defined; if not, provide definitions for
	bswap_{16,32,64}.  For gcc 4.3 and later, use the builtin bswap
	functions.  Check WORDS_BIGENDIAN rather than __BYTE_ORDER.
gold:/
	* configure.ac: Check for byteswap.h.
	* configure: Rebuild.
	* config.in: Rebuild.
2009-03-02 02:45:29 +00:00
Ian Lance Taylor 8a4c0b0d7e * layout.cc (Layout::find_or_add_kept_section): New function.
(Layout::add_comdat): Removed.
	* layout.h (struct Kept_section): Move out of class Layout.
	Remove trailing underscores from field names.  Add group_sections
	field.  Rename group_ field to is_group.  Change all uses.
	(class Layout): Declare find_or_add_kept_section, not add_comdat.
	* object.cc (Sized_relobj::Sized_relobj): Don't initialize
	comdat_groups_ field.
	(Sized_relobj::include_section_group): Use
	find_or_add_kept_section and Kept_section::group_sections.
	(Sized_relobj::include_linkonce_section): Likewise.
	* object.cc (class Sized_relobj): Don't define Comdat_group or
	Comdat_group_table.  Remove find_comdat_group and
	add_comdat_group.  Remove comdat_groups_ field.
	* plugin.cc (include_comdat_group): Use
	Layout::find_or_add_kept_section.
2009-03-01 22:22:02 +00:00
Ian Lance Taylor 14359ca0dc * README: --gc-sections and map files are now supported. Document
some build requirements.
2009-02-28 18:08:30 +00:00
Ian Lance Taylor b4ecf66bbe PR 6992
* symtab.cc (Symbol_table::sized_write_section_symbol): In a
	relocatable link set the value of the section symbol to zero.
	* object.cc (Sized_relobj::do_finalize_local_symbols): In a
	relocatable link don't include the section address in the local
	symbol value.
2009-02-28 17:53:16 +00:00
Ian Lance Taylor fd9d194f04 PR 6811
* 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.
2009-02-28 04:39:57 +00:00
Ian Lance Taylor 61edd21fa4 PR 5990
* descriptors.h (Open_descriptor): Add is_on_stack field.
	* descriptors.cc (Descriptors::open): If the descriptor is on the
	top of the stack, remove it.  Initialize is_on_stack field.
	(Descriptors::release): Only add pod to stack if it is not on the
	stack already.
	(Descriptors::close_some_descriptor): Clear stack_next and
	is_on_stack fields.
2009-02-28 03:05:08 +00:00
Ian Lance Taylor e29e076ab8 PR 7091
* output.cc (Output_section::find_starting_output_address): Rename
	from starting_output_address; add PADDR parameter; change return
	type.
	* output.h (class Output_section): Declare
	find_starting_output_address instead of starting_output_address.
	* object.cc (Sized_relobj::do_finalize_local_symbols): Handle a
	section symbol for which we can't find a merge section.
2009-02-28 00:12:26 +00:00
Ian Lance Taylor 0602e05a84 PR 9836
* symtab.cc (Symbol_table::add_from_object): If the visibility is
	hidden or internal, force the symbol to be local.
	* resolve.cc (Symbol::override_visibility): Define.
	(Symbol::override_base): Use override_visibility.
	(Symbol_table::resolve): Likewise.
	(Symbol::override_base_with_special): Likewise.
	(Symbol_table::override_with_special): If the visibility is hidden
	or internal, force the symbol to be local.
	* symtab.h (class Symbol): Add set_visibility and
	override_visibility.
	* testsuite/ver_test_1.sh: New file.
	* testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh.
	(check_DATA): Add ver_test_1.syms.
	(ver_test_1.syms): New target.
	* testsuite/Makefile.in: Rebuild.
2009-02-27 19:57:46 +00:00
Cary Coutant 401a9a7392 * layout.cc (Layout::choose_output_section): Don't rename sections
when using a linker script that has a SECTIONS clause.
	* Makefile.in: Regenerate.

	* testsuite/Makefile.am (script_test_5.sh): New test case.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/script_test_5.cc: New file.
	* testsuite/script_test_5.sh: New file.
	* testsuite/script_test_5.t: New file.
2009-02-25 19:05:21 +00:00
Cary Coutant f488e4b0e9 (From Rafael Espindola)
* archive.cc (Archive::include_member): Update calls to add_symbols.
	* dynobj.cc (Sized_dynobj<size, big_endian>::make_version_map): Add
	the Layout argument.
	* dynobj.h (do_add_symbols): Add the Layout argument.
	* object.cc (Sized_relobj<size, big_endian>::do_add_symbols): Add the
	Layout argument.
	* object.h (Object::add_symbols): Add the Layout argument.
	(Object::do_add_symbols): Add the Layout argument.
	(Sized_relobj::do_add_symbols): Add the Layout argument.
	* plugin.cc (Sized_pluginobj<size, big_endian>::do_add_symbols):
	Unify the two versions.
	(Add_plugin_symbols): Remove.
	* plugin.h (Pluginobj::add_symbols, Pluginobj::do_add_symbols): Remove.
	(Sized_pluginobj::do_add_symbols): Unify the two versions.
	(Add_plugin_symbols): Remove.
	* readsyms.cc (Read_symbols::do_read_symbols): Update call to
	Add_symbols. Use Add_symbols instead of Add_plugin_symbols.
	(Add_symbols::run): Make it work with Pulginobj.
2009-02-13 19:04:45 +00:00
Ian Lance Taylor 89dd16802f * object.cc (Sized_relobj::do_layout): Make info message start
with lower case letter.
2009-02-07 01:05:15 +00:00
Ian Lance Taylor 602b464ef1 * binary.cc: Fix file comment. 2009-02-07 01:03:32 +00:00
Ian Lance Taylor 266d0a7434 * options.h (enum Incremental_disposition): Define.
(class General_options): Add new options: --incremental,
	--incremental_changed, --incremental_unchanged,
	--incremental_unknown.  Add incremental_disposition_ and
	implicit_incremental_ fields.
	(General_options::incremental_disposition): New function.
	(class Position_dependent_options): Add incremental_disposition
	option.
	(Position_dependent_options::copy_from_options): Set incremental
	dispositions.
	* options.cc (General_options::parse_incremental_changed): New
	function.
        (General_options::parse_incremental_unchanged): New function.
        (General_options::parse_incremental_unknown): New function.
        (General_options::General_options): Initialize new fields
	incremental_disposition_ and implicit_incremental_.
        (General_options::finalize): Check for uasge of --incremental-*
	without --incremental.
2009-02-06 23:49:43 +00:00
Chris Demetriou f073bbf7e0 2009-02-06 Chris Demetriou <cgd@google.com>
* gold.h (gold_undefined_symbol): Change to take only a Symbol
	pointer and to report location as the file name associated with
	the symbol.
	(gold_undefined_symbol_at_location): New function to replace the
	old gold_undefined_symbol functionality.
	* target-reloc.h (relocate_section): Update to use
	gold_undefined_symbol_at_location.
	* symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
	Call gold_undefined_symbol function rather than gold_error.
	* errors.h (Errors::undefined_symbol): Take location as a
	string, rather than calculating it from a relocation.
	* errors.cc (Errors::fatal): Print "fatal error:" before the
	formatted message.
	(Errors::error, Errors::error_at_location): Print "error: "
	before the formatted message.
	(Errors::undefined_symbol): Take location as a string, rather
	than calculating it from a relocation.
	(gold_undefined_symbol_at_location): New function akin to
	old gold_undefined_symbol, calculates location from relocation.
	(gold_undefined_symbol): Change to take only a Symbol pointer
	and to report location as the file name associated with the symbol.
	* testsuite/debug_msg.sh: Update for changed error messages.
	* testsuite/undef_symbol.sh: Likewise.
2009-02-06 19:20:10 +00:00
Ian Lance Taylor 8e94a90cbc PR 9812
* reduced_debug_output.h
	(Output_reduced_debug_abbrev_section::failed): Use format for
	gold_warning.
	(Output_reduced_debug_info_section::faild): Likewise.
2009-02-04 15:18:51 +00:00
Ian Lance Taylor 88a0e15ba8 * script.cc (Lazy_demangler): New class.
(Version_script_info::get_symbol_version_helper): Demangle a
	symbol only once.
2009-02-01 00:45:28 +00:00
Cary Coutant 5efc7cd2d6 * i386.cc (Target_i386::Relocate::relocate): Recognize non-PIC calls
to __tls_get_addr.
	* x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.

	* ChangeLog: Fixed typo in previous ChangeLog entry (version 1.9).
2009-01-30 00:21:46 +00:00
Ian Lance Taylor 75fe7426f9 * version.cc (version_string): Bump to 1.8. 2009-01-28 20:18:11 +00:00
Ian Lance Taylor e0ebcf42c2 * gold.h: Include <cstring> and <stdint.h>.
* version.cc: Include <cstdio>.
	* object.cc (Sized_relobj::do_layout): Initialize gc_sd to avoid a
	warning.
	* reduced_debug_output.cc (insert_into_vector): Rename from
	Insert_into_vector; change all callers.  Use Swap_unaligned to
	avoid aliasing issue; remove union since it is unnecessary.
2009-01-28 20:09:18 +00:00
Sriraman Tallam 8e2813be52 Wrong date and missing space in last checkin. 2009-01-28 02:27:07 +00:00
Sriraman Tallam 6d03d481a0 2009-01-20 Sriraman Tallam <tmsriram@google.com>
* Makefile.am (CCFILES): Add gc.cc.
	(HFILES): Add gc.h.
	* Makefile.in: Regenerate.
	* gold.cc (Gc_runner): New class.
	(queue_initial_tasks): Call garbage collection related tasks
	when corresponding options are invoked.
	(queue_middle_gc_tasks): New function.
	(queue_middle_tasks): Reorder tasks to allow relocs to be read and
	processed early before laying out sections during garbage collection.
	* gold.h (queue_middle_gc_tasks): New function.
	(is_prefix_of): Move from "layout.cc".
	* i386.cc (Target_i386::gc_process_relocs): New function.
	* layout.cc (is_prefix_of): Remove. Move to "gold.h"
	* main.cc (main): Create object of class "Garbage_collection".
	* object.cc (Relobj::copy_symbols_data): New function.
	(Relobj::is_section_name_included): New function.
	(Sized_relobj::do_layout): Allow this function to be called twice
	during garbage collection and defer layout of section during the
	first call.
	* object.h (Relobj::get_symbols_data): New function.
	(Relobj::is_section_name_included): New function.
	(Relobj::copy_symbols_data): New function.
	(Relobj::set_symbols_data): New function.
	(Relobj::get_relocs_data): New function.
	(Relobj::set_relocs_data): New function.
	(Relobj::is_output_section_offset_invalid): New pure virtual function.
	(Relobj::gc_process_relocs): New function.
	(Relobj::do_gc_process_relocs): New pure virtual function.
	(Relobj::sd_): New data member.
	(Sized_relobj::is_output_section_offset_invalid): New function.
	(Sized_relobj::do_gc_process_relocs): New function.
	* options.h (General_options::gc_sections): Modify to not be a no-op.
	(General_options::print_gc_sections): New option.
	* plugin.cc (Plugin_finish::run): Remove function call to
	Plugin_manager::layout_deferred_objects.  Move it to "gold.cc".
	* powerpc.cc (Target_powerpc::gc_process_relocs): New function.
	* reloc.cc (Read_relocs::run): Add task to process relocs and
	determine unreferenced sections when doing garbage collection.
	(Gc_process_relocs): New class.
	(Sized_relobj::do_gc_process_relocs): New function.
	(Sized_relobj::do_scan_relocs): Don't try to scan the relocs for
	sections that are garbage collected.
	* reloc.h (Gc_process_relocs): New class.
	* sparc.cc (Target_sparc::gc_process_relocs): New function.
	* symtab.cc (Symbol::should_add_dynsym_entry): Do not add entries for
	symbols whose corresponding sections are garbage collected.
	(Symbol_table::Symbol_table): Add new parameter for the garbage
	collection object.
	(Symbol_table::gc_mark_undef_symbols): New function.
	(Symbol_table::gc_mark_symbol_for_shlib): New function.
	(Symbol_table::gc_mark_dyn_syms): New function.
	(Symbol_table::resolve): Do not treat symbols seen in dynamic objects
	as garbage.
	(Symbol_table::add_from_object): Likewise.
	(Symbol_table::add_from_relobj): When building shared objects, do not
	treat externally visible symbols as garbage.
	(Symbol_table::sized_finalize_symbol): Do not check dynamic symbol
	table information for static and relocatable links.
	* symtab.h (Symbol_table::set_gc): New function.
	(Symbol_table::gc): New function.
	(Symbol_table::gc_mark_undef_symbols): New function.
	(Symbol_table::gc_mark_symbol_for_shlib): New function.
	(Symbol_table::gc_mark_dyn_syms): New function.
	(Symbol_table::gc_): New data member.
	* target.h (Sized_target::gc_process_relocs): New pure virtual
	function.
	* x86_64.cc (Target_x86_64::gc_process_relocs): New function.
	* testsuite/testfile.cc (Target_test::gc_process_relocs): New function.
2009-01-28 02:25:33 +00:00
Christopher Faylor 3b2935444f * options.h (General_options::gc_sections): Define as a no-op for now.
(General_options::no_keep_memory): Ditto.
(General_options::Bshareable): Define.
* options.cc (General_options::finalize): Honor -Bshareable.
2009-01-23 17:05:16 +00:00
Andreas Schwab 83d22aa855 * powerpc.cc (Powerpc_relocate_functions::rel16_ha): Don't try to
read the value in the contents, since we don't use it.  Use the
template endianness when writing.
(Relocate::relocate): Use it for R_PPC_REL16_HA.
2009-01-20 16:12:00 +00:00
Andreas Schwab cd536b21e2 * configure.tgt (powerpc64-*): Fix targ_obj. 2009-01-19 19:55:26 +00:00
Ian Lance Taylor 99e9a495d5 * object.cc (Sized_relobj::write_local_symbols): Don't write out
local symbols when stripping all symbols.
2009-01-15 18:10:54 +00:00
Cary Coutant bbbfea06e5 * output.cc (Output_reloc): Add explicit instantiations. 2009-01-15 02:18:11 +00:00
Cary Coutant 0f7c0701ba * archive.cc (Archive::get_elf_object_for_member): Remove call
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.
2009-01-15 01:29:25 +00:00
Ian Lance Taylor 62a6d10909 * version.cc (version_string): Bump to 1.8. 2009-01-07 21:39:25 +00:00
Cary Coutant 483620e86f * gold.cc (gold_exit): Call plugin cleanup handlers on exit.
* plugin.cc (Plugin_manager::finish): Rename as
	layout_deferred_objects.  Move cleanup to separate function.
	(Plugin_manager::cleanup): New function.
	(Plugin_finish::run): Call layout_deferred_objects and cleanup
	separately.
	* plugin.h (Plugin_manager::finish): Rename as
	layout_deferred_objects.
	(Plugin_manager::cleanup): New function.
	(Plugin_manager::cleanup_done): New field.
2008-12-24 06:17:18 +00:00
Cary Coutant d66a9eb3f0 * plugin.cc (is_visible_from_outside): New function.
(Pluginobj::get_symbol_resolution_info): Call is_visible_from_outside
	so we don't return "IR only" status for exported symbols or -r links.

	* testsuite/Makefile.am (plugin_test_3): New test case.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/plugin_test_3.sh: New file.
2008-12-23 23:46:55 +00:00
Cary Coutant 5995b57073 * object.cc (Sized_relobj::layout_section): New function.
(Sized_relobj::do_layout): Defer layout of input sections until after
	plugin has provided replacement files.
	(Sized_relobj::do_layout_deferred_sections): New function.
	* object.h (Relobj::set_section_offset): Remove virtual keyword.
	(Relobj::layout_deferred_sections): New function.
	(Relobj::do_layout_deferred_sections): New function.
	(Sized_relobj::do_layout_deferred_sections): New function.
	(Sized_relobj::layout_section): New function.
	(Sized_relobj::Deferred_layout): New structure.
	(Sized_relobj::deferred_layout_): New field.
	* plugin.cc (Plugin_manager::finish): Renamed, was cleanup.
	Change all callers.  Layout deferred sections.
	(class Plugin_finish): Renamed, was Plugin_cleanup.  Change all
	references.
	(Plugin_hook::run): Move code from do_plugin_hook inline.
	(Plugin_hook::do_plugin_hook): Remove.
	* plugin.h (Plugin_manager::Plugin_manager): Add missing initializers.
	(Plugin_manager::finish): Renamed, was cleanup.
	(Plugin_manager::should_defer_layout): New function.
	(Plugin_manager::add_deferred_layout_object): New function.
	(Plugin_manager::Deferred_layout_list): New type.
	(Plugin_manager::deferred_layout_objects_): New field.
	(Plugin_hook::do_plugin_hook): Remove.
2008-12-23 02:02:20 +00:00
Ian Lance Taylor ee769c8852 * options.h (class General_options): Add --no case for
--export-dynamic.
2008-12-18 01:53:38 +00:00
Cary Coutant abc8dcbad2 * plugin.cc (Plugin::load): Move LDPT_MESSAGE to front of transfer
vector.
	(Plugin_manager::claim_file): Create plugin object even if
	plugin did not call the add_symbols callback.
	(Plugin_obj::get_symbol_resolution_info): Guard against plugin
	asking for more symbols than were added.
	* testsuite/Makefile.am (plugin_test_1): Add test case with
	no global symbols.
	(empty.syms): New target.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/plugin_test.c (claim_file_hook): Add new debug
	message. Don't call add_symbols if no globals.
	(all_symbols_read_hook): Don't provide replacement for empty
	claimed file.
2008-12-16 19:19:16 +00:00
Ian Lance Taylor 6894310219 * target-reloc.h (Default_scan_relocatable_relocs): Only discard
r_type == 0 for a local symbol with r_sym == 0.
	(scan_relocatable_relocs): Pass r_sym to
	local_non_section_strategy.
	* reloc.cc (Emit_relocs_strategy::local_non_section_strategy): Add
	r_sym parameter.
2008-12-12 16:33:05 +00:00
Ian Lance Taylor b0074644c4 * configure.ac: Update test for TLS descriptors: they are
supported as of glibc 2.9.
	* configure: Rebuild.
2008-12-12 16:23:27 +00:00
Ian Lance Taylor c250817872 PR 7091
* target-reloc.h (Default_scan_relocatable_relocs): For each
	function, map r_type == 0 to RELOC_DISCARD.
2008-12-12 02:41:39 +00:00
Cary Coutant 2756a25828 * layout.cc (Layout::add_comdat): Allow COMDAT group from a replacement
object to override a kept COMDAT group from a plugin object.
2008-12-10 19:50:14 +00:00
Ian Lance Taylor fbc558e16b PR 7088
* yyscript.y (file_cmd): Handle INPUT.
2008-12-09 16:09:32 +00:00
Ian Lance Taylor bb6f53d37a * testsuite/initpri1.c: Change all declarations to be full
prototypes by adding void, to avoid compiler warnings.
2008-12-09 16:03:47 +00:00
Cary Coutant 4674ecfcf4 2008-12-05 Rafael Avila de Espindola <espindola@google.com>
* options.cc (General_options::parse_plugin_opt): New.
	(General_options::add_plugin): The argument now is just the filename.
	(General_options::add_plugin_option): New.
	* options.h (plugin_opt): New.
	(add_plugin): Change argument name.
	(add_plugin_option): New.
	* plugin.cc (Plugin::load): Don't parse the plugin option.
	* plugin.h (Plugin::Plugin): Rename argument. Init filename_.
	(Plugin::add_option): New.
	(Plugin::args_): Change type.
	(Plugin::filename_): New.
	(Plugin_manager::add_plugin_option): New.
	* testsuite/Makefile.am (plugin_test_1): Use new syntax.
	* testsuite/Makefile.in: Regenerate.
2008-12-05 21:34:54 +00:00
Cary Coutant fd06b4aa51 * layout.cc (Layout::include_section): Check for SHF_EXCLUDE.
Handle --strip-lto-sections option.
	* options.h (strip_lto_sections): New option.
2008-12-05 21:13:35 +00:00
Cary Coutant 6c52134ce6 gold/ChangeLog:
* plugin.cc (ld_plugin_message): Change format parameter to const.
	Fix mismatch between new[] and delete.

include/ChangeLog:

	* plugin-api.h (ld_plugin_message): Change format parameter to const.
2008-12-01 19:50:49 +00:00
Cary Coutant a45248e086 * reloc.cc (Sized_relobj::do_read_relocs): Use constant invalid_address
instead of -1U.
2008-11-15 01:40:23 +00:00
Craig Silverstein c82fbeee59 * options.cc (General_options::parse_dynamic_list): New function.
* options.h (General_options): New flags dynamic_list,
	dynamic_list_data, dynamic_list_cpp_new, and
	dynamic_list_cpp_typeinfo.  New variable dynamic_list_.
	(General_options::in_dynamic_list): New function.
	* script.cc (Lex::Mode): New enum DYNAMIC_LIST.
	(Lex::can_start_name): Add support for DYNAMIC_LIST mode.
	(Lex::can_continue_name): Likewise.
	(yylex): Likewise.
	(read_script_file): New parameter script_options.
	(read_dynamic_list): New function.
	(Script_options::define_dynamic_list): New function.
	(dynamic_list_keyword_parsecodes): New variable.
	(dynamic_list_keywords): New variable.
	* script.h (Script_options::define_dynamic_list): New function
	prototype.
	(read_dynamic_list): New function prototype.
	* symtab.cc (strprefix): New macro.
	(Symbol::should_add_dynsym_entry): Support dynamic_list,
	dynamic_list_data, dynamic_list_cpp_new, and
	dynamic_list_cpp_typeinfo.
	* yyscript.y (PARSING_DYNAMIC_LIST): New token.
	(dynamic_list_expr): New rule.
	(dynamic_list_nodes): Likewise.
	(dynamic_list_node): Likewise.
	* testsuite/Makefile.am (dynamic_list): New test.
	* testsuite/Makefile.in: Regenerated.
	* testsuite/dynamic_list.t: New file.
	* testsuite/dynamic_list.sh: New file.
2008-11-06 07:23:31 +00:00
Craig Silverstein e0bb29a584 * testsuite/tls_test_c.c: Add prototype for t11 and t11_last.
* testsuite/tls_test_c.c (t11): Add explicit "void" to prototype.
	(t11_last): Likewise.
	* testsuite/ver_test_6.c (main): Likewise.
2008-11-06 00:44:32 +00:00
Cary Coutant 4e1e25e084 * options.c (General_options::finalize): Add check for -static and
-shared.
	* gold.cc (queue_middle_tasks): Assert that list of dynamic objects
	is not empty.
2008-10-07 23:40:21 +00:00
Cary Coutant 92f03fcbe1 * plugin.cc (make_sized_plugin_object): Fix conditional
compilation to work when not all targets are enabled.
2008-10-02 18:35:51 +00:00
Cary Coutant 81636b3fef Added missing files to ChangeLog entry. 2008-09-29 21:26:39 +00:00
Cary Coutant fbd8a2572e * archive.cc (Archive::get_file_and_offset): Use filename instead
of name to get library path.
	(Archive::include_member): Unlock external member of a thin archive.

	* testsuite/Makefile.am (TEST_AR): New variable.
	(thin_archive_test_1): New test.
	(thin_archive_test_2): New test.
2008-09-29 21:23:02 +00:00
Cary Coutant eff458138e * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.
* object.cc (Sized_relobj::do_layout): Use constant invalid_address
	instead of -1U.
	(Sized_relobj::do_finalize_local_symbols): Likewise.
	(Sized_relobj::map_to_kept_section): Likewise.
	* object.h (Sized_relobj::invalid_address): New constant.
	(Sized_relobj::do_output_section_offset): Check for invalid_address
	and return -1ULL.
	* output.cc (Output_reloc::local_section_offset): Use constant
	invalid_address instead of -1U.
	(Output_reloc::get_address): Likewise.
	(Output_section::output_address): Change -1U to -1ULL.
	* output.h (Output_reloc::invalid_address): New constant.
	* reloc.cc (Sized_relobj::write_sections): Use constant
	invalid_address instead of -1U.
	(Sized_relobj::relocate_sections): Likewise.
	* symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
	values for merge sections.
	* target-reloc.h (relocate_for_relocatable): Use constant
	invalid_address instead of -1U.
2008-09-29 21:10:26 +00:00
Cary Coutant 89fc34211b Add plugin functionality for link-time optimization (LTO).
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.
2008-09-19 22:54:57 +00:00
Ian Lance Taylor 9c2d0ef98a * target-reloc.h (relocate_section): Check whether a symbol is
defined by the ABI before reporting an undefined symbol error.
	* target.h (Target::is_defined_by_abi): Make parameter const.
	(Target::do_is_defined_by_abi): Likewise.
	* i386.cc (Target_i386::do_is_defined_by_abi): Likewise.
	* powerpc.cc (Target_powerpc::do_is_defined_by_abi): Likewise.
	* sparc.cc (Target_sparc::do_is_defined_by_abi): Likewise.
	* x86_64.cc (Target_x86_64::do_is_defined_by_abi): Likewise.
	* testsuite/Makefile.am (tls_test_shared.so): Add -Wl,-z,defs.
	* testsuite/Makefile.in: Rebuild.
2008-09-16 17:23:37 +00:00
Ian Lance Taylor de31bda5f6 * fileread.cc (make_view): Add casts to avoid warning. 2008-09-16 17:17:22 +00:00
Alexandre Oliva 9fa33bee6a * i386.cc (Target_i386::define_tls_base_symbol): Update comments.
* x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
2008-09-16 04:31:25 +00:00
Alexandre Oliva 183fd0e3ed * options.h (General_options::output_is_executable): New.
(General_options::output_is_pie): New.
* i386.cc (Target_i386::define_tls_base_symbol): Use SEGMENT_START
for shared libraries.
* x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
2008-09-16 04:23:29 +00:00
Chris Demetriou 7be8330a59 2008-09-11 Chris Demetriou <cgd@google.com>
* options.h (origin): New -z option.
        * layout.cc (Layout:finish_dynamic_section): If "-z origin"
        is specified, set DF_ORIGIN in DT_FLAGS and set DF_1_ORIGIN
        in DT_FLAGS_1.
2008-09-12 05:42:29 +00:00
Cary Coutant a9caad024e 2008-09-05 Cary Coutant <ccoutant@google.com>
* fileread.cc (File_read::make_view): Add check for attempt to map
	beyond end of file.
2008-09-10 17:56:02 +00:00
Cary Coutant ae6dce4daa 2008-09-05 Cary Coutant <ccoutant@google.com>
* symtab.cc (Symbol_table::add_from_dynobj): Fix typos in
	explicit instantiations.
2008-09-06 01:13:00 +00:00
Kris Van Hees d7ab2a4705 2008-08-28 Kris Van Hees <kris.van.hees@oracle.com>
PR gold/6858
        * options.cc (General_options::finalize): Allow undefined symbols
        in shlibs if linking -shared.

        PR gold/6859
        * symtab.cc (Symbol::init_base_undefined): Mark explicitly undefined
        symbols as not needing a dynsym entry.
2008-08-28 14:51:04 +00:00
Craig Silverstein 1e52a9c187 2008-08-20 Craig Silverstein <csilvers@google.com>
* fileread.cc (File_read::open): Do not lock the file unless it
	was successfully opened.
2008-08-21 00:30:13 +00:00
Cary Coutant d85c80a353 2008-08-14 Cary Coutant <ccoutant@google.com>
* x86_64.cc (Target_x86_64::Relocate::relocat_tls):
	Use addend for DTPOFF32, DTPOFF64, and TPOFF32 relocs.
	* testsuite/tls_test.cc (struct int128): 128-bit struct
	for testing TLS relocs with non-zero addend.
	(v12): New TLS variable.
	(t12): New test.
	(t_last): Add check for v12.
	* testsuite/tls_test.h (t12): New function.
	* testsuite/tls_test_main.cc (thread_routine): Call new test.
2008-08-15 04:57:46 +00:00
Ian Lance Taylor 2d924fd9eb * layout.cc (Layout::attach_allocated_section_to_segment): Don't
set tls_segment_ or relro_segment_.
	(Layout::make_output_segment): Set tls_segment_ and relro_segment_
	when appropriate.
	* output.h (Output_section::clear_is_relro): New function.
	* output.cc (Output_segment::add_output_section): Handle SHF_TLS
	sections specially even when output_data_ is empty.
	(Output_segment::maximum_alignment): When first section is relro,
	only force alignment for PT_LOAD segments.
	* script.cc (script_data_segment_align): New function.
	(script_data_segment_relro_end): New function.
	* script-c.h (script_data_segment_align): Declare.
	(script_data_segment_relro_end): Declare.
	* script-sections.h (class Script_sections): Declare
	data_segment_align and data_segment_relro_end.  Add fields
	segment_align_index_ and saw_relro_end_.
	* script-sections.cc (class Sections_element): Add set_is_relro
	virtual function.  Add new bool* parameter to place_orphan_here.
	Add get_output_section virtual function.
	(class Output_section_definition): Add set_is_relro.  Add new
	bool* parameter to place_orphan_here.  Add get_output_section.
	Add is_relro_ field.
	(Output_section_definition::Output_section_definition): Initialize
	evaluated_address_, evaluated_load_address, evaluated_addralign_,
	and is_relro_ fields.
	(Output_section_definition::place_orphan_here): Add is_relro
	parameter.
	(Output_section_definition::set_section_addresses): Set relro for
	output section.
	(Output_section_definition::alternate_constraint): Likewise.
	(class Orphan_output_section): Add new bool* parameter to
	place_orphan_here.  Add get_output_section.
	(Orphan_output_section::place_orphan_here): Add is_relro
	parameter.
	(Script_sections::Script_sections): Initialize
	data_segment_align_index_ and saw_relro_end_.
	(Script_sections::data_segment_align): New function.
	(Script_sections::data_segment_relro_end): New function.
	(Script_sections::place_orphan): Set or clear is_relro.
	(Script_sections::set_section_addresses): Force alignment of first
	TLS section.
	* yyscript.y (exp): Call script_data_segment_align and
	script_data_segment_relro_end.
	* testsuite/relro_script_test.t: New file.
	* testsuite/relro_test.cc (using_script): Declare.
	(t1, t2): Test using_script.
	* testsuite/Makefile.am (check_PROGRAMS): Add relro_script_test.
	(relro_script_test_SOURCES): Define.
	(relro_script_test_DEPENDENCIES): Define.
	(relro_script_test_LDFLAGS): Define.
	(relro_script_test_LDADD): Define.
	(relro_script_test.so): New target.
	* testsuite/Makefile.in: Rebuild.
2008-08-13 07:37:46 +00:00
Cary Coutant f827c9a9d7 2008-08-06 Cary Coutant <ccoutant@google.com>
* archive.cc (Archive::total_archives, Archive::total_members)
	(Archive::total_members_loaded): New variables.
	(Archive::setup): Add parameter.  Add option to preread
	archive symbols.
	(Archive::read_armap): Add counter.
	(Archive::get_file_and_offset): New function.
	(Archive::get_elf_object_for_member): New function.
	(Archive::read_all_symbols): New function.
	(Archive::read_symbols): New function.
	(Archive::add_symbols): Add counters.
	(Archive::include_all_members): Use armap to find members if it's
	already built.
	(Archive::include_member): Skip reading symbols if already read.
	Factored code into Archive::get_file_and_offset and
	Archive::get_elf_object_for_member.  Changed call to
	Mapfile::report_include_archive_member.
	(Archive::print_stats): New function.
	* archive.h: Declare Object and Read_symbols_data classes.
	(Archive::Archive): Add initializers for new members.
	(Archive::setup): Add parameter.
	(Archive::print_stats): New function.
	(Archive::total_archives, Archive::total_members)
	(Archive::total_members_loaded): New variables.
	(Archive::get_file_and_offset): New function.
	(Archive::get_elf_object_for_member): New function.
	(Archive::read_all_symbols): New function.
	(Archive::read_symbols): New function.
	(Archive::Archive_member): New class.
	(Archive::members_): New member.
	(Archive::num_members_): New member.
	* main.cc: Include archive.h.
	(main): Call Archive::print_stats.
	* mapfile.cc (Mapfile::report_include_archive_member): Delete
	archive parameter; member_name is now the fully-decorated name.
	* mapfile.h (Mapfile::report_include_archive_member): Likewise.
	* options.h: (General_options): Add --preread-archive-symbols option.
	* readsyms.cc (Read_symbols::do_read_symbols): Change call to
	Archive::setup.
2008-08-07 17:16:36 +00:00
Cary Coutant ac45a351cf 2008-08-06 Cary Coutant <ccoutant@google.com>
* archive.cc (Archive::total_archives, Archive::total_members)
	(Archive::total_members_loaded): New variables.
	(Archive::setup): Add parameter.  Add option to preread
	archive symbols.
	(Archive::read_armap): Add counter.
	(Archive::get_file_and_offset): New function.
	(Archive::get_elf_object_for_member): New function.
	(Archive::read_all_symbols): New function.
	(Archive::read_symbols): New function.
	(Archive::add_symbols): Add counters.
	(Archive::include_all_members): Use armap to find members if it's
	already built.
	(Archive::include_member): Skip reading symbols if already read.
	Factored code into Archive::get_file_and_offset and
	Archive::get_elf_object_for_member.  Changed call to
	Mapfile::report_include_archive_member.
	(Archive::print_stats): New function.
	* archive.h: Declare Object and Read_symbols_data classes.
	(Archive::Archive): Add initializers for new members.
	(Archive::setup): Add parameter.
	(Archive::print_stats): New function.
	(Archive::total_archives, Archive::total_members)
	(Archive::total_members_loaded): New variables.
	(Archive::get_file_and_offset): New function.
	(Archive::get_elf_object_for_member): New function.
	(Archive::read_all_symbols): New function.
	(Archive::read_symbols): New function.
	(Archive::Archive_member): New class.
	(Archive::members_): New member.
	(Archive::num_members_): New member.
	* main.cc: Include archive.h.
	(main): Call Archive::print_stats.
	* mapfile.cc (Mapfile::report_include_archive_member): Delete
	archive parameter; member_name is now the fully-decorated name.
	* mapfile.h (Mapfile::report_include_archive_member): Likewise.
	* options.h: (General_options): Add --preread-archive-symbols option.
	* readsyms.cc (Read_symbols::do_read_symbols): Change call to
	Archive::setup.
2008-08-07 17:02:11 +00:00
Ian Lance Taylor de4c45bd54 * symtab.h (Symbol::use_plt_offset): New function.
* i386.cc (Relocate::relocate): Call Symbol::use_plt_offset.
	* powerpc.cc (Relocate::relocate): Likewise.
	* sparc.cc (Relocate::relocate): Likewise.
	* x86_64.cc (Relocate::relocate): Likewise.
	* testsuite/weak_plt.sh: New test.
	* testsuite/weak_plt_main.cc: New test.
	* testsuite/weak_plt_shared.cc: New test.
	* testsuite/Makefile.am (check_SCRIPTS): Add weak_plt.sh.
	(check_PROGRAMS): Add weak_plt.
	(check_DATA): Add weak_plt_shared.so.
	(weak_plt_main_pic.o, weak_plt): New targets.
	(weak_plt_shared_pic.o, weak_plt_shared.so): New targets.
	* testsuite/Makefile.in: Rebuild.

	* testsuite/Makefile.am (weak_alias_test_1.so): Depend upon
	gcctestdir/ld.
	(weak_alias_test_2.so, weak_alias_test_4.so): Likewise.
	* testsuite/Makefile.in: Rebuild.
2008-08-04 22:22:13 +00:00
Alan Modra 323ee3f41c Set LC_ALL=C rather than unsetting LC_COLLATE for sort. 2008-08-04 06:55:33 +00:00
Ian Lance Taylor 7c07ececf4 * script.cc (Script_options::finalize_symbols): Finalize SECTIONS
symbols before other symbols.
	* testsuite/script_test_2.cc (test_addr): Declare.
	(test_addr_alias): Declare.
	(main): Check that test_addr and test_addr_alias have the right
	values.
	* testsuite/script_test_2.t: Define test_addr_alias and
	test_addr.
2008-07-29 22:58:03 +00:00
Ian Lance Taylor 2a00e4fb8e PR 5990
* 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.
2008-07-25 04:25:49 +00:00
Ian Lance Taylor 801647d1db PR 6716
* gold.h: Always include <clocale>.  Add Solaris workarounds
	following code in binutils/sysdep.h.
2008-07-24 21:45:50 +00:00
Ian Lance Taylor 5edd166e7d PR 6048
* ehframe.cc (Eh_frame::add_ehframe_input_section): Check whether
	this->eh_frame_hdr_ is NULL before using it.
2008-07-24 21:23:09 +00:00
Ian Lance Taylor c89ad72891 * dynobj.cc (Versions::Versions): Update comment. 2008-07-24 21:21:38 +00:00
Ian Lance Taylor aa86f06bb6 * dynobj.cc (Versions::Versions): If there is an soname, use it as
the base version name.
2008-07-24 07:26:27 +00:00
Ian Lance Taylor 5778530ea7 * stringpool.cc (Stringpool_template::add_with_length): Set key to
array size plus one.
	(Stringpool_template::set_string_offsets): Subtract one from key
	before using it as an array index.
	(Stringpool_template::get_offset_with_length): Likewise.
	(Stringpool_template::write_to_buffer): Likewise.
	* stringpool.h (Stringpool_template::get_offset_from_key):
	Likewise.
2008-07-24 07:23:20 +00:00
Ian Lance Taylor 7f649c59d1 PR 6658
* object.h (Merged_symbol_value::value): Do our best to handle a
	negative addend.
2008-07-24 01:24:50 +00:00
Ian Lance Taylor 057ead2231 PR 6647
* script.cc (Version_script_info::get_versions): Don't add empty
	version tag to return value.
	(Version_script_info::get_symbol_version_helper): Change return
	type to bool.  Add pversion parameter.  Change all callers.
	(script_register_vers_node): Don't require a non-NULL tag.
	* script.h (class Version_script_info): Update declarations.
	(Version_script_info::get_symbol_version): Change return type to
	bool.  Add version parameter.  Change all callers.
	* symtab.cc (Sized_symbol::add_from_relobj): Rework version
	handling.  Handle an empty version from a version script.
	(Symbol_table::define_special_symbol): Likewise.
	* testsuite/ver_test_10.script: New file.
	* testsuite/ver_test_10.sh: New file.
	* testsuite/Makefile.am (check_SCRIPTS): Add ver_test_10.sh.
	(check_DATA): Add ver_test_10.syms.
	(ver_test_10.syms, ver_test_10.so): New target.
	* testsuite/Makefile.in: Rebuild.
2008-07-23 23:44:02 +00:00
Chris Demetriou 58e54ac21d 2008-07-23 Simon Baldwin <simonb@google.com>
* symtab.cc (Symbol_table::sized_write_symbol): Only set st_size
        to zero for undefined symbols from dynamic libraries.
2008-07-23 16:19:59 +00:00
Ian Lance Taylor 95d14cd31e * symtab.cc (Symbol_table::resolve): Remove version parameter.
Change all callers.
	* symtab.h (class Symbol_table): Update declaration.
	* testsuite/ver_test_9.cc: New file.
	* testsuite/Makefile.am (check_PROGRAMS): Add ver_test_9.
	(ver_test_9_SOURCES, ver_test_9_DEPENDENCIES): Define.
	(ver_test_9_LDFLAGS, ver_test_9_LDADD): Define.
	(ver_test_9.so, ver_test_9.o): New targets.
	* testsuite/Makefile.in: Rebuild.
2008-07-23 14:36:09 +00:00
Ian Lance Taylor 3481085102 * options.h (class General_options): Define --check-sections.
* layout.cc (Layout::set_segment_offsets): Handle
	--check-sections.
2008-07-22 23:55:24 +00:00