Commit Graph

44 Commits

Author SHA1 Message Date
Alan Modra f31ae5b84b * merge.cc (Output_merge_string::do_add_input_section): Correct
scan for number of strings.  Rename vars to avoid shadowing.
	Include missing terminator in input_size_.
2013-05-03 09:30:24 +00:00
H.J. Lu d3a7cd45fd Restore empty string handling
* merge.cc (Output_merge_string<Char_type>::do_add_input_section):
	Restore empty string handling.
2013-05-01 19:45:27 +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 5dd8762ad1 * dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info):
Call Object::decompressed_section_contents.
	* dwarf_reader.h (Sized_dwarf_line_info::~Sized_dwarf_line_info):
	New dtor.
	(Sized_dwarf_line_info::buffer_start_): New data member.
	* merge.cc (Output_merge_data::do_add_input_section): Call
	Object::decompressed_section_contents.
	(Output_merge_string::do_add_input_section): Likewise.
	* object.cc (need_decompressed_section): New function.
	(build_compressed_section_map): Decompress sections needed later.
	(Sized_relobj_file::do_decompressed_section_contents): New function.
	(Sized_relobj_file::do_discard_decompressed_sections): New function.
	* object.h (Object::decompressed_section_contents): New function.
	(Object::discard_decompressed_sections): New function.
	(Object::do_decompressed_section_contents): New function.
	(Object::do_discard_decompressed_sections): New function.
	(Compressed_section_info): New type.
	(Compressed_section_map): Include decompressed section contents.
	(Sized_relobj_file::do_decompressed_section_contents): New function.
	(Sized_relobj_file::do_discard_decompressed_sections): New function.
2012-02-29 21:22:29 +00:00
Ian Lance Taylor 07a6059735 PR gold/12571
* options.h (class General_options): Add
	--ld-generated-unwind-info.
	* ehframe.cc (Fde::write): Add address parameter.  Change all
	callers.  If associated with PLT, fill in address and size.
	(Cie::set_output_offset): Only add merge mapping if there is an
	object.
	(Cie::write): Add address parameter.  Change all callers.
	(Eh_frame::add_ehframe_for_plt): New function.
	* ehframe.h (class Fde): Update declarations.  Move shndx_ and
	input_offset_ fields into union u_, with new plt field.
	(Fde::Fde): Adjust for new union field.
	(Fde::Fde) [Output_data version]: New constructor.
	(Fde::add_mapping): Only add merge mapping if there is an object.
	(class Cie): Update declarations.
	(class Eh_frame): Declare add_ehframe_for_plt.
	* layout.cc (Layout::layout_eh_frame): Break out code into
	make_eh_frame_section, and call it.
	(Layout::make_eh_frame_section): New function.
	(Layout::add_eh_frame_for_plt): New function.
	* layout.h (class Layout): Update declarations.
	* merge.cc (Merge_map::add_mapping): Add assertion.
	* i386.cc: Include "dwarf.h".
	(class Output_data_plt_i386): Make first_plt_entry,
	dyn_first_plt_entry, exec_plt_entry, and dyn_plt_entry const.  Add
	plt_eh_frame_cie_size, plt_eh_frame_fde_size, plt_eh_frame_cie,
	and plt_eh_frame_fde.
	(Output_data_plt_i386::Output_data_plt_i386): Align to 16-byte
	boundary.  Call add_eh_frame_for_plt if appropriate.
	* x86_64.cc: Include "dwarf.h".
	(class Output_data_plt_x86_64): Align to 16-byte boundary.  Make
	first_plt_entry, plt_entry and tlsdesc_plt_entry const.  Add
	plt_eh_frame_cie_size, plt_eh_frame_fde_size, plt_eh_frame_cie,
	and plt_eh_frame_fde.
	(Output_data_plt_x86_64::init): Call add_eh_frame_for_plt if
	appropriate.
2011-07-01 22:05:01 +00:00
Nick Clifton ca09d69af1 * archive.cc: Formatting fixes: Remove whitespace between
typename and following asterisk.  Remove whitespace between
        function name and opening parenthesis.
        * archive.h: Likewise.
        * arm.cc: Likewise.
        * attributes.cc: Likewise.
        * attributes.h: Likewise.
        * common.cc: Likewise.
        * copy-relocs.cc: Likewise.
        * dirsearch.h: Likewise.
        * dynobj.cc: Likewise.
        * ehframe.cc: Likewise.
        * ehframe.h: Likewise.
        * expression.cc: Likewise.
        * fileread.cc: Likewise.
        * fileread.h: Likewise.
        * gc.h: Likewise.
        * gold-threads.cc: Likewise.
        * gold.cc: Likewise.
        * i386.cc: Likewise.
        * icf.h: Likewise.
        * incremental-dump.cc: Likewise.
        * incremental.cc: Likewise.
        * layout.cc: Likewise.
        * layout.h: Likewise.
        * main.cc: Likewise.
        * merge.cc: Likewise.
        * merge.h: Likewise.
        * object.cc: Likewise.
        * object.h: Likewise.
        * options.cc: Likewise.
        * options.h: Likewise.
        * output.cc: Likewise.
        * output.h: Likewise.
        * plugin.cc: Likewise.
        * plugin.h: Likewise.
        * powerpc.cc: Likewise.
        * reloc.cc: Likewise.
        * script-c.h: Likewise.
        * script-sections.cc: Likewise.
        * script.cc: Likewise.
        * stringpool.cc: Likewise.
        * symtab.cc: Likewise.
        * symtab.h: Likewise.
        * target.cc: Likewise.
        * timer.cc: Likewise.
        * timer.h: Likewise.
        * version.cc: Likewise.
        * x86_64.cc: Likewise.
2010-08-25 08:36:54 +00:00
Cary Coutant fef830db38 * merge.cc (Output_merge_string::do_add_input_section): Count strings
to reserve space in merged_strings vector. Keep total input size
	for stats.
	(Output_merge_string::do_print_merge_stats): Print total input size.
	* merge.h (Output_merge_string): Add input_size_ field.
	* stringpool.cc (Stringpool_template::string_length): Move
	implementations out of Stringpool_template class and place in
	stringpool.h.
	* stringpool.h (string_length): Move out of Stringpool_template.
2010-08-03 20:38:09 +00:00
Cary Coutant 7689733114 * merge.h (Output_merge_string::Merged_string): Remove object, shndx,
string, and length fields.
	(Output_merge_string::Merged_strings_list): New type.
	(Output_merge_string::Merged_strings_lists): New typedef.
	(Output_merge_string): Replace merged_strings_ with
	merged_strings_lists_.
	* merge.cc (Output_merge_string::do_add_input_section): Allocate new
	Merged_strings_list per input object and section.  Don't store pointer
	to the string.  Don't store length with each merged string entry.
	(Output_merge_string::finalize_merged_data): Loop over list of merged
	strings lists.  Recompute length of each merged string.
2010-07-21 21:03:54 +00:00
Cary Coutant a2e4736229 * compressed_output.cc (zlib_decompress): New function.
(get_uncompressed_size): New function.
	(decompress_input_section): New function.
	* compressed_output.h (get_uncompressed_size): New function.
	(decompress_input_section): New function.
	* dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info)
	Handle compressed debug sections.
	* layout.cc (is_compressed_debug_section): New function.
	(Layout::output_section_name): Map compressed section names to
	canonical names.
	* layout.h (is_compressed_debug_section): New function.
	(is_debug_info_section): Recognize compressed debug sections.
	* merge.cc: Include compressed_output.h.
	(Output_merge_data::do_add_input_section): Handle compressed
	debug sections.
	(Output_merge_string::do_add_input_section): Handle compressed
	debug sections.
	* object.cc: Include compressed_output.h.
	(Sized_relobj::Sized_relobj): Initialize new data members.
	(build_compressed_section_map): New function.
	(Sized_relobj::do_read_symbols): Handle compressed debug sections.
	* object.h (Object::section_is_compressed): New method.
	(Object::do_section_is_compressed): New method.
	(Sized_relobj::Compressed_section_map): New type.
	(Sized_relobj::do_section_is_compressed): New method.
	(Sized_relobj::compressed_sections_): New data member.
	* output.cc (Output_section::add_input_section): Handle compressed
	debug sections.
	* reloc.cc: Include compressed_output.h.
	(Sized_relobj::write_sections): Handle compressed debug sections.
2010-07-12 17:59:58 +00:00
Doug Kwan 0439c7962a 2010-05-23 Doug Kwan <dougkwan@google.com>
* arm.cc (Arm_input_section::do_output_offset): Use convert_types
	instead of a cast.
	(Target_arm::apply_cortex_a8_workaround): Rewrite a conditional branch
	with a direct branch, not a conditional branch, to a stub.
	* merge.cc (Output_merge_base::record_input_section): New method
	defintion.
	(Output_merge_data::do_add_input_section): Record input section if
	keeps-input-sections flag is set.
	(Output_merge_string::do_add_input_section): Ditto.
	* merge.h (Output_merge_base::Output_merge_base): Initialize new data
	members KEEPS_INPUT_SECTIONS_, FIRST_RELOBJ_, FIRST_SHNDX_ and
	INPUT_SECTIONS_.
	(Output_merge_base::keeps_input_sections,
	Output_merge_base::set_keeps_input_sections,
	Output_merge_base::first_relobj, Output_merge_base::first_shndx): New
	method definitions.
	(Output_merge_base::Input_sections): New type declaration.
	(Output_merge_base::input_sections_begin,
	Output_merge_base::input_sections_end,
	Output_merge_base::do_set_keeps_input_sections): New method definitions.
	(Output_merge_base::bool keeps_input_sections_,
	Output_merge_base::first_relobj_, Output_merge_base::first_shndx_,
	Output_merge_base::input_sections_): New data members.
	(Output_merge_data::do_set_keeps_input_sections): New method
	defintion.
	(Output_merge_string::do_set_keeps_input_sections): Ditto.
	* output.cc (Output_section::Input_section::relobj): Move method
	defintion from class declaration to here and handle merge sections.
	(Output_section::Input_section::shndx): Ditto.
	(Output_section::Output_section): Remove initializations of removed
	data members and initialize new data member LOOKUP_MAPS_.
	(Output_section::add_input_section): Set keeps-input-sections flag
	for a newly created merge output section as appropriate.  Adjust code
	to use Output_section_lookup_maps class.
	(Output_section::add_relaxed_input_section): Adjst code for lookup
	maps code refactoring.
 	(Output_section::add_merge_input_section): Add a new parameter
	KEEPS_INPUT_SECTION.  Adjust code to use Output_section_lookup_maps
	class.  If adding input section to a newly created merge output
	section fails, remove the new merge section.
	(Output_section::convert_input_sections_in_list_to_relaxed_input_sections):
	Adjust code for use of the Output_section_lookup_maps class.
 	(Output_section::find_merge_section): Ditto.
	(Output_section::build_lookup_maps): New method defintion.
 	(Output_section::find_relaxed_input_section): Adjust code to use
	Output_section_lookup_maps class.
	(Output_section::get_input_sections): Export merge sections.  Adjust
	code to use Output_section_lookup_maps class.
	(Output_section:::add_script_input_section): Adjust code to use
	Output_section_lookup_maps class.  Update lookup maps for merge
	sections also.
	(Output_section::discard_states): Use Output_section_lookup_maps.
	(Output_section::restore_states): Same.
	* output.h (Merge_section_properties): Move class defintion out of
	Output_section.
	(Output_section_lookup_maps): New class.
	(Output_section::Input_section::is_merge_section): New method
	defintion.
	(Output_section::Input_section::relobj): Move defintion out of class
	defintion.  Declare method only.
	(Output_section::Input_section::shndx): Ditto.
	(Output_section::Input_section::output_merge_base): New method defintion.
     	(Output_section::Input_section::u2_.pomb): New union field.
	(Output_section::Merge_section_by_properties_map,
	Output_section::Output_section_data_by_input_section_map,
	Output_section::Ouptut_relaxed_input_section_by_input_section_map):
	Remove types.
   	(Output_section::add_merge_input_section): Add new parameter
	KEEPS_INPUT_SECTIONS.
	(Output_section::build_lookup_maps): New method declaration.
	(Output_section::merge_section_map_,
	Output_section::merge_section_by_properties_map_,
	Output_section::relaxed_input_section_map_,
	Output_section::is_relaxed_input_section_map_valid_): Remove data
	members.
	(Output_section::lookup_maps_): New data member.
2010-05-23 07:43:39 +00:00
Doug Kwan 6bf924b0ab 2010-04-08 Doug Kwan <dougkwan@google.com>
* merge.cc (Output_merge_data::set_final_data_size): Handle empty
	Output_merge_data.
	* output.cc (Output_section::add_merge_input_section): Simplify
	code and return status of Output_merge_base::add_input_section.
	Update merge section map only if Output_merge_base::add_input_section
	returns true.
2010-04-09 00:04:30 +00:00
Ian Lance Taylor 2ea9794110 Revert -Wshadow changes, all changes from:
2009-12-11  Doug Kwan  <dougkwan@google.com>
	2009-12-11  Nick Clifton  <nickc@redhat.com>
	* configure.ac: Remove -Wshadow when setting WARN_CXXFLAGS.
2009-12-14 19:53:05 +00:00
Nick Clifton 91d6fa6a03 Add -Wshadow to the gcc command line options used when compiling the binutils.
Fix up all warnings generated by the addition of this switch.
2009-12-11 13:42:17 +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 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 780e49c563 * merge.cc (Object_merge_map::get_output_offset): Remove inline
qualifier.
2008-04-08 18:46:43 +00:00
Ian Lance Taylor ebdbb4583d Update copyright years. Update language files. 2008-03-13 21:04:21 +00:00
Ian Lance Taylor 1d6531cfad Don't crash if we change the address of the .eh_frame section after we
find its size.
2008-03-13 20:58:11 +00:00
Ian Lance Taylor a9a60db689 Speed up relocations against local symbols in merged sections. 2007-12-21 21:19:45 +00:00
Ian Lance Taylor 1e9836570f Update comments about output offsets and merged input sections. 2007-12-20 16:27:34 +00:00
Ian Lance Taylor 4106a0814a Remove one inline. 2007-12-20 01:32:10 +00:00
Ian Lance Taylor 8f00aeb8a6 Make functions on hot path inline. Remove a mistaken virtual
declaration.
2007-12-20 01:29:04 +00:00
Ian Lance Taylor 2030fba084 Move Stringpool offsets into a chunked_vector indexed by keys. 2007-12-19 01:23:46 +00:00
Ian Lance Taylor c0873094f5 Use string length when available when calling Stringpool. Compare
pointers first when looking up Stringpool entries.
2007-12-19 00:29:28 +00:00
Ian Lance Taylor 38c5e8b493 Print statistics about merge sections with --stats. 2007-12-18 21:24:10 +00:00
Ian Lance Taylor 8383303e0a Add section_size_type and section_offset_type, use them to replace a
lot of instances of off_t.
2007-12-18 00:48:04 +00:00
Ian Lance Taylor 281b8327ae Minor speedup to Output_merge_string::do_add_input_section. 2007-12-15 01:01:48 +00:00
Ian Lance Taylor 96803768f1 Compress all debug sections. 2007-12-01 06:34:12 +00:00
Ian Lance Taylor 9a0910c33e From Craig Silverstein: Add support for compressing .debug_str section. 2007-11-30 00:35:27 +00:00
Ian Lance Taylor 27bc2bce09 Clean up setting address and section offset. 2007-11-29 20:10:17 +00:00
Ian Lance Taylor 4625f782a5 Rework merge_map for speed. 2007-11-27 06:13:33 +00:00
Ian Lance Taylor d8a8897678 Make Merge_key_less operator() inline. 2007-11-22 00:45:46 +00:00
Ian Lance Taylor 730cdc88f7 Generate a complete exception frame header. Discard duplicate
exception frame information.
2007-11-09 07:00:15 +00:00
Ian Lance Taylor 291eaac6ab From Craig Silverstein: add cast to avoid warning. 2007-10-20 04:35:43 +00:00
Ian Lance Taylor fa1bd4fb25 Fix handling of wide string merge sections. 2007-10-19 23:33:37 +00:00
Ian Lance Taylor 87f9577614 Correctly handle alignment in merge sections. 2007-10-18 17:46:23 +00:00
Ian Lance Taylor 75f2446ec3 Run all error handling through an Errors object. Delete output file
on error.
2007-10-14 06:49:14 +00:00
Ian Lance Taylor cfd73a4e26 Add an option for Stringpools to not copy strings. 2007-10-12 06:06:34 +00:00
Ian Lance Taylor cec9d2f362 From Craig Silverstein: don't get confused if the same file name
occurs in an archive.
2007-10-10 06:33:56 +00:00
Ian Lance Taylor 9eb9fa57c2 Add cache parameter to get_view. Discard uncached views on unlock.
Fix bug this exposed in archive armap symbol name handling.
2007-09-25 17:50:26 +00:00
Ian Lance Taylor c077629be8 Avoid dereferencing map->end(). 2007-09-23 03:16:47 +00:00
Ian Lance Taylor 6cb15b7f89 Add licensing text to every source file. 2007-09-22 21:02:10 +00:00
Ian Lance Taylor 42e3fe0dd9 We don't need a hash table mapping input locations to strings. 2007-09-22 05:38:12 +00:00
Ian Lance Taylor b8e6aad960 Add support for SHF_MERGE sections. 2007-05-16 17:42:48 +00:00