Commit Graph

236 Commits

Author SHA1 Message Date
Cary Coutant 1f25b93bc6 Fix problem where -u is ignored when a weak undef is seen.
When the linker has a weak undefined symbol, it normally does not
select an archive library member just to satisfy the reference.
If the same symbol is also listed in a -u option, however, we
should select the archive library member.  This patch reorders
the code in Library_base::should_include_member so that the
additional checks are performed in the case of a weak undef.

gold/

2014-02-06  Cary Coutant  <ccoutant@google.com>

	* archive.cc (Library_base::should_include_member): Reorder
	code to check for -u option if a weak undef has already been seen.
	* testsuite/Makefile.am (weak_undef_test_2): New test case.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/weak_undef_file3.cc: New file.
	* testsuite/weak_undef_file4.cc: New file.
	* testsuite/weak_undef_test_2.cc: New file.
2014-02-06 17:15:02 -08:00
Cary Coutant fd834e57ff Fix problems with the --dynamic-list option.
PR gold/13577 complains that even though symbols listed in
the --dynamic-list script are exported, they are still bound symbolically
if -Bsymbolic is also used. There are two underlying problems here.
First, -Bsymbolic should be overridden by --dynamic-list, since the
dynamic list provides an explicit list of symbols that are not bound
within the library, and if we go ahead and set DT_SYMBOLIC, then the
dynamic loader will bind it within the library anyway. Second, gold
did not properly identify the symbols listed in the file as preemptible.

PR gold/16530 complains that symbols listed in the --dynamic-list script
can still be garbage collected. I've fixed this by checking the symbols
as they're added to the symbol table. (Unlike the --export-dynamic-symbol
option, we can't iterate over the list, because the --dynamic-list script
can have wildcards in it.)

gold/

2014-02-05  Cary Coutant  <ccoutant@google.com>

	PR gold/13577
	* options.cc (General_options::parse_dynamic_list):
	Set have_dynamic_list_.
	(General_options::General_options): Initialize have_dynamic_list_.
	(General_options::finalize): Turn off -Bsymbolic and
	-Bsymbolic-functions if --dynamic-list provided.
	* options.h (General_options::have_dynamic_list): New function.
	(General_options::have_dynamic_list_): New data member.
	* symtab.h (Symbol::is_preemptible): Handle --dynamic-list
	correctly.

	PR gold/16530
	* symtab.cc (Symbol_table::add_from_relobj): If symbol is named
	in --dynamic-list, mark it.

	* testsuite/Makefile.am (gc_dynamic_list_test.sh): New test case.
	(dynamic_list_2): New test case.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/dynamic_list_2.cc: New file.
	* testsuite/dynamic_list_2.t: New file.
	* testsuite/dynamic_list_lib1.cc: New file.
	* testsuite/dynamic_list_lib2.cc: New file.
	* testsuite/gc_dynamic_list_test.c: New file.
	* testsuite/gc_dynamic_list_test.sh: New file.
	* testsuite/gc_dynamic_list_test.t: New file.
2014-02-05 18:01:47 -08:00
Cary Coutant 0c075858c7 Use in-tree assembler for exception_x86_64_bnd_test.
gold/
	* testsuite/Makefile.am (exception_x86_64_bnd_test): Use in-tree
	assembler.
	* testsuite/Makefile.in: Regenerate.
2013-11-22 15:47:18 -08:00
H.J. Lu f49fe902ba Add R_X86_64_PC32_BND/R_X86_64_PLT32_BND suppor to gold
elfcpp/

	* x86_64.h (R_X86_64_PC32_BND): New.
	(R_X86_64_PLT32_BND): Likewise.

gold/

	* x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags):
	Handle R_X86_64_PC32_BND and R_X86_64_PLT32_BND just like
	R_X86_64_PC32 and R_X86_64_PLT32, respectively.
	(Target_x86_64<size>::Scan::local): Likewise.
	(Target_x86_64<size>::Scan::global): Likewise.
	(Target_x86_64<size>::Relocate::relocate): Likewise.
	(Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc):
	Likewise.
	(Target_x86_64<size>::Scan::check_non_pic(): Handle
	R_X86_64_PC32_BND.

	* testsuite/Makefile.am (check_PROGRAMS): Add
	exception_x86_64_bnd_test.
	(exception_x86_64_bnd_test_SOURCES): New macro.
	(exception_x86_64_bnd_test_DEPENDENCIES): Likewise.
	(exception_x86_64_bnd_test_LDFLAGS): Likewise.
	(exception_x86_64_bnd_test_LDADD): Likewise.
	(exception_x86_64_bnd_1.o): New rule.
	(exception_x86_64_bnd_2.o): Likewise.
	* testsuite/Makefile.in: Regenerated.
2013-11-18 09:55:09 -08:00
Roland McGrath 52dc3f9c91 Revert inappropriate portions of last change. 2013-10-11 22:16:34 +00:00
Roland McGrath 1496b4465d gold/
* testsuite/Makefile.am: Replace '-T foo' with '-Wl,-T,foo' throughout.
	* testsuite/Makefile.in: Regenerate.
2013-10-11 22:05:16 +00:00
Roland McGrath 2b64b5511a gold/
* configure.ac (MERGE_CONSTANTS_FLAG): New check.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* testsuite/merge_string_literals_1.c: Renamed to have .cc suffix.
	* testsuite/merge_string_literals_2.c: Likewise.
	* testsuite/Makefile.am
	(merge_string_literals_1.o, merge_string_literals_2.o): Update deps.
	(AM_CFLAGS, AM_CXXFLAGS): Use $(MERGE_CONSTANTS_FLAG) in place of
	literal -fmerge-constants.
	* testsuite/Makefile.in: Regenerate.
2013-10-11 21:56:16 +00:00
Cary Coutant 54de2ea658 gold/
PR gold/16010
	* testsuite/Makefile.am (icf_test): Fix dependencies.
	(icf_safe_test): Likewise.
	(icf_safe_so_test): Likewise.
	(large_symbol_alignment): Add empty _LDADD rule.
	* testsuite/Makefile.in: Regenerate.
2013-10-07 17:08:34 +00:00
Cary Coutant 32364e50a7 gold/
* resolve.cc (Symbol::override_base): Don't override st_type
	from plugin placeholder symbols.
	(Symbol_table::resolve): Likewise.
	(Symbol_table::should_override): Don't complain about TLS mismatch
	if the TO symbol is a plugin placeholder.
	* testsuite/Makefile.am (plugin_test_tls): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/plugin_test_tls.sh: New test script.
	* testsuite/two_file_test_2_tls.cc: New test source.
	* testsuite/two_file_test_tls.cc: New test source.
2013-06-14 20:07:18 +00:00
Cary Coutant 7fb47cc9a4 2013-06-05 Alexander Ivchenko <alexander.ivchenko@intel.com>
gold/
	* layout.cc (Layout::set_segment_offsets): Taking care of the case when
	the maximum segment alignment is larger than the page size.
	* testsuite/Makefile.am (large_symbol_alignment): Test that Gold
	correctly aligns the symbols with large alignemnt.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/large_symbol_alignment.cc: New file.
2013-06-05 23:52:21 +00:00
Cary Coutant 6934001a98 2013-05-30 Alexander Ivchenko <alexander.ivchenko@intel.com>
Sriraman Tallam  <tmsriram@google.com>

	* options.h (sort_section): New option.
	* output.h (Input_section_sort_section_prefix_special_ordering_compare):
	Rename from Input_section_sort_section_name_special_ordering_compare.
	(Input_section_sort_section_name_compare): New struct.
	* output.cc (Output_section::Input_section_sort_section_name_compare::
	operator()): New function.
	(Output_section::sort_attached_input_sections): Use new sort function
	for .text if --sort-section=name is specified.
	* layout.cc (Layout::make_output_section):
	Add sorting by name when --sort-section=name is specified.
	* testsuite/Makefile.am (text_section_grouping): Test option
	--sort-section=name.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/section_sorting_name.cc: New file.
	* testsuite/section_sorting_name.sh: New file.
2013-05-30 23:01:11 +00:00
Cary Coutant 93acabad6a gold/
* symtab.h (Symbol::is_cxx_vtable): New function.
	* target-reloc.h (relocate_section): Check for vtable symbol.
	* testsuite/Makefile.am (missing_key_func.sh): New test case.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/missing_key_func.cc: New test source.
	* testsuite/missing_key_func.sh: New test script.
2013-05-21 21:14:40 +00:00
Cary Coutant 9df9de2cca gold/
* configure.ac: Export DEFAULT_TARGET.
    	* configure: Regenerate.
    	* Makefile.in: Regenerate.
    	* testsuite/Makefile.am: Add .EXPORT_ALL_VARIABLES.
    	* testsuite/Makefile.in: Regenerate.
    	* testsuite/debug_msg.sh: Delete duplicate tests.
    	Don't check undef_int error message match for powerpc where the
    	source file and line number aren't available.
2013-05-13 17:35:22 +00:00
Cary Coutant e31908b642 2013-04-29 Alexander Ivchenko <alexander.ivchenko@intel.com>
gold/
	* output.cc (Output_section::add_merge_input_section): Allow
	to merge sections if the alignment is more than character size.
	* merge.h (Output_merge_string::Output_merge_string): Remove
	assert.
	* merge.cc (Output_merge_string<Char_type>::do_add_input_section): Count
	only not-null strings. Check the alignment of strings.
	* stringpool.h
	(Stringpool_template<Stringpool_char>::Stringpool_template): Add
	alignment as the argument.
	(Stringpool_template<Stringpool_char>::addralign_): New class member.
	* stringpool.cc (Stringpool_template<Stringpool_char>::new_key_offset):
	Align non-zero length strings according to the addralign_.
	(Stringpool_template<Stringpool_char>::set_string_offsets):
	Updating offsets according to the given alignment.
	* testsuite/Makefile.am (text_section_grouping): Test if string
	literals are getting merged.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/merge_string_literals_1.c: New file.
	* testsuite/merge_string_literals_2.c: Ditto.
	* testsuite/merge_string_literals.sh: Ditto.
2013-04-29 17:15:09 +00:00
Cary Coutant 502e8a8430 gold/
* symtab.cc (Symbol_table::sized_write_globals): Subtract
    	section starting address for relocatable link.
    	* testsuite/Makefile.am (script_test_11): New test.
    	* testsuite/Makefile.in: Regenerate.
    	* testsuite/script_test_11.c: New source file.
    	* testsuite/script_test_11.t: New linker script.
2013-04-15 16:34:12 +00:00
Alan Modra 4d9aa15515 * powerpc.cc (is_branch_reloc): Forward declare.
(Target_powerpc::do_can_check_for_function_pointers): New predicate.
	(Target_powerpc::Scan::local_reloc_may_be_function_pointer): Return
	false for 64-bit, true for 32-bit non-branch relocs.
	(Target_powerpc::Scan::global_reloc_may_be_function_pointer): Likewise.
	* testsuite/Makefile.am (icf_test): Use linker map file instead of
	nm output.
	(icf_safe_test): Generate linker map file as well as nm output.
	(icf_safe_so_test): Likewise.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/icf_test.sh: Parse linker map file to determine
	section folding.
	* testsuite/icf_safe_test.sh: Likewise.  Expect folding for PowerPC.
	* testsuite/icf_safe_so_test.sh: Likewise.
	(X86_32_or_ARM_specific_safe_fold): Merge into..
	(arch_specific_safe_fold): ..this.
	(X86_64_specific_safe_fold): Delete unused function.
2013-03-12 22:46:19 +00:00
Alan Modra a39e4af6dc * testsuite/Makefile.am (final_layout_script.lds): Add .sbss.
* testsuite/Makefile.in: Regenerate.
2013-03-04 00:48:01 +00:00
Sriraman Tallam c6ac678db5 Default text reordering fix with a flag to turn it off.
2013-01-24  Sriraman Tallam  <tmsriram@google.com>

	* layout.cc (Layout::layout): Check for option text_reorder.
	(Layout::make_output_section): Ditto.
	* options.h (text_reorder): New option.
	* output.cc (Input_section_sort_compare): Remove special ordering
	of section names.
	(Output_section::
	 Input_section_sort_section_name_special_ordering_compare::
	 operator()): New function.
	(Output_section::sort_attached_input_sections): Use new sort function
	for .text.
	* output.h (Input_section_sort_section_name_special_ordering_compare):
	New struct.
	* testsuite/Makefile.am (text_section_grouping): Test option
	--no-text-reorder
	* testsuite/Makefile.in: Regenerate.
	* testsuite/text_section_grouping.sh: Check order of functions without
	default text reordering.
2013-01-24 18:49:55 +00:00
Alan Modra 431ed302a8 * testsuite/Makefile.am (final_layout_script.lds): Handle .got section.
* testsuite/Makefile.in: Regenerate.
2013-01-14 23:11:56 +00:00
Alan Modra 0ec6429be3 * testsuite/Makefile.am (MOSTLYCLEANFILES): Add various output files.
* testsuite/Makefile.in: Regenerate.
2013-01-14 12:56:39 +00:00
Ian Lance Taylor 0bf402d505 Fix mingw gold build with plugins enabled
* Makefile.am: Replace -ldl with @DLOPEN_LIBS@.
	* configure.ac: Export DLOPEN_LIBS and add headers check.
	* plugin.cc: Handle non-dlfcn case.
	* Makefile.in: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2013-01-11 14:36:36 +00:00
Sriraman Tallam 9e9143bc87 Make linker scripts and section ordering via --section-ordering-file or
linker plugins work. This patch lets linker scripts take precedence.

2013-01-09  Sriraman Tallam  <tmsriram@google.com>

	* output.h (sort_attached_input_sections): Change to be public.
	* script-sections.cc
	(Output_section_definition::set_section_addresses): Sort
	attached input sections according to section order before linker
	script assigns section addresses.
	(Orphan_output_section::set_section_addresses): Sort
	attached input sections according to section order before linker
	script assigns section addresses.
	* Makefile.am (final_layout.sh): Use a simple linker script to
	check if section ordering still works.
	* Makefile.in: Regenerate.
2013-01-10 00:18:15 +00:00
Cary Coutant 3d587466ef gold/
* testsuite/Makefile.am (CXXLINK_S): New macro.
	(debug_msg_so.err, debug_msg_ndebug.err): Use CXXLINK_S.
	* testsuite/Makefile.in: Regenerate.
2013-01-04 23:50:27 +00:00
Sriraman Tallam 28f2a4ac6f Group text sections with prefixes .text.unlikely,.text.hot and .text.startup
by default.


2012-12-18  Sriraman Tallam  <tmsriram@google.com>

	* layout.cc (Layout::is_section_name_prefix_grouped): New function.
	* layout.h (Layout::is_section_name_prefix_grouped): New function.
	* output.cc (Output_section::add_input_section): Check if section
	name contains special prefix.  Keep input sections to sort such
	sections.
	(Output_section::Input_section_sort_section_order_index_compare
	 ::operator()): Group sections according to prefixes.
	* (Output_section::sort_attached_input_sections): Add condition
	to Input_section_entry constructor call.
	* testsuite/Makefile.am (text_section_grouping): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/text_section_grouping.cc: New file.
	* testsuite/text_section_grouping.sh: New file.
2012-12-19 02:55:15 +00:00
Cary Coutant 59965708ea gold/
* testsuite/Makefile.am (exception_separate_shared_12_test): Add
    	--no-as-needed flag.
    	(exception_separate_shared_12_test): Likewise.
    	(incremental_copy_test): Likewise.
    	* testsuite/Makefile.in: Regenerate.
2012-12-15 01:55:08 +00:00
Ian Lance Taylor ae2eea65c6 * configure.ac (HAVE_ZLIB): Use AM_ZLIB instead of AC_SEARCH_LIBS.
Use $ac_cv_header_zlib_h = yes as the condition in AM_CONDITIONAL.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2012-12-07 04:28:52 +00:00
H.J. Lu b2490a7b4f Add final_layout_sequence.txt to MOSTLYCLEANFILES
* testsuite/Makefile.am (MOSTLYCLEANFILES): Add
	final_layout_sequence.txt.
	* testsuite/Makefile.in: Regenerated.
2012-10-26 00:50:05 +00:00
H.J. Lu aa54351297 Strip out -Wp,-D_FORTIFY_SOURCE= for gold tests
* testsuite/Makefile.am (COMPILE1): New variable. Renamed from
	COMPILE generated by automake.
	(LINK1): Likewise.
	(CXXCOMPILE1): Likewise.
	(CXXLINK1): Likewise.
	(COMPILE): Strip out -Wp,-D_FORTIFY_SOURCE= from COMPILE1.
	(LINK): Likewise.
	(CXXCOMPILE): Likewise.
	(CXXLINK): Likewise.
	* testsuite/Makefile.in: Regenerated.
2012-10-25 22:50:54 +00:00
Cary Coutant 35c813e224 gold/
* testsuite/Makefile.am (TEST_OBJCOPY): New macro.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/dwp_test.h: New source file.
	* testsuite/dwp_test_1.cc: New source file.
	* testsuite/dwp_test_1.s: New source file.
	* testsuite/dwp_test_1.sh: New source file.
	* testsuite/dwp_test_1b.cc: New source file.
	* testsuite/dwp_test_1b.s: New source file.
	* testsuite/dwp_test_2.cc: New source file.
	* testsuite/dwp_test_2.s: New source file.
	* testsuite/dwp_test_2.sh: New source file.
	* testsuite/dwp_test_main.cc: New source file.
	* testsuite/dwp_test_main.s: New source file.
2012-10-24 02:32:15 +00:00
Alan Modra 864a1b5697 * configure.ac (FN_PTRS_IN_SO_WITHOUT_PIC): False for powerpc.
* configure: Regenerate.
	* testsuite/Makefile.am (final_layout.stdout): Pass --synthetic to nm.
	(plugin_final_layout.stdout): Likewise.
	(memory_test): Set page sizes to 0x1000.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/discard_locals_test.sh: Add FIXME comment.
	* testsuite/justsyms_exec.c: Disable function test for powerpc64.
	* testsuite/pr14265.t: Add .got output section statement.
	* testsuite/script_test_2.t: Likewise.
	* testsuite/script_test_3.t: Likewise.
	* testsuite/script_test_4.t: Likewise.
	* testsuite/script_test_5.t: Likewise.
	* testsuite/script_test_6.t: Likewise.
	* testsuite/script_test_7.t: Likewise.
	* testsuite/script_test_9.t: Likewise.
2012-09-05 11:01:43 +00:00
Sriraman Tallam 16164a6b00 Patch adds support to allow plugins to map selected subset of sections to unique
segments.


2012-08-24  Sriraman Tallam  <tmsriram@google.com>

	* gold.cc (queue_middle_tasks): Call layout again when unique
	segments for sections is desired.
	* layout.cc (Layout::Layout): Initialize new members.
	(Layout::get_output_section_flags): New function.
	(Layout::choose_output_section): Call get_output_section_flags.
	(Layout::layout): Make output section for mapping to a unique segment.
	(Layout::insert_section_segment_map): New function.
	(Layout::attach_allocated_section_to_segment): Make unique segment for
	output sections marked so.
	(Layout::segment_precedes): Check for unique segments when sorting.
	* layout.h (Layout::Unique_segment_info): New struct.
	(Layout::Section_segment_map): New typedef.
	(Layout::insert_section_segment_map): New function.
	(Layout::get_output_section_flags): New function.
	(Layout::is_unique_segment_for_sections_specified): New function.
	(Layout::set_unique_segment_for_sections_specified): New function.
	(Layout::unique_segment_for_sections_specified_): New member.
	(Layout::section_segment_map_): New member.
	* object.cc (Sized_relobj_file<size, big_endian>::do_layout):
	Rename is_gc_pass_one to is_pass_one.
	Rename is_gc_pass_two to is_pass_two.
	Rename is_gc_or_icf to is_two_pass.
	Check for which pass based on whether symbols data is present.
	Make it two pass when unique segments for sections is desired.
	* output.cc (Output_section::Output_section): Initialize new
	members.
	* output.h (Output_section::is_unique_segment): New function.
	(Output_section::set_is_unique_segment): New function.
	(Output_section::is_unique_segment_): New member.
	(Output_section::extra_segment_flags): New function.
	(Output_section::set_extra_segment_flags): New function.
	(Output_section::extra_segment_flags_): New member.
	(Output_section::segment_alignment): New function.
	(Output_section::set_segment_alignment): New function.
	(Output_section::segment_alignment_): New member.
	(Output_segment::Output_segment): Initialize is_unique_segment_.
	(Output_segment::is_unique_segment): New function.
	(Output_segment::set_is_unique_segment): New function.
	(Output_segment::is_unique_segment_): New member.
	* plugin.cc (allow_unique_segment_for_sections): New function.
	(unique_segment_for_sections): New function.
	(Plugin::load): Add new functions to transfer vector.
	* Makefile.am (plugin_final_layout.readelf.stdout): Add readelf output.
	* Makefile.in: Regenerate.
	* testsuite/plugin_final_layout.sh: Check if unique segment
	functionality works.
	* testsuite/plugin_section_order.c (onload): Check if new interfaces
	are available.
	(allow_unique_segment_for_sections): New global.
	(unique_segment_for_sections): New global.
	(claim_file_hook): Call allow_unique_segment_for_sections.
	(all_symbols_read_hook): Call unique_segment_for_sections.


2012-08-24  Sriraman Tallam  <tmsriram@google.com>

	* plugin-api.h (ld_plugin_allow_unique_segment_for_sections):
	New interface.
	(ld_plugin_unique_segment_for_sections): New interface.
	(LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS): New enum val.
	(LDPT_UNIQUE_SEGMENT_FOR_SECTIONS): New enum val.
	(tv_allow_unique_segment_for_sections): New member.
	(tv_unique_segment_for_sections): New member.
2012-08-24 18:35:35 +00:00
Nick Clifton b9b2ae8bbf PR ld/14265
* script-sections.cc (Sections_element::output_section_name): Add
	keep return parameter.
	(Output_section_element::match_name): Add keep return parameter.
	Return the value of the keep_ member.
	* script-sections.h (class Output_section): Update
	output_section_name prototype.
	* layout.cc (Layout::keep_input_section): New public member
	function.
	(Layout::choose_output_section): Pass keep parameter to
	output_section_name.
	* layout.h (class Layout): Add keep_input_section.
	* object.cc (Sized_relobj_file::do_layout): Check for kept input
	sections.
	* testsuite/Makefile.am: Add a test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/pr14265.c: Source file for the test.
	* testsuite/pr14265.t: Linker script for the test.
	* testsuite/pr14265.sh: Shell script for the test.

	* ld-gc/gc.exp: Add a new test.
	* ld-gc/pr14265.c: Source file for the new test.
	* ld-gc/pr14265.t: Linker script for the new test.
	* ld-gc/pr14265.d: Expected symbol dump.
2012-08-14 08:31:57 +00:00
Cary Coutant f1415016b6 2012-07-18 Cary Coutant <ccoutant@google.com>
PR gold/14344
	* configure.ac: Add check for -gpubnames support.
	* configure: Regenerate.
	* testsuite/Makefile.am (gdb_index_test_1): Add check for -gpubnames
	support; force -gno-pubnames.
	(gdb_index_test_2, gdb_index_test_3): Add check for -gpubnames
	support.
	(gdb_index_test_4): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/gdb_index_test_1.sh: Refactor code into common file.
	* testsuite/gdb_index_test_2.sh: Likewise.
	* testsuite/gdb_index_test_3.sh: Don't look for space after colon.
	* testsuite/gdb_index_test_4.sh: New script.
	* testsuite/gdb_index_test_comm.sh: New script with common code;
	don't look for space after colon.
2012-07-19 00:19:35 +00:00
Mark Wielaard 57923f48a1 gold: Handle DW_AT_high_pc as offset from DW_AT_low_pc in gdb-index.cc.
* dwarf_reader.cc (Dwarf_die::address_attribute): New function.
        * dwarf_reader.h (Dwarf_die::address_attribute): Likewise.
        * gdb-index.cc (Gdb_index_info_reader::record_cu_ranges): Handle
        DW_AT_high_pc as offset from DW_AT_low_pc.

        * testsuite/Makefile.am (gdb_index_test_3.sh): New test case.
        * testsuite/Makefile.in: Regenerate.
        * testsuite/gdb_index_test_3.c: New test source file.
        * testsuite/gdb_index_test_3.sh: New test source file.
2012-05-01 19:12:21 +00:00
David S. Miller 661d7a80a2 gold: Build Gold IFUNC tests with -fPIC/-fPIE instead of -fpic/-fpie.
gold/

	* Makefile.am: Build IFUNC tests with -fPIC and -fPIE instead of
	-fpic and -fpie respectively.
	* Makefile.in: Regenerate.
2012-04-17 02:09:42 +00:00
Cary Coutant c1027032c2 2012-03-21 Cary Coutant <ccoutant@google.com>
* Makefile.am: Add gdb-index.cc, gdb-index.h.
	* Makefile.in: Regenerate.
	* dwarf_reader.cc (Sized_elf_reloc_mapper::do_initialize): New function.
	(Sized_elf_reloc_mapper::symbol_section): New function.
	(Sized_elf_reloc_mapper::do_get_reloc_target): New function.
	(make_elf_reloc_mapper): New function.
	(Dwarf_abbrev_table::clear_abbrev_codes): New function.
	(Dwarf_abbrev_table::do_read_abbrevs): New function.
	(Dwarf_abbrev_table::do_get_abbrev): New function.
	(Dwarf_ranges_table::read_ranges_table): New function.
	(Dwarf_ranges_table::read_range_list): New function.
	(Dwarf_pubnames_table::read_section): New function.
	(Dwarf_pubnames_table::read_header): New function.
	(Dwarf_pubnames_table::next_name): New function.
	(Dwarf_die::Dwarf_die): New function.
	(Dwarf_die::read_attributes): New function.
	(Dwarf_die::skip_attributes): New function.
	(Dwarf_die::set_name): New function.
	(Dwarf_die::set_linkage_name): New function.
	(Dwarf_die::attribute): New function.
	(Dwarf_die::string_attribute): New function.
	(Dwarf_die::int_attribute): New function.
	(Dwarf_die::uint_attribute): New function.
	(Dwarf_die::ref_attribute): New function.
	(Dwarf_die::child_offset): New function.
	(Dwarf_die::sibling_offset): New function.
	(Dwarf_info_reader::check_buffer): New function.
	(Dwarf_info_reader::parse): New function.
	(Dwarf_info_reader::do_parse): New function.
	(Dwarf_info_reader::do_read_string_table): New function.
	(Dwarf_info_reader::lookup_reloc): New function.
	(Dwarf_info_reader::get_string): New function.
	(Dwarf_info_reader::visit_compilation_unit): New function.
	(Dwarf_info_reader::visit_type_unit): New function.
	(Sized_dwarf_line_info::Sized_dwarf_line_info): Use
	Sized_elf_reloc_mapper.
	(Sized_dwarf_line_info::symbol_section): Remove function.
	(Sized_dwarf_line_info::read_relocs): Use Sized_elf_reloc_mapper.
	(Sized_dwarf_line_info::read_line_mappings): Remove object
	parameter, adjust callers.
	(Sized_dwarf_line_info::format_file_lineno): Fix type of cast.
	* dwarf_reader.h: Include <sys/types.h>.
	(class Track_relocs): Remove forward declaration.
	(class Elf_reloc_mapper): New class.
	(class Sized_elf_reloc_mapper): New class.
	(class Dwarf_abbrev_table): New class.
	(class Dwarf_range_list): New class.
	(class Dwarf_ranges_table): New class.
	(class Dwarf_pubnames_table): New class.
	(class Dwarf_die): New class.
	(class Dwarf_info_reader): New class.
	(Sized_dwarf_line_info::read_line_mappings): Remove object parameter.
	(Sized_dwarf_line_info::symbol_section): Remove member function.
	* dynobj.h (Sized_dynobj::do_section_contents): Refactor code from
	base class.
	* gdb-index.cc: New source file.
	* gdb-index.h: New source file.
	* incremental.cc (Sized_relobj_incr::do_layout): Track .debug_info
	and .debug_types sections, call Layout::add_to_gdb_index.
	(Sized_relobj_incr::do_section_name): Implement.
	(Sized_relobj_incr::do_section_contents): Adjust parameter list and
	return type; Implement.
	(Sized_incr_dynobj::do_section_contents): Adjust parameter list and
	return type.
	* incremental.h (Sized_relobj_incr::do_section_contents): Adjust
	parameter list and return type.
	(Sized_incr_dynobj::do_section_contents): Likewise.
	* layout.cc: Include gdb-index.h.
	(Layout::Layout): Initialize gdb_index_data_.
	(Layout::init_fixed_output_section): Check for .gdb_index section.
	(Layout::add_to_gdb_index): New function. Instantiate.
	* layout.h: Add forward declaration for class Gdb_index.
	(Layout::add_to_gdb_index): New member function.
	(Layout::gdb_index_data_): New data member.
	* main.cc: Include gdb-index.h.
	(main): Print statistics for gdb index.
	* object.cc (Object::section_contents): Move code into
	do_section_contents.
	(need_decompressed_section): Check for sections needed when building
	gdb index.
	(build_compressed_section_map): Likewise.
	(Sized_relobj_file::do_read_symbols): Need local symbols when building
	gdb index.
	(Sized_relobj_file::do_layout): Track .debug_info and .debug_types
	sections; call Layout::add_to_gdb_index.
	(Sized_relobj_file::do_decompressed_section_contents): Call
	do_section_contents directly.
	* object.h (Object::do_section_contents): Adjust parameter list and
	return type.
	(Object::do_decompressed_section_contents): Call do_section_contents
	directly.
	(Sized_relobj_file::do_section_contents): Adjust parameter list and
	return type.
	* options.h (class General_options): Add --gdb-index option.
	* plugin.cc (Sized_pluginobj::do_section_contents): Adjust parameter
	list and return type.
	* plugin.h (Sized_pluginobj::do_section_contents): Likewise.
	* reloc.h (Track_relocs::checkpoint): New function.
	(Track_relocs::reset): New function.

	* testsuite/Makefile.am (gdb_index_test_1.sh, gdb_index_test_2.sh):
	New test cases.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/gdb_index_test.cc: New test source file.
	* testsuite/gdb_index_test_1.sh: New test source file.
	* testsuite/gdb_index_test_2.sh: New test source file.
2012-03-21 19:02:22 +00:00
Doug Kwan 647f15745a 2012-03-19 Doug Kwan <dougkwan@google.com>
* arm.cc (Target_arm::do_define_standard_symbols): New method.
 	(Target_arm::do_finalize_sections): Remove code which defines
	__exidx_start and __exidx_end.  Make symbol table parameter
	anonymous as it is not used.
	* gold.cc (queue_middle_tasks): Call target hook to define any
	target-specific symbols.
	* target.h (Target::define_standard_symbols): New method.
	(Target::do_define_standard_symbols): Same.
	* testsuite/Makefile.am (arm_exidx_test): Dump relocations also.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/arm_exidx.s: Generate data relocations for __exidx_start
	and __exidx_end.
	* testsuite/arm_exidx_test.sh: Check that no unused dynamic
	relocations are generated for __exidx_start and __exidx_end.
2012-03-19 23:54:07 +00:00
Doug Kwan 7c6109da4a 2012-03-16 Doug Kwan <dougkwan@google.com>
* testsuite/Makefile.am: Disable test initpri3b.
	* testsuite/Makefile.in: Regenerate.
2012-03-17 01:33:19 +00:00
Cary Coutant 7b5de7eeac * testsuite/Makefile.am (initpri2): Add --ctors-in-init-array option.
* testsuite/Makefile.in: Regenerate.
2012-02-16 19:37:34 +00:00
Cary Coutant c2c7840a42 * int_encoding.cc (read_unsigned_LEB_128): Replaced with inline
definition and ...
	(read_unsigned_LEB_128_x): ... this new function.
	(read_signed_LEB_128): Replaced with inline definition and ...
	(read_signed_LEB_128_x): ... this new function.
	* int_encoding.h  (read_unsigned_LEB_128_x): New function.
	(read_unsigned_LEB_128): Add inline definition.
	(read_signed_LEB_128_x): New function.
	(read_signed_LEB_128): Add inline definition.
	* testsuite/Makefile.am (leb128_unittest): New unit test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/leb128_unittest.cc: New unit test.
2012-01-25 07:34:55 +00:00
Doug Kwan 2c339f710d 2011-11-09 Doug Kwan <dougkwan@google.com>
PR gold/13362
	* arm.cc (Arm_scan_relocatable_relocs::Default_scan_relocatable_relocs):
	Use unaligned 4-byte relocs for static 32-bit data as required by EABI.
	* reloc.h (Relocatable_relocs::Reloc_strategy): New enum
	RELOC_ADJUST_FOR_SECTION_4_UNALIGNED.
	(Relocate_functions::rel_unaligned): New.
	(Relocate_functions::rel32_unaligned): New.
	* target-reloc.h (relocate_for_relocatable): Add code to handle
	RELOC_ADJUST_FOR_SECTION_4_UNALIGNED.
	* testsuite/Makefile.am (arm_unaligned_reloc_r.stdout,
	arm_unaligned_reloc_r): New targets.
	* testsuite/Makefile.in: Regenerate.
	* arm_unaligned_reloc.sh: Check unaligned relocs in relocatable
	linking.
2011-11-10 00:41:53 +00:00
Ian Lance Taylor a8e2273bba * arm.cc (Target_arm::may_use_v5t_interworking): Check whether
we are working around the ARM1176 Erratum.
	* options.h (General_options::fix_arm1176): Add option.
	* testsuite/Makefile.am: Add testcases, and keep current ones
	working.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/arm_fix_1176.s: New file.
	* testsuite/arm_fix_1176.sh: Likewise.
2011-11-03 03:38:34 +00:00
Ian Lance Taylor cd6eab1c16 * arm.cc (Target_arm::Target_arm): Remove initialisation of
may_use_blx_.
	(Target_arm::may_use_blx): Remove method.
	(Target_arm::set_may_use_blx): Likewise.
	(Target_arm::may_use_v4t_interworking): New method.
	(Target_arm::may_use_v5t_interworking): Likewise.
	(Target_arm::may_use_blx_): Remove member variable.
	(Arm_relocate_functions::arm_branch_common): Check for v5T
	interworking.
	(Arm_relocate_functions::thumb_branch_common): Likewise.
	(Reloc_stub::stub_type_for_reloc): Likewise.
	(Target_arm::do_finalize_sections): Correct interworking checks.
	* testsuite/Makefile.am: Add new tests.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/arm_farcall_arm_arm.s: New test.
	* testsuite/arm_farcall_arm_arm.sh: Likewise.
	* testsuite/arm_farcall_arm_thumb.s: Likewise.
	* testsuite/arm_farcall_arm_thumb.sh: Likewise.
	* testsuite/arm_farcall_thumb_arm.s: Likewise.
	* testsuite/arm_farcall_thumb_arm.sh: Likewise.
	* testsuite/arm_farcall_thumb_thumb.s: Likewise.
	* testsuite/arm_farcall_thumb_thumb.sh: Likewise.
2011-11-02 19:11:48 +00:00
Sriraman Tallam f0558624db 2011-09-29 Sriraman Tallam <tmsriram@google.com>
* layout.h (section_order_map_): New member.
	(get_section_order_map): New member function.
	* output.cc (Output_section::add_input_section): Check for patterns
	only when --section-ordering-file is specified.
	* gold.cc (queue_middle_tasks): Delay updating order of sections till
	output_sections have been formed.
	* layout.cc (Layout_Layout): Initialize section_order_map_.
	* plugin.cc (update_section_order): Store order in order_map. Do not
	update the order.
	* testsuite/Makefile.am: Add test case for plugin_final_layout.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/plugin_section_order.c: New file.
	* testsuite/plugin_final_layout.cc: New file.
	* testsuite/plugin_final_layout.sh: New file.
2011-09-29 23:45:57 +00:00
Ian Lance Taylor dc87f62014 * configure.ac: Add new --with-gold-ldadd and --with-gold-ldflags
configuration options.
	* configure: Regenerate.
	* Makefile.am: Handle GOLD_LDADD and GOLD_LDFLAGS.
	* Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2011-09-23 15:02:32 +00:00
Cary Coutant ebb300b244 * configure.ac: Check for glibc support for gnu_indirect_function
support with static linking, setting automake conditional
	IFUNC_STATIC.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

	* testsuite/Makefile.am (ifuncmain1static, ifuncmain2static)
	(ifuncmain4static, ifuncmain5static, ifuncmain7static): Add check
	for IFUNC_STATIC.
	* testsuite/Makefile.in: Regenerate.
2011-09-14 01:29:01 +00:00
Cary Coutant 1206d0d514 * incremental.cc (Sized_relobj_incr::do_layout): Call
report_comdat_group for kept comdat sections.
	* testsuite/Makefile.am (incremental_comdat_test_1): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/incr_comdat_test_1.cc: New source file.
	* testsuite/incr_comdat_test_2_v1.cc: New source file.
	* testsuite/incr_comdat_test_2_v2.cc: New source file.
	* testsuite/incr_comdat_test_2_v3.cc: New source file.
2011-09-14 01:10:43 +00:00
Cary Coutant 8ea8cd50dd * layout.cc (Free_list::allocate): Provide guarantee of minimum
remaining hole size when allocating.
	(Layout::make_output_section): Set fill methods for debug sections.
	* layout.h (Free_list::Free_list_node): Move from private to
	public.
	(Free_list::set_min_hole_size): New function.
	(Free_list::begin, Free_list::end): New functions.
	(Free_list::min_hole_): New data member.
	* output.cc: Include dwarf.h.
	(Output_fill_debug_info::do_minimum_hole_size): New function.
	(Output_fill_debug_info::do_write): New function.
	(Output_fill_debug_line::do_minimum_hole_size): New function.
	(Output_fill_debug_line::do_write): New function.
	(Output_section::Output_section): Initialize new data member.
	(Output_section::set_final_data_size): Ensure patch space is larger
	than minimum hole size.
	(Output_section::do_write): Fill holes in debug sections.
	* output.h (Output_fill): New class.
	(Output_fill_debug_info): New class.
	(Output_fill_debug_line): New class.
	(Output_section::set_free_space_fill): New function.
	(Output_section::free_space_fill_): New data member.
	* testsuite/Makefile.am (incremental_test_3): Add
	--incremental-patch option.
	(incremental_test_4): Likewise.
	(incremental_test_5): Likewise.
	(incremental_test_6): Likewise.
	(incremental_copy_test): Likewise.
	(incremental_common_test_1): Likewise.
	* testsuite/Makefile.in: Regenerate.
2011-08-27 01:28:18 +00:00
Cary Coutant c3f7b0e5a1 * gold/testsuite/Makefile.am (justsyms_exec): New testcase.
* gold/testsuite/Makefile.in: Regenerate.
	* gold/testsuite/justsyms_exec.c: New source file.
	* gold/testsuite/justsyms_lib.c: New source file.
2011-08-01 20:09:25 +00:00
Ian Lance Taylor d12a5ea8c9 * layout.cc (Layout::relaxation_loop_body): Only clear load_seg if
the -Ttext option is not 0 modulo the page size.  If we clear
	load_seg, clear phdr_seg too.
	* testsuite/Makefile.am (check_PROGRAMS): Add flagstest_o_ttext_1.
	(flagstest_o_ttext_1): New target.
	(check_DATA): Add flagstest_o_ttext_2.
	(flagstest_o_ttext_2): New target.
	* testsuite/Makefile.in: Rebuild.
2011-07-25 22:48:42 +00:00