Commit Graph

1707 Commits

Author SHA1 Message Date
Cary Coutant db4c959472 Fix error from previous patch where tosize and tovalue were redefined
in a block, shadowing the declarations outside the block.

gold/
	PR gold/17432
	* resolve.cc (Symbol_table::resolve): Fix local shadowing error.
2014-09-30 16:06:50 -07:00
Kito Cheng cd6da0366d Fix SysV-style hash table when --hash-style=both.
When --hash-style-both is used, gold currently builds the sysv hash
table first, then the gnu hash table. Building the gnu hash table
renumbers the dynamic symbol table, invalidating the sysv hash
table. This patch reverses the order in which the hash tables are
build so that both hash tables are correct.

gold/
	PR gold/13597
	* layout.cc (Layout::create_dynamic_symtab): Build gnu-style
	hash table before sysv-style hash table.
2014-09-30 14:36:46 -07:00
Sriraman Tallam 5f77241211 2014-09-29 Sriraman Tallam <tmsriram@google.com>
* options.h (--pic-executable): Add negative to alias to -no-pie.
2014-09-29 17:30:54 -07:00
Cary Coutant 5efeedf61e Fix handling of relocations against TLS section symbols.
Gold doesn't handle relocations against the section symbol for a TLS
section correctly. Instead of using the offset of the section relative
to the TLS segment, it uses the address of the actual section.  This
patch checks for section symbols for TLS sections, and treats them
the same as TLS symbols.

gold/
	PR gold/16773
	* object.cc (Sized_relobj_file): Compute value of section symbols
	for TLS sections the same as TLS symbols.
2014-09-26 13:34:27 -07:00
Cary Coutant 1707f18344 Fix problem where TLS common symbols are not allocated properly during LTO.
The plugin API doesn't provide a way for the claimed file handler to
identify a TLS symbol, so when adding a common TLS symbol, gold
mistakenly places the symbol in the non-TLS commons list, and does
not override it when we see the replacement symbol that is marked
as TLS. Consequently, we allocate the TLS common symbol as a regular
common, and, if it's the only TLS in the program, we'll give an
internal error because we haven't allocated a TLS segment.

This patch fixes the problem by removing an exclusion where common
symbols would not override the placeholder symbols, but checking to
see if the size needs adjusting (the original reason for the exclusion).
Furthermore, we need to avoid putting placeholder symbols in the common
list, and wait until we see a real common symbol with a type we can
trust.

gold/
	PR gold/17432
	* resolve.cc (Symbol_table::resolve): Override common placeholder
	symbols, but adjust sizes.
	* symtab.cc (Symbol_table::add_from_object): Don't add placeholder
	symbols to common lists.
2014-09-25 21:49:42 -07:00
Alan Modra 00cac886aa Regen gold POTFILES.in
* po/POTFILES.in: Regenerate.
2014-09-24 19:14:38 +09:30
Cary Coutant 71b9b91bce Add PR reference to ChangeLog entry.
2014-09-23  Taiju Tsuiki  <tzik@google.com>
            Cary Coutant  <ccoutant@google.com>

gold/
	PR gold/14860
	* gold.cc (queue_final_tasks): Add Write_sections_task as a blocker
	on input_sections_blocker.
	* layout.cc (Write_sections_task::locks): Unblock
	input_sections_blocker_.
	* layout.h (Write_sections_task::Write_sections_task): Add
	input_sections_blocker.
	* testsuite/Makefile.am (exception_x86_64_bnd_test): Add gcctestdir/ld
	to DEPENDENCIES.
	* testsuite/Makefile.in: Regenerate.
2014-09-23 23:35:36 -07:00
Cary Coutant 635aa30e3a Fix race condition causing assert in Eh_frame_hdr::do_sized_write().
2014-09-23  Taiju Tsuiki  <tzik@google.com>
            Cary Coutant  <ccoutant@google.com>

gold/
	* gold.cc (queue_final_tasks): Add Write_sections_task as a blocker
	on input_sections_blocker.
	* layout.cc (Write_sections_task::locks): Unblock
	input_sections_blocker_.
	* layout.h (Write_sections_task::Write_sections_task): Add
	input_sections_blocker.
	* testsuite/Makefile.am (exception_x86_64_bnd_test): Add gcctestdir/ld
	to DEPENDENCIES.
	* testsuite/Makefile.in: Regenerate.
2014-09-23 23:20:57 -07:00
Rafael Ávila de Espíndola c0c71592f7 A a testcase for common symbol handling with plugins.
2014-09-18  Rafael Ávila de Espíndola <rafael.espindola@gmail.com>

	* testsuite/Makefile.am (plugin_test_10): New test.
	* testsuite/Makefile.in: Regenerate
	* testsuite/plugin_common_test_2.c (c1): Align to 8.
	* testsuite/plugin_test_10.sh: New file.
2014-09-18 13:58:16 -04:00
Cary Coutant 6d610fa7ce Regenerate gold/Makefile.in. 2014-09-17 15:12:21 -07:00
Rafael Ávila de Espíndola 6168c2a1c6 Fix handling of common symbols with plugins.
gold/ChangeLog:
2014-09-17  Rafael Ávila de Espíndola <rafael.espindola@gmail.com>

	* plugin.cc (Sized_pluginobj::do_add_symbols): Ignore isym->size.
	* resolve.cc (Symbol_table::resolve): Don't override common symbols
	during the replacement phase.
2014-09-17 17:53:49 -04:00
Jing Yu 3a53193762 Add tls support to gold aarch64 backend.
elfcpp/ChangeLog:
2014-09-17  Han Shen  <shenhan@google.com>
	* aarch64.h (R_AARCH64_TLS_DTPREL64): Switch enum value with ...
	(R_AARCH64_TLS_DTPMOD64): ... enum value.

gold/ChangeLog:
2014-09-17  Han Shen  <shenhan@google.com>
	    Jing Yu  <jingyu@google.com>
        * aarch64-reloc.def: Add TLSGD_ADR_PAGE21, TLSGD_ADD_LO12_NC,
        TLSDESC_ADR_PAGE21, TLSDESC_LD64_LO12, TLSDESC_ADD_LO12, TLSDESC_CALL.
        * aarch64.cc (Target_aarch64): Add data members
        got_irelative_, got_tlsdesc_, rela_irelative_, got_mod_index_offset_,
        tlsdesc_reloc_info_, tls_base_symbol_defined_. Initialize them in
        constructor.
        (Target_aarch64::do_reloc_symbol_index): New method.
        (Target_aarch64::do_reloc_addend): New method.
        (Target_aarch64::add_tlsdesc_info): New method.
        (Target_aarch64::do_dynsym_value): New method.
        (Target_aarch64::do_make_data_plt): Add new parameters: got,
        got_irelative. Pass them to Output_data_plt_aarch64_standard.
        (Target_aarch64::make_data_plt): Add new parameters: got,
        got_irelative. Pass them to do_make_data_plt.
        (Target_aarch64::Relocate): Add skip_call_tls_get_addr_ variable.
        (Target_aarch64::Relocate:tls_gd_to_le): New method.
        (Target_aarch64::Relocate:tls_ie_to_le): New method.
        (Target_aarch64::Relocate:tls_desc_gd_to_le): New method.
        (Target_aarch64::Relocate:tls_desc_gd_to_ie): New method.
        (Target_aarch64::got_tlsdesc_section): New method.
        (Target_aarch64::make_local_ifunc_plt_entry): New method.
        (Target_aarch64::define_tls_base_symbol): New method.
        (Target_aarch64::reserve_tlsdesc_entries): New method.
        (Target_aarch64::got_mod_index_entry): New method.
        (Target_aarch64::rela_tlsdesc_section): New method.
        (Target_aarch64::rela_irelative_section): New method.
        (Target_aarch64::Tlsdesc_info): New struct.
        (Target_aarch64::got_section): Create .got.plt space for IRELATIVE
        relocations and tlsdesc relocations.
        (Target_aarch64::optimize_tls_reloc): Implement method.
        (Output_data_plt_aarch64): Add member variables: tlsdesc_rel_, got_,
        got_irelative_, irelative_count_, tlsdesc_got_offset_. Initialize them
        in constructor.
        (Output_data_plt_aarch64::reserve_tlsdesc_entry): New method.
        (Output_data_plt_aarch64::has_tlsdesc_entry): New method.
        (Output_data_plt_aarch64::get_tlsdesc_got_offset): New method.
        (Output_data_plt_aarch64::get_tlsdesc_plt_offset): New method.
        (Output_data_plt_aarch64::rela_tlsdesc): New method.
        (Output_data_plt_aarch64::rela_irelative): New method.
        (Output_data_plt_aarch64::entry_count): Count IRELATIVE relocations.
        (Output_data_plt_aarch64::first_plt_entry_offset): Add const attribute.
        (Output_data_plt_aarch64::get_plt_tlsdesc_entry_size): New method.
        (Output_data_plt_aarch64::fill_tlsdesc_entry): New method.
        (Output_data_plt_aarch64::do_get_plt_tlsdesc_entry_size): New method.
        (Output_data_plt_aarch64::do_fill_tlsdesc_entry): New method.
        (Output_data_plt_aarch64_standard): New member variables:
        plt_tlsdesc_entry_size, tlsdesc_plt_entry.
        (Output_data_plt_aarch64_standard::Output_data_plt_aarch64_standard):
        New parameter: got, got_irelative.
        (Output_data_plt_aarch64_standard::do_get_plt_entry_size): New method.
        (Output_data_plt_aarch64_standard::do_fill_tlsdesc_entry): New method.
        (Output_data_plt_aarch64::do_write): Replace got_address with
        gotplt_address. Add irelative_count_ to count. Write tlsdesc entry.
        (AArch64_relocate_functions::update_movnz): New method.
        (AArch64_relocate_functions): Correct format.
        (AArch64_relocate_functions::movnz): New method.
        (Target_aarch64::Scan::local): Correct format. Move r_sym, got to
        before the switch. Add new cases to switch.
        Check ie_to_le relaxation on tlsie relocations. Add code handling
        tlsgd tlsdesc cases.
        (Target_aarch64::Scan::global): Move arp to front. Do copy_reloc when
        needed. Add new cases to switch. Insert dynamic RELATIVE relocation
        when needed. Add code handling tlsgd, tlsie, tlsdesc cases.
        Call reloc_name_in_error_message to print unsupported reloc.
        (Target_aarch64::make_plt_section): Pass got_ and got_irelative_ to
        make_data_plt.
        (Target_aarch64::do_finalize_sections): Emit relocs to save COPY
        relocs. Fill in some more dynamic tags.
        (Target_aarch64::Relocate::relocate): Handle tlsgd, tlsdesc relocs.
        Skip call tls_get_addr when tlsgd is relaxed.
        (Target_aarch64::Relocate::relocate_tls): Correct format. Add code
        handling tlsgd, tlsdesc relocs, and tls gd->le, ie->le, tlsdesc->le,
        tlsdesc->ie relaxation.
2014-09-17 14:24:10 -07:00
Sasa Stankovic 62661c935d Add NaCl (NativeClient) specific classes Target_mips_nacl and
Target_selector_mips_nacl.

gold/
	* mips.cc (Target_mips_nacl): New class.
	(Target_selector_mips_nacl): New class.
	(target_selector_mips32): Rename from target_selector_mips32be and use
	Target_selector_mips_nacl instead of Target_selector_mips.
	(target_selector_mips32el): Rename from target_selector_mips32 and use
	Target_selector_mips_nacl instead of Target_selector_mips.
	(target_selector_mips64): Rename from target_selector_mips64be and use
	Target_selector_mips_nacl instead of Target_selector_mips.
	(target_selector_mips64el): Rename from target_selector_mips64 and use
	Target_selector_mips_nacl instead of Target_selector_mips.
	(Target_mips::mips_info): Add const attribute.
2014-09-03 09:44:11 -07:00
Cary Coutant 54674d3893 Make Elf_file::section_name() a const function, so that it can be used in
places where we have only a const Elf_file*.

elfcpp/
	* elfcpp_file.h (Elf_file::shnum): New const function.
	(Elf_file::shstrndx): New const function.
	(Elf_file::large_shndx_offset): New const function.
	(Elf_file::section_name): Add const attribute.
	(Elf_file::section_header_offset): Likewise.

gold/
	* dwp.cc (Sized_relobj_dwo::do_section_name): Add const attribute.
	* dynobj.h (Sized_dynobj::do_section_name): Likewise.
	* incremental.cc (Sized_relobj_incr::do_section_name): Likewise.
	(Sized_incr_dynobj::do_section_name): Likewise.
	* incremental.h (Sized_relobj_incr::do_section_name): Likewise.
	(Sized_incr_dynobj::do_section_name): Likewise.
	* object.h (Object::section_name): Likewise.
	(Object::do_section_name): Likewise.
	(Sized_relobj_file::do_section_name): Likewise.
	* plugin.cc (Sized_pluginobj::do_section_name): Likewise.
	* plugin.h (Sized_pluginobj::do_section_name): Likewise.
2014-09-02 15:44:58 -07:00
Cary Coutant 9860cbcfb6 Fix problem with optimization of .eh_frame section and --sort-section option.
When --sort-section=name is used, gold will sort the linker-generated contents
of .eh_frame (after optimization) after the endcap provided by crtendS.o.
This causes two problems: the .eh_frame_hdr section is generated assuming that
the optimized .eh_frame contents will be placed at the very beginning of the
section, and the endcap no longer appears at the end of the section.

This patch fixes the first problem by adjusting FDE offsets to take into account
the actual starting offset within the output section, and fixes the second
problem by sorting linker-generated (Output_section_data) sections based on the
name of the output section.

gold/
	PR gold/17005
	* ehframe.cc (Fde::write): Add output_offset parameter.
	(Cie::write): Likewise.
	(Eh_frame::set_final_data_size): Account for offset within output
	section.
	(Eh_frame::do_sized_write): Likewise.
	* ehframe.h (Fde::write): Add output_offset parameter.
	(Cie::write): Likewise.
	* output.cc (Output_section::Input_section_sort_entry): Remove
	section_has_name_; add output_section_name parameter. Use
	output section name for non-input sections.
	(Output_section::Input_section_sort_entry::section_has_name): Remove.
	(Output_section::Input_section_sort_entry::section_has_name_): Remove.
	(Output_section::Input_section_sort_compare): Remove logic for
	sections without names.
	(Output_section::Input_section_sort_init_fini_compare): Likewise.
	(Output_section::Input_section_sort_section_prefix_special_ordering_compare):
	Likewise.
	(Output_section::Input_section_sort_section_name_compare): Likewise.
2014-09-02 14:49:18 -07:00
Han Shen 8e33481e13 The 3rd patch for aarch64 gold.
This enables -
1. static linking hello world
2. limited support for TLSIE and TLSLE
3. limited support for linking shared library, linking executable against shared
   library.

gold/ChangeLog
2014-08-29 Han Shen <shenhan@google.com>
       Jing Yu <jingyu@google.com>

    * aarch64-reloc-property.cc
    (AArch64_reloc_property_table::reloc_name_in_error_message): Fix bug in
    reference reloc property in the table.
    * aarch64-reloc.def: Add TLSLE reloc types and fix some errors in
    3 other entries.
    * aarch64.cc: (Output_data_got_aarch64::add_static_reloc):
    2 new overloaded methods.
    (Output_data_got_aarch64::do_write): Add code to write out
    static relocs.
    (class Output_data_got_aarch64::Static_reloc): New class to wrap
    static relocs.
    (Output_data_got_aarch64::static_relocs): New vector to
    hold static relocs.
    (Target_aarch64::TCB_SIZE): New const static memeber.
    (Target_aarch64::tcb_size): New method.
    (Target_aarch64::Relocate::relocate): Add code handling new reloc types.
    (Target_aarch64::Relocate::relocate_tls): New method.
    (Target_aarch64::Scan::local): Add code handling new reloc types.
    (Target_aarch64::Scan::global): Add code handling new reloc types.
2014-08-29 17:53:03 -07:00
Sriraman Tallam 8123365312 Add option -no-pie. 2014-08-13 18:40:19 -07:00
Jing Yu 9363c7c3ad gold aarch64 patch to enable linking hello_wolrd.
elfcpp/ChangeLog:
2014-08-08  Han Shen  <shenhan@google.com>

	* aarch64.h (withdrawn): Replaced with R_AARCH64_withdrawn.

2014-08-08  Jing Yu  <jingyu@google.com>
	    Han Shen  <shenhan@google.com>

	* Makefile.am (HFILES): Add aarch64-reloc-property.h.
	(DEFFILES): add aarch64-reloc.def.
	(TARGETSOURCES): Add aarch64-reloc-property.cc.
	(ALL_TARGETOBJS): Add aarch64-reloc-property.$(OBJEXT).
	* Makefile.in: Regenerate.
	* aarch64-reloc-property.cc: New file.
	* aarch64-reloc-property.h: New file.
	* aarch64-reloc.def: New file.
	* aarch64.cc: Include aarch64-reloc-property.h. Replace spaces
	with tab to make the format consistent.
	(Output_data_got_aarch64::symbol_table_): New method.
	(Target_aarch64::do_plt_address_for_global): New method.
	(Target_aarch64::do_plt_address_for_local): New method.
	(Target_aarch64::do_select_as_default_target): New method.
	(Target_aarch64::do_make_data_plt): New method.
	(Target_aarch64::make_data_plt): New method.
	(Output_data_plt_aarch64::has_irelative_section): New method.
	(Output_data_plt_aarch64::address_for_global): New method.
	(Output_data_plt_aarch64::address_for_local): New method.
	(Output_data_plt_aarch64::irelative_rel_): New parameter.
	(Output_data_plt_aarch64::add_entry): Implement contents.
	(Output_data_plt_aarch64::set_final_data_size): Fix typo.
	(Output_data_plt_aarch64::do_write): Remove useless got_base. Set
	the got_pov entry to plt0.
	(Output_data_plt_aarch64_standard::do_fill_first_plt_entry):
	Implement contents.
	(Output_data_plt_aarch64_standard::do_fill_plt_entry): Implement.
	(AArch64_howto): New struct.
	(aarch64_howto[]): New static const array.
	(AArch64_relocate_functions): New class.
	(Target_aarch64::Scan::get_reference_flags): Remove method.
	(Target_aarch64::Scan::local): Implement to support a few relocations.
	(Target_aarch64::Scan::global): Implement to support a few relocations.
	(Target_aarch64::make_plt_section): Implement contents.
	(Target_aarch64::make_plt_entry): Implement contents.
	(Target_aarch64::do_finalize_sections): Implement contents.
	(Target_aarch64::Relocate::relocate): Implement a few relocations.
	(Target_aarch64::relocate_section): Implement contents.
2014-08-08 14:18:35 -07:00
Alan Modra ad9fe6c108 Modify new gold test to pass on powerpc64le
* testsuite/defsym_test.sh: Allow ppc64le localentry annotation.
2014-08-06 22:15:48 +09:30
Alan Modra 7cd4e5b756 Warn for gold on lto objects without plugin
PR 13227
	* symtab.cc (Symbol_table::add_from_relobj): Warn on __gnu_lto_slim.
2014-08-06 12:40:00 +09:30
Sriraman Tallam 7c16d96edb Fix ChangeLog entry:
2014-07-21  Sriraman Tallam  <tmsriram@google.com>

	* object.cc (Relobj::is_section_name_included): Add
	".rodata.nptl_version" to not garbage collect this section.
2014-07-21 11:15:38 -07:00
Sriraman Tallam 5ad9b0a773 2014-07-21 Sriraman Tallam <tmsriram@google.com>
* object.cc (Relobj::is_section_name_included): Add
	".rodata.nptl_version".
2014-07-21 11:12:05 -07:00
Cary Coutant e051745c83 Fix --defsym to copy symbol attributes.
Alan Modra committed a patch to Gnu ld to fix a problem encountered on
PPC where the --defsym option wasn't copying the st_other bits to the
newly-defined symbol.

    https://sourceware.org/ml/binutils/2014-07/msg00094.html

Gold has the same problem, and additionally wasn't copying the symbol type.
This patch fixes both problems, by copying the symbol type, visibility, and
the remaining st_other bits to the new symbol for --defsym=sym1=sym2
assignments.

gold/
	* expression.cc (struct Expression::Expression_eval_info): Add
	new fields type_pointer, vis_pointer, and nonvis_pointer.
	(Expression::eval_maybe_dot): Add type_pointer, vis_pointer, and
	nonvis_pointer parameters. Adjust all calls.
	(Symbol_expression::value): Update type, visibility, and nonvis bits
	in caller.
	* script.cc (Symbol_assignment::sized_finalize): Update type,
	visibility, and remaining st_other bits for new symbol.
	* script.h: (Expression::eval_maybe_dot): Add type_pointer,
	vis_pointer, and nonvis_pointer parameters.
	* symtab.h (Symbol::set_type): New method.

	* testsuite/Makefile.am (defsym_test): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/defsym_test.c: New file.
	* testsuite/defsym_test.sh: New file.
2014-07-08 22:52:37 -07:00
Cary Coutant f35c4853cc Fix internal error with LTO on ARM.
This prevents the target-specific do_read_symbols methods from being called
twice when do_layout_deferred_sections needs to layout an .eh_frame section.

gold/
	PR gold/15639
	* dynobj.h (Sized_dynobj::base_read_symbols): New method.
	* dynobj.cc (Sized_dynobj::do_read_symbols): Move body to...
	(Sized_dynobj::base_read_symbols): ...new method.
	* object.h (Sized_relobj_file::base_read_symbols): New method.
	* object.cc (Sized_relobj_file::do_read_symbols): Move body to...
	(Sized_relobj_file::base_read_symbols): ...new method.
	* arm.cc (Arm_relobj::do_read_symbols): Call base_read_symbols.
	* mips.cc: (Mips_relobj::do_read_symbols): Likewise.
	* powerpc.cc (Powerpc_dynobj::do_read_symbols): Likewise.
2014-07-08 10:44:09 -07:00
Alan Modra 2900af2d0a Update gold POTFILES.in
for recent aarch64 and mips support.

	* po/POTFILES.in: Regenerate
2014-07-04 12:32:14 +09:30
Jing Yu 053a4d680b 2014-07-02 Jing Yu <jingyu@google.com>
Initial patch to enable gold aarch64 backend.

    This patch is just a skeleton which almost does nothing.
    It does not support ILP32 now.

    gold/ChangeLog:
	* aarch64.cc: New file
	* Makefile.am (TARGETSOURCES): Add aarch64.cc
	(ALL_TARGETOBJS): Add aarch64.$(OBJEXT)
	* Makefile.in: Regenerate.
	* configure.tgt: Add entries for aarch64*.
	* configure.ac:  Likewise.
	* configure: Likewise.

    elfcpp/ChangeLog:
	* aarch64.h: New file. New enums for aarch64-elf64 relocations.
	* elfcpp.h (EM_AARCH64, SHT_AARCH64_ATTRIBUTES, PT_AARCH64_ARCHEXT,
	PT_AARCH64_UNWIND): New enum constant.
2014-07-02 16:21:23 -07:00
Alan Modra 7b54904566 Fix undefined symbol errors from mips.cc
* symtab.cc (Symbol::should_add_dynsym_entry): Don't make inline.
2014-06-27 10:42:28 +09:30
Cary Coutant cb818dbff5 Fix dwp to allow intermediate .dwp files with no .debug_types sections.
gold/
	* dwp.cc (Dwo_file::read): Allow files with no .debug_types
	sections.
	(Dwo_file::sized_read_unit_index): Likewise.
2014-06-24 12:17:09 -07:00
Sasa Stankovic 9810d34d76 gold/
* mips.cc: New file.
	* Makefile.am (TARGETSOURCES): Add mips.cc
	(ALL_TARGETOBJS): Add mips.$(OBJEXT)
	* configure.tgt: Add entries for mips*.
	* configure.ac: Likewise.
	* Makefile.in: Regenerate.
	* configure: Likewise.
2014-06-23 12:02:10 -07:00
Cary Coutant 9baa787b14 Add check to keep from segfaulting on a corrupt .debug_pubnames section.
gold/
	* dwarf_reader.cc (Dwarf_pubnames_table::read_header): Check that
	unit_length is within section bounds.
2014-06-09 14:55:02 -07:00
Cary Coutant 8f89af0abe Print unattached sections in the link map.
gold/
	PR gold/16980
	* layout.cc (Layout::print_to_mapfile): Print unattached sections in
	map.
2014-06-09 12:58:48 -07:00
Alan Modra a47622ac1b Allow both signed and unsigned fields in PowerPC cmpli insn
There are legitimate reasons to allow a signed value in a cmpli insn
field, for example to test for a "stw r1,lock@sdarel(r13)" instruction
in user code, a kernel might use
	subis r3,r3,STW_R1_0R13@ha	# subtract off high part
	cmplwi r3,lock@sdarel		# is low part accessing lock?
Since the lock@sdarel may take a range of -32768 to 32767,
the allowed range of cmpli immediate must be at least [-32768,65535].

bfd/
	* elf32-ppc.c (ppc_elf_relocate_section): Treat field of cmpli
	insn as a bitfield; Use complain_overflow_bitfield.
	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
opcodes/
	* ppc-opc.c (UISIGNOPT): Define and use with cmpli.
gas/
	* config/tc-ppc.c (ppc_insert_operand): Handle PPC_OPERAND_SIGNOPT
	on unsigned fields.  Comment on PPC_OPERAND_SIGNOPT signed fields
	in 64-bit mode.
gold/
	* powerpc.cc (relocate): Treat field of cmpli insn as a bitfield.
2014-06-07 14:55:11 +09:30
Cary Coutant 4320c69198 Strip .debug_gnu_pubnames and .debug_gnu_pubtypes when building .gdb_index.
When not stripping those sections, there was a bug where gold was incorrectly
adjusting section-relative offsets by the offset of the input section within
the output section. That adjustment was both unnecessary and wrong, causing
gold to miss a number of debug entries that should have been added to
.gdb_index.  (With stripping, the adjustment was always 0, so the bug in
dwarf_reader.cc would have been hidden by the change to layout.cc.)

gold/
	* dwarf_reader.h (Dwarf_pubnames_table): Remove output_section_offset_.
	* dwarf_reader.cc (Dwarf_pubnames_table::read_section): Likewise.
	(Dwarf_pubnames_table::read_header): Likewise.
	* layout.cc (gdb_fast_lookup_sections): Add .debug_gnu_pubnames and
	.debug_gnu_pubtypes.
2014-06-06 16:24:30 -07:00
Joel Brobecker 270c993744 Make it easy to make --disable-werror the default for both binutils and gdb
The goal of this patch is to provide an easy way to make
--disable-werror the default when building binutils, or the parts
of binutils that need to get built when building GDB. In development
mode, we want to continue making -Werror the default with GCC.
But, when making releases, I think we want to make it as easy as
possible for regular users to successfully build from sources.

GDB already has this kind of feature to turn -Werror as well as
the use of the libmcheck library. As GDB Release Manager, I take
advantage of it to turn those off after having cut the branch.
I'd like to be able to do the same for the binutils bits. And
perhaps Tristan will want to do the same for his releases too
(not sure, binutils builders might be a little savvier than GDB
builders).

This patch introduces a new file, called development.sh, which
just sets a variable called $development. In our development branches
(Eg. "master"), it's set to true. But setting it to false would allow
us to change the default behavior of various development-related
features to be turned off; in this case, it turns off the use of
-Werror by default (use --enable-werror to turn it back on).

bfd/ChangeLog:

        * development.sh: New file.
        * warning.m4 (AM_BINUTILS_WARNINGS): Source bfd/development.sh.
        Make -Werror the default with GCC only if DEVELOPMENT is true.
        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add
        $(srcdir)/development.sh.
        * Makefile.in, configure: Regenerate.

binutils/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gas/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gold/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): New.
        * Makefile.in, configure: Regenerate.

gprof/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

ld/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

opcodes/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gdb/ChangeLog:

        * development.sh: Delete.
        * Makefile.in (config.status): Adjust dependency on development.sh.
        * configure.ac: Adjust development.sh source call.
        * configure: Regenerate.

gdb/gdbserver/ChangeLog:

        * configure.ac: Adjust development.sh source call.
        * Makefile.in (config.status): Adjust dependency on development.sh.
        * configure: Regenerate.

Tested on x86_64-linux by building two ways: One with DEVELOPMENT
set to true, and one with DEVELOPMENT set to false. In the first
case, I could see the use of -Werror, while it disappeared in
the second case.
2014-06-05 05:47:29 -07:00
Alan Modra 397998fc32 Support fusion for ELFv2 stubs
Power8 fuses addis,addi and addis,ld sequences when the target of the
addis is the same as the addi/ld.  Thus
    addis r12,r2,xxx@ha
    addi r12,r12,xxx@l / ld r12,xxx@l(r12)
is faster than
    addis r11,r2,xxx@ha
    addi r12,r11,xxx@l / ld r12,xxx@l(r11)
So use the form that allows fusion in plt call and branch stubs.

bfd/
	* elf64-ppc.c (ADDIS_R12_R2): Define.
	(build_plt_stub): Support fusion on ELFv2 stub.
	(ppc_build_one_stub): Likewise for plt branch stubs.
gold/
	* powerpc.cc (addis_12_2): Define.
	(Stub_table::do_write): Support fusion on ELFv2 stubs.
ld/testsuite/
	* ld-powerpc/elfv2exe.d: Update for changed plt call stubs.
gdb/
	* ppc64-tdep.c (ppc64_standard_linkage8): New.
	(ppc64_skip_trampoline_code): Recognise ELFv2 stub supporting fusion.
2014-06-03 10:55:29 +09:30
Alan Modra 61f5c66f62 Fix gold plugin_test failures on PowerPC64 ELFv2
readelf output for ELFv2 includes st_other bits specifying a
function's local entry offset.

	* testsuite/plugin_test.c (parse_readelf_line): Skip non-visibility
	st_other output.
2014-06-03 10:47:55 +09:30
Alan Modra f697178787 Fix PowerPC64 ELFv2 icf_safe failures
ELFv2 doesn't use .opd, so folding function code can't be allowed
in safe mode if a function's address might be taken.

	* powerpc.cc (Target_powerpc::local_reloc_may_be_function_pointer):
	Only ignore relocs on ELFv1.
	(Target_powerpc::global_reloc_may_be_function_pointer): Likewise.
2014-06-02 09:26:23 +09:30
Cary Coutant f6fb832249 Fix testsuite to use newly-built linker for ehdr_start_test_4, and fix
check script to look for the right binding.

gold/
	* testsuite/Makefile.am (ehdr_start_test_4): Fix typo in -B option.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/ehdr_start_test_4.sh: Look for "U" instead of "w".
2014-05-30 10:21:27 -07:00
H.J. Lu c23dd3426c Properly handle 64-bit GOT relocations
This patch fixes 2 issues:

1. Since the GOT offset is always negative, we need to use signed int
to support 64-bit GOT relocations.
2. R_X86_64_PLTOFF64 uses the address of GLOBAL_OFFSET_TABLE, which is
the address of the .got.plt section, not the .got section.
2014-05-27 12:20:18 -07:00
Alan Modra 5fe7ffdc98 Fix "overflow in PLT unwind data" warning
When linking statically, it's possible to hit this warning with IFUNC
or very large executables, due to .glink being unused.

	* powerpc.cc (do_plt_fde_location): Handle zero length .glink.
	Compare FDE contents with DW_CFA_nop rather than 0.
2014-05-15 18:37:43 +09:30
Sriraman Tallam a82bef932e With -pie and x86, the linker complains if it sees a PC-relative relocation
to access a global as it expects a GOTPCREL relocation.  This is really not
necessary as the linker could use a copy relocation to get around it.  This
patch enables copy relocations with pie.

Context:
This is useful because currently the GCC compiler with option -fpie makes
every extern global access go through the GOT. That is because the compiler
cannot tell if a global will end up being defined in the executable or not
and is conservative. This ends up hurting performance when the binary is linked
as mostly static where most of the globals do end up being defined in the
executable.  By allowing copy relocs with fPIE, the compiler need not generate
a GOTPCREL(GOT access) for any global access.  It can safely assume that all
globals will be defined in the executable and generate a PC-relative access
instead.  Gold can then create a copy reloc for only the undefined globals.

	gold/
	* symtab.h (may_need_copy_reloc): Remove check for position independent
	code.
	* x86_64.cc (Target_x86_64<size>::Scan::global): Add check for no
	position independence before pc absolute may_need_copy_reloc call.
	Add check for executable output befor pc relative may_need_copy_reloc
	call.
	* i386.cc: Ditto.
	* arm.cc: Ditto.
	* sparc.cc: Ditto.
	* tilegx.cc: Ditto.
	* powerpc.cc: Add check for no position independence before
	may_need_copy_reloc calls.
	* testsuite/pie_copyrelocs_test.cc: New file.
	* testsuite/pie_copyrelocs_shared_test.cc: New file.
	* Makefile.am (pie_copyrelocs_test): New test.
	* Makefile.in: Regenerate.
2014-05-13 10:55:11 -07:00
Sriraman Tallam 1642b4b337 Optimizing accesses to Globals with -fpie -pie:
With -pie and x86, the linker complains if it sees a PC-relative relocation
to access a global as it expects a GOTPCREL relocation.  This is really not
necessary as the linker could use a copy relocation to get around it.  This
patch enables copy relocations with pie.

Context:
This is useful because currently the GCC compiler with option -fpie makes
every extern global access go through the GOT. That is because the compiler
cannot tell if a global will end up being defined in the executable or not
and is conservative. This ends up hurting performance when the binary is linked
as mostly static where most of the globals do end up being defined in the
executable.  By allowing copy relocs with fPIE, the compiler need not generate
a GOTPCREL(GOT access) for any global access.  It can safely assume that all
globals will be defined in the executable and generate a PC-relative access
instead.  Gold can then create a copy reloc for only the undefined globals.
2014-05-13 10:33:59 -07:00
Martin Liška 53c6660516 2014-05-08 Martin Liška <mliska@suse.cz>
gold/
	* output.cc (Sized_relobj_file::do_layout): Fix typo in info message.
2014-05-08 15:23:53 -07:00
Cary Coutant 57b2284c63 Fix issue where first reserved word of GOT is not initialized if there
is no PLT.

gold/
	PR gold/16900
	* i386.cc (Output_data_got_plt_i386): New class.
	(Output_data_plt_i386::Output_data_plt_i386): Change type of got_plt
	parameter. Change all callers.
	(Output_data_plt_i386::layout_): Remove.
	(Output_data_plt_i386::got_plt_): Change type.
	(Target_i386::got_plt_): Change type. Change all references.
	(Target_i386::got_section): Create instance of new class.
	(Output_data_got_plt_i386::do_write): New function.
	* x86_64.cc (Output_data_got_plt_x86_64): New class.
	(Output_data_plt_x86_64::Output_data_plt_x86_64): Change type of got_plt
	parameter. Change all callers.
	(Output_data_plt_x86_64::layout_): Remove.
	(Output_data_plt_x86_64::got_plt_): Change type.
	(Target_x86_64::got_plt_): Change type. Change all references.
	(Target_x86_64::got_section): Create instance of new class.
	(Output_data_got_plt_x86_64::do_write): New function.
	(Output_data_plt_x86_64::do_write): Don't write reserved words in GOT.
	(Target_x86_64<size>::init_got_plt_for_update): Create instance of new
	class.
2014-05-06 14:29:42 -07:00
Cary Coutant 6b97515d17 Don't complain about the source language when we have pubnames/pubtypes info.
gold/
	* gdb-index.cc (Gdb_index_info_reader): Don't complain about language
	if we have pubnames/pubtypes.
2014-05-05 15:23:14 -07:00
Cary Coutant d1bddd3c4b Fix handling of __ehdr_start when it cannot be defined.
2014-05-02  Cary Coutant  <ccoutant@google.com>

	* defstd.cc (in_segment): Define __ehdr_start here...
	* layout.cc (Layout::finalize): ...Instead of here.  Set the
	output segment when known.
	* resolve.cc (Symbol::override_base_with_special): Remember
	the original binding.
	* symtab.cc (Symbol::set_output_segment): New function.
	(Symbol::set_undefined): New function.
	* symtab.h (Symbol::is_weak_undefined): Check original undef
	binding.
	(Symbol::is_strong_undefined): New function.
	(Symbol::set_output_segment): New function.
	(Symbol::set_undefined): New function.
	* target-reloc.h (is_strong_undefined): Remove.
	(issue_undefined_symbol_error): Call Symbol::is_weak_undefined.
	Check for hidden undefs.
	(relocate_section): Call Symbol::is_strong_undefined.

	* testsuite/Makefile.am (ehdr_start_test_1)
	(ehdr_start_test_2, ehdr_start_test_3)
	(ehdr_start_test_4, ehdr_start_test_5): New test cases.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/ehdr_start_def.cc: New source file.
	* testsuite/ehdr_start_test.cc: New source file.
	* testsuite/ehdr_start_test.t: New linker script.
	* testsuite/ehdr_start_test_4.sh: New shell script.
2014-05-02 16:33:43 -07:00
Cary Coutant bf2cc635e2 Add missing PR ref to ChangeLog entry. 2014-04-23 15:20:56 -07:00
Cary Coutant 7849f6d8dc Add missing break statement for case elfcpp::R_X86_64_PLTOFF64.
gold/
	* x86_64.cc (Target_x86_64::Relocate::relocate): Add missing break.
2014-04-23 15:19:05 -07:00
Cary Coutant 99fd8cfff7 Allow target to decide whether to include a section.
2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
	* layout.cc (Layout::include_section): Allow a target to decide
	whether to include a section.
	* target.h (Target::should_include_section): New function.
	(Target::do_should_include_section): New function.
2014-04-15 11:56:18 -07:00
Cary Coutant 91f43acd5d Allow target to derive from Copy_relocs class.
2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
	* copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Remove and
	inline into ...
	(Copy_relocs::emit): ... here.
	* copy-relocs.h (Copy_reloc_entry): Change from class to struct.
	(Copy_reloc_entry::make_copy_reloc): Change from private to protected.
	(Copy_reloc_entry::entries_): Change from private to protected.
2014-04-15 11:56:18 -07:00
Sriraman Tallam c4eb27e1db 2014-04-02 Sriraman Tallam <tmsriram@google.com>
* icf.cc (get_section_contents): Replace copies of reloc
	vectors with (const) references.
2014-04-02 17:07:47 -07:00
Cary Coutant ae447ddd12 Modify gold testsuite to disable plugins added by GCC driver.
GCC 4.8 now adds linker plugin options by default, which conflict with the
--incremental tests in the testsuite. This patch checks whether the compiler
supports the -fno-use-linker-plugin option, and adds it to all link
commands.

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

	* configure.ac (HAVE_PUBNAMES): Use C instead of C++.
	(HAVE_NO_USE_LINKER_PLUGIN): Check for -fno-use-linker-plugin.
	* configure: Regenerate.
	* testsuite/Makefile.am (OPT_NO_PLUGINS): New macro for
	-fno-use-linker-plugin.
	(LINK1, CXXLINK1): Add it to the link command.
	* testsuite/Makefile.in: Regenerate.
2014-04-02 15:04:36 -07:00
Alan Modra fa47fa9246 autoreconf
Regenerate Makefile.in in bfd, binutils, gas, gold, gprof, ld, opcodes.
Regenerate gas/config.in.
2014-03-12 15:02:00 +10:30
Cary Coutant 9b12c50063 Add function to set non-visibility part of st_other.
2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
	* symtab.h (Symbol::set_nonvis): New function.
2014-03-10 13:38:20 -07:00
Cary Coutant beacaa966b Add explicit instantiations for Sized_symbol::init_output_data.
2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
	* symtab.cc (Sized_symbol<32>::init_output_data):
	Instantiate the template.
	(Sized_symbol<64>::init_output_data): Likewise.
2014-03-10 13:36:40 -07:00
Cary Coutant 800d982336 Allow target to adjust dynamic symbol value.
2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
	* symtab.cc (Symbol_table::sized_write_globals): Allow a target to
	adjust dynamic symbol value.
	* target.h (Target::adjust_dyn_symbol): New function.
	(Target::do_adjust_dyn_symbol): New function.
2014-03-10 13:35:53 -07:00
Cary Coutant 918fc1f8d2 Allow target to add custom dynamic table entries.
2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
	* output.cc (Output_data_dynamic::Dynamic_entry::write):
	Get the value of DYNAMIC_CUSTOM dynamic entry.
	* output.h (Output_data_dynamic::add_custom): New function.
	(Dynamic_entry::Dynamic_entry): New constructor for DYNAMIC_CUSTOM
	dynamic entry.
	(enum Dynamic_entry::Classification): Add DYNAMIC_CUSTOM.
	* target.h (Target::dynamic_tag_custom_value): New function.
	(Target::do_dynamic_tag_custom_value): New function.
2014-03-10 13:34:53 -07:00
Cary Coutant 98ff923154 Allow target to set dynsym indexes.
2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
	* symtab.cc (Symbol_table::set_dynsym_indexes): Allow a target to set
	dynsym indexes.
	* target.h (Target::has_custom_set_dynsym_indexes): New function.
	(Target::do_has_custom_set_dynsym_indexes): New function.
	(Target::set_dynsym_indexes): New function.
	(Target::do_set_dynsym_indexes): New function.
2014-03-10 13:33:20 -07:00
Alan Modra b80eed39e2 Better overflow checking for powerpc64 relocations
R_PPC64_ADDR16 is used in three contexts:
- .short data relocation
- 16-bit signed insn fields, eg. addi
- 16-bit unsigned insn fields, eg. ori
In the first case we want to allow both signed and unsigned 16-bit
values, the latter two ought to error if the field exceeds the range
of values allowed for 16-bit signed and unsigned integers
respectively.  These conflicting requirements meant that ld had to
choose the least restrictive overflow checks, and thus it is possible
to construct testcases where an addi field overflows but is not
reported by ld.  Many relocations dealing with 16-bit insn fields have
this problem.  What's more, some relocations that are only ever used
for signed fields of instructions woodenly copied the lax overflow
checking of R_PPC64_ADDR16.

bfd/
	* elf64-ppc.c (ppc64_elf_howto_raw): Use complain_overflow_signed
	for R_PPC64_ADDR14, R_PPC64_ADDR14_BRTAKEN, R_PPC64_ADDR14_BRNTAKEN,
	R_PPC64_SECTOFF, R_PPC64_ADDR16_DS, R_PPC64_SECTOFF_DS,
	R_PPC64_REL16 entries.  Use complain_overflow_dont for R_PPC64_TOC.
	(ppc64_elf_relocate_section): Modify overflow test for 16-bit
	fields in instructions to signed/unsigned according to whether
	the field takes a signed or unsigned value.
gold/
	* powerpc.cc (Powerpc_relocate_functions::Overflow_check): Add
	CHECK_UNSIGNED, CHECK_LOW_INSN, CHECK_HIGH_INSN.
	(Powerpc_relocate_functions::has_overflow_unsigned): New function.
	(Powerpc_relocate_functions::has_overflow_bitfield,
	overflowed): Use the above.
	(Target_powerpc::Relocate::relocate): Correct overflow checking
	for a number of relocations.  Modify overflow test for 16-bit
	fields in instructions to signed/unsigned according to whether
	the field takes a signed or unsigned value.
2014-03-08 12:57:58 +10:30
Alan Modra 4b95cf5c0c Update copyright years 2014-03-05 22:16:15 +10:30
Alan Modra 45965137be Support R_PPC64_ADDR64_LOCAL
This adds support for "func@localentry", an expression that returns the
ELFv2 local entry point address of function "func".  I've excluded
dynamic relocation support because that obviously would require glibc
changes.

include/elf/
	* ppc64.h (R_PPC64_REL24_NOTOC, R_PPC64_ADDR64_LOCAL): Define.
bfd/
	* elf64-ppc.c (ppc64_elf_howto_raw): Add R_PPC64_ADDR64_LOCAL entry.
	(ppc64_elf_reloc_type_lookup): Support R_PPC64_ADDR64_LOCAL.
	(ppc64_elf_check_relocs): Likewise.
	(ppc64_elf_relocate_section): Likewise.
	* Add BFD_RELOC_PPC64_ADDR64_LOCAL.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
gas/
	* config/tc-ppc.c (ppc_elf_suffix): Support @localentry.
	(md_apply_fix): Support R_PPC64_ADDR64_LOCAL.
ld/testsuite/
	* ld-powerpc/elfv2-2a.s, ld-powerpc/elfv2-2b.s: New files.
	* ld-powerpc/elfv2-2exe.d, ld-powerpc/elfv2-2so.d: New files.
	* ld-powerpc/powerpc.exp: Run new test.
elfcpp/
	* powerpc.h (R_PPC64_REL24_NOTOC, R_PPC64_ADDR64_LOCAL): Define.
gold/
	* powerpc.cc (Target_powerpc::Scan::local, global): Support
	R_PPC64_ADDR64_LOCAL.
	(Target_powerpc::Relocate::relocate): Likewise.
2014-03-05 19:57:39 +10:30
Alan Modra 2c80b75360 Fix various copyright issues
binutils/
	* README: Add "Copyright Notices" paragraph.
gas/
	* config/bfin-lex-wrapper.c: Correct copyright date.
	* config/tc-frv.c: Correct copyright punctuation.
	* config/tc-ip2k.c: Likewise.
	* config/tc-iq2000.c: Likewise.
	* config/tc-mep.c: Likewise.
	* config/tc-tic4x.c: Likewise.
	* config/tc-tic4x.h: Likewise.
ld/testsuite/
	* ld-scripts/phdrs2.exp: Correct copyright punctuation.
	* ld-v850/v850.exp: Correct copyright typo.
opcodes/
	* i386-gen.c (process_copyright): Emit copyright notice on one line.
gold/
	* dwp.cc (print_version): Update copyright year to current.
2014-03-03 11:03:08 +10:30
Cary Coutant dd0c4e70fe Update ChangeLog from earlier patch. 2014-02-11 11:26:37 -08:00
Alan Modra c1c69e839e binutils potfiles regen
Adds nds32 files to POTFILES.in
2014-02-10 09:59:35 +10:30
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 1a221d3d9c Fix issues with gold undefined symbol diagnostics.
PR binutils/15435 complains that gold issues a visibility error for an
weak undefined symbol with hidden visibility. The message should be
suppressed if the symbol is a weak undef.

An earlier patch to add an extra note about key functions when a class's
vtable symbol is undefined missed a case where the reference to the
vtable came from a shared library. This patch moves the check to a
lower-level routine that catches both cases.

gold/

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

	* errors.cc (Errors::undefined_symbol): Move undef vtable symbol
	check to here.
	* target-reloc.h (is_strong_undefined): New function.
	(relocate_section): Move undef vtable symbol check from here.
	Check for is_strong_undefined.
2014-02-05 23:04:52 -08:00
Cary Coutant e889f0a4b1 Add missing gold/ChangeLog entry. 2014-02-05 22:59:17 -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 ec673e648c Add .gdb_index version 7 support.
This patch adds support for .gdb_index version 7, which adds several
flag bits to the symbol index.  It also fixes a problem where it did
not handle compressed debug sections correctly.

Tested with a google/gcc-4_8 branch compiler, which supports
the -ggnu-pubnames option to generate .debug_gnu_pubnames/pubtypes
tables. (We will submit that patch to GCC when stage 1 reopens.)

2014-01-28  Cary Coutant  <ccoutant@google.com>

	* gold/dwarf_reader.cc: include <utility> (for make_pair).
	(Dwarf_abbrev_table::do_read_abbrevs): Check for compressed
	debug sections.
	(Dwarf_ranges_table::read_ranges_table): Likewise.
	(Dwarf_pubnames_table::read_section): Check for GNU-style
	sections, and for compressed debug sections.
	(Dwarf_pubnames_table::read_header): Compute end address of table.
	(Dwarf_pubnames_table::next_name): Return flag_byte.  Check
	for end of list by offset, not by offset == 0.
	(Dwarf_info_reader::do_read_string_table): Check for compressed
	debug sections.
	* gold/dwarf_reader.h (Dwarf_pubnames_table::Dwarf_pubnames_table):
	Initialize new data members.
	(Dwarf_pubnames_table::next_name): return flag_byte.
	(Dwarf_pubnames_table::end_of_table_): New data member.
	(Dwarf_pubnames_table::is_gnu_style_): New data member.
	* gold/gdb-index.cc (gdb_index_version): Update to version 7.
	(Gdb_index_info_reader::read_pubtable): Read flag_byte.
	(Gdb_index_info_reader::read_pubnames_and_pubtypes): Don't
	read skeleton type unit DIEs.
	(Gdb_index::add_symbol): Add flag_byte; adjust all callers.
	(Gdb_index::do_write): Write flag_byte.
	* gold/gdb-index.h (Gdb_index::add_symbol): Add flags parameter.
	(Gdb_index::Cu_vector): Store flags along with cu indexes.
	* gold/testsuite/gdb_index_test_3.sh: Allow versions 4-7.
	* gold/testsuite/gdb_index_test_comm.sh: Likewise.
2014-01-28 15:36:00 -08:00
H.J. Lu 221fd5d598 Update copyright year to 2014
binutils/

	* version.c (print_version): Update copyright year to 2014.

gas/

	* as.c (parse_args): Update copyright year to 2014.

gold/

	* version.cc (print_version): Update copyright year to 2014.

ld/

	* ldver.c (ldversion): Update copyright year to 2014.

opcodes/

	* i386-gen.c (process_copyright): Update copyright year to 2014.
2014-01-08 05:48:12 -08:00
Ian Lance Taylor 6c09fb0ba1 * stringpool.cc (Stringpool_template::reserve): Add
HAVE_UNORDERED_MAP case.
	* stringpool.cc (Stringpool_template::print_stats): Likewise.
2013-12-19 21:54:43 -08:00
Cary Coutant 8356f2d009 Add configure checks for <unordered_set> and <unordered_map>.
gold/
	* configure.ac: Check for <unordered_set> and <unordered_map>.
	* config.in: Regenerate.
	* configure: Regenerate.
	* system.h: Use <unordered_set> and <unordered_map> if available.
2013-12-18 15:53:31 -08:00
Roland McGrath f2c7d7ee5b Use $(INSTALL_PROGRAM_ENV) consistently.
binutils/
	* Makefile.am (install-exec-local): Prefix libtool invocation with
	$(INSTALL_PROGRAM_ENV).
	* Makefile.in: Regenerate.

gas/
	* Makefile.am (install-exec-bindir): Prefix libtool invocation
	with $(INSTALL_PROGRAM_ENV).
	(install-exec-tooldir): Likewise.
	* Makefile.in: Regenerate.

gold/
	* Makefile.am (install-exec-local): Prefix $(INSTALL_PROGRAM) uses
	with $(INSTALL_PROGRAM_ENV).
	* Makefile.in: Regenerate.

ld/
	* Makefile.am (install-exec-local): Prefix libtool invocation with
	$(INSTALL_PROGRAM_ENV).
	* Makefile.in: Regenerate.
2013-12-10 15:19:50 -08:00
Cary Coutant 6632e8ccec Add check for which library is needed for dlopen.
gold/
	PR gold/16203
	* configure.ac: Add check for which library is needed for
	dlopen.
	* configure: Regenerate.
2013-11-22 15:47:18 -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
Alan Modra 4f65b40ee0 Add missing ChangeLog for 88b8e63904 2013-11-15 16:25:44 +10:30
Alan Modra 9055360d4a Fixes to powerpc64 gold ELFv2 support
* powerpc.cc (Target_powerpc::glink_section): Provide non-const
	accessor.
	(Target_powerpc::Branch_info::make_stub): Make global entry stubs.
	Only call ppc64_local_entry_offset for 64-bit.  Restrict
	symval_for_branch lookup to ELFv1.
	(Stub_table::add_plt_call_entry): Use unsigned int off.
	(Output_data_glink::Address, invalid_address): New.
	(Output_data_glink::add_eh_frame): Move out of line.  Add
	support for ELFv2.
	(Output_data_glink::add_global_entry, find_global_entry,
	global_entry_address): New functions.
	(Output_data_glink::global_entry_stubs_, end_branch_table_,
	ge_size): New variables.
	(Output_data_glink::set_final_data_size): Add global entry
	stub sizing.
	(Output_data_glink::do_write): Write global entry stubs.
	(Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Add target
	parameter.  Return true for ELFv2.  Adjust callers.
	(Target_powerpc::Scan::local, global): Restrict opd lookup to
	ELFv1.  Similarly for ifunc and dynamic relocation processing
	specific to ELFv1.  Recognize that symbols are defined on
	their plt entries for ELFv2.
	(Target_powerpc::symval_for_branch): Assert if called for
	ELFv2 or ppc32.
	(Target_powerpc::Relocate::relocate): Use global entry plt
	stub for symbol value if such exists on ELFv2.
	(Target_powerpc::Relocate::relocate): Don't call
	symval_for_branch when ELFv2.  Do adjust for local entry
	offset when ELFv2.
	(Target_powerpc::do_dynsym_value): Set symbols to global entry
	plt stub for ELFv2.
	(Target_powerpc::do_plt_address_for_global): Similarly.
2013-11-15 10:36:34 +10:30
Cary Coutant cafdd5697b Revert "Fix race condition while building EH frame header."
This reverts commit 7cdd7d57e6.
2013-11-14 13:15:55 -08:00
Cary Coutant 94e49e160d Add --verify-only option to DWP.
gold/
	* dwp.cc (Dwo_file_entry): New type.
	(File_list): Use Dwo_file_entry.
	(Dwo_file::verify): New function.
	(Dwo_file::verify_dwo_list): New function.
	(Dwo_file::sized_verify_dwo_list): New function.
	(Dwo_name_info_reader::visit_compilation_unit): Add dwo_id to file
	list.
	(Dwp_options): New enum type.
	(dwp_options): Add --verify-only.
	(usage): Likewise.
	(main): Likewise.
	* dwp.h (gold_info): Add declaration.
2013-11-14 11:30:12 -08:00
Cary Coutant 7cdd7d57e6 Fix race condition while building EH frame header.
gold/
	PR gold/14860
	* ehframe.cc (Eh_frame_hdr::Eh_frame_hdr): Initialize lock_.
	(Ehframe_hdr::set_final_data_size): Allocate a Lock.
	* ehframe.h (Eh_frame_hdr::record_fde): Hold the lock while
	updating fde_offsets_.
	(Eh_frame_hdr::lock_): New data member.
2013-11-14 10:33:36 -08:00
Cary Coutant 1d946cb356 Fix assert failure with --emit-relocs and .eh_frame sections.
gold/
	PR gold/15758
	* object.cc (Sized_relobj_file::do_layout): Handle .eh_frame sections
	before reloc sections.
2013-11-06 10:37:45 -08:00
Alan Modra 88b8e63904 Remove powerpc.cc copy of use_plt_offset
This adds an extra flag for needs_dynamic_reloc() in order to remove
the copy of this function and use_plt_offset() in powerpc.cc, and
tweaks the powerpc get_reference_flags() to return the flag as
appropriate.  ELFv2 does not want ELFv1 behaviour here.

	* symtab.h (Symbol::Reference_flags): Add FUNC_DESC_ABI.
	(Symbol::needs_dynamic_reloc): Test new flag.
	* powerpc.cc (needs_dynamic_reloc, use_plt_offset): Delete.
	(Target_powerpc::Scan::get_reference_flags): Add target param.
	Return FUNC_DESC_ABI for 64-bit ELFv1.
	(Target_powerpc::Branch_info::make_stub): Adjust get_reference_flags
	call.
	(Target_powerpc::Scan::global): Use Symbol::needs_dynamic_reloc.
	(Target_powerpc::Relocate::relocate): Use Symbol::use_plt_offset.
2013-11-04 16:00:13 +10:30
Cary Coutant 908794a915 Restore support for dwp v2 DWARF package file format.
gold/
	* dwarf_reader.cc (Dwarf_info_reader::visit_type_unit): Add
	tu_length parameter.  Adjust all callers.
	* dwarf_reader.h (Dwarf_info_reader::visit_type_unit): Likewise.
	* dwp.cc: Include dwarf.h.
	(Section_bounds): New struct type.
	(Unit_set): New struct type.
	(Dwo_file::Dwo_file): Initialize new data member.
	(Dwo_file::read_compunit_index, Dwo_file::read_typeunit_index):
	Combine and rename to...
	(Dwo_file::read_unit_index): ...this.
	(Dwo_file::sized_read_compunit_index)
	(Dwo_file::sized_read_typeunit_index): Combine and rename to...
	(Dwo_file::sized_read_unit_index): ...this.
	(Dwo_file::copy_section): Remove section_name, is_str_offsets
	parameters; add section_id parameter.
	(Dwo_file::add_cu_set, Dwo_file::add_tu_set): Combine and rename to...
	(Dwo_file::add_unit_set): ...this.
	(Dwo_file::shndx_map_): Remove.
	(Dwo_file::sect_offsets_): New data member.
	(Dwp_output_file::Dwp_output_file): Initialize new data members.
	(Dwp_output_file::add_section): Rename to...
	(Dwp_output_file::add_contribution): ...this.
	(Dwp_output_file::add_cu_set): Combine parameters into a struct.
	(Dwp_output_file::add_tu_set): Likewise.
	(Dwp_output_file::Contribution): New type.
	(Dwp_output_file::Section::contributions): New data member.
	(Dwp_output_file::Cu_or_tu_set): Remove.
	(Dwp_output_file::Section::Section): New ctor.
	(Dwp_output_file::Dwp_index::Shndx_pool): Remove.
	(Dwp_output_file::Dwp_index::Section_table): New type.
	(Dwp_output_file::Dwp_index::Dwp_index): Initialize new data members.
	(Dwp_output_file::Dwp_index::enter_set): Change type of "set"
	parameter.
	(Dwp_output_file::Dwp_index::shndx_pool): Remove.
	(Dwp_output_file::Dwp_index::shndx_pool_end): Remove.
	(Dwp_output_file::Dwp_index::section_table): New member function.
	(Dwp_output_file::Dwp_index::section_table_end): New member function.
	(Dwp_output_file::Dwp_index::shndx_pool_size): Remove.
	(Dwp_output_file::Dwp_index::section_table_rows): New member function.
	(Dwp_output_file::Dwp_index::section_table_cols): New member function.
	(Dwp_output_file::Dwp_index::shndx_pool_): Remove.
	(Dwp_output_file::Dwp_index::section_table_): New data member.
	(Dwp_output_file::Dwp_index::section_mask_): New data member.
	(Dwp_output_file::add_output_section): New member function.
	(Dwp_output_file::write_new_section): New member function.
	(Dwp_output_file::write_contributions): New member function.
	(Dwp_output_file::section_id_map_): New data member.
	(class Dwo_id_info_reader): Remove.
	(class Unit_reader): New class.
	(get_dwarf_section_name): New function.
	(Dwo_file::read_executable): Adjust initializations of class data.
	(Dwo_file::read): Add support for v2 package file format.
	(Dwo_file::read_unit_index): Likewise.
	(Dwo_file::sized_read_unit_index): Likewise.
	(Dwo_file::copy_section): Likewise.
	(Dwo_file::add_unit_set): Likewise.
	(Dwp_output_file::add_output_section): Likewise.
	(Dwp_output_file::add_contribution): Likewise.
	(Dwp_output_file::Dwp_index::find_or_add): Use row index to check
	for empty slot.
	(Dwp_output_file::Dwp_index::enter_set): Add support for v2 package
	file format.
	(Dwp_output_file::Dwp_index::grow): Use row index to check for empty
	slot.
	(Dwp_output_file::initialize): Remove unused function.
	(Dwp_output_file::finalize): Add support for v2 package file format.
	(Dwp_output_file::write_index): Likewise.
	* gdb-index.cc (Gdb_index_info_reader::visit_type_unit): Adjust
	function prototype.
2013-10-31 11:48:42 -07:00
Cary Coutant 2500c0173e gold/
* configure.ac: Fix check for -fmerge-constants.
	* configure.ac: Regenerate.
2013-10-31 11:36:32 -07:00
Roland McGrath dd0845d708 gold: x86_64-nacl: Correct 9-byte nop sequence to match what the assembler generates.
gold/
	* x86_64.cc (Output_data_plt_x86_64_nacl::first_plt_entry):
	Correct 9-byte nop sequence to match what the assembler generates.
2013-10-30 16:01:06 -07:00
Alan Modra b4f7960d53 PowerPC64 ELFv2 support for gold.
elfcpp/
	* powerpc.h (EF_PPC64_ABI): New enum constant.
	(STO_PPC64_LOCAL_BIT, STO_PPC64_LOCAL_MASK): Likewise.
	(ppc64_decode_local_entry): New function.
	(ppc64_encode_local_entry): Likewise.
gold/
	* powerpc.cc (Powerpc_relobj::abiversion, set_abiversion,
	ppc64_local_entry_offset, ppc64_local_entry_offset,
	do_read_symbols): New functions.
	(Powerpc_relobj::e_flags_, st_other_): New vars.
	(Powerpc_relobj::Powerpc_relobj): Call set_abiversion.
	(Powerpc_dynobj::abiversion, set_abiversion): New functions.
	(Powerpc_relobj::e_flags_): New var.
	(Target_powerpc::first_plt_entry_offset, plt_entry_size): Inline
	and adjust for ELFv2.
	(Target_powerpc::abiversion, set_abiversion, stk_toc): New functions.
	(Powerpc_relobj::do_find_special_sections): Check no .opd in ELFv2.
	(Powerpc_dynobj::do_find_special_sections): Likewise.
	(Target_powerpc::do_define_standard_symbols): Define ".TOC.".
	(Target_powerpc::Branch_info::make_stub): Adjust stub destination
	to ELFv2 local entry.
	(Target_powerpc::do_relax): No thread safe barriers needed for
	ELFv2.
	(Output_data_plt_powerpc::initial_plt_entry_size_,
	plt_entry_size): Delete.  Replace all uses with
	first_plt_entry_offset() and plt_entry_size().
	(Output_data_plt_powerpc::Output_data_plt_powerpc): Remove
	reserved_size parm.  Update callers.
	(Output_data_plt_powerpc::entry_count): Update.
	(Output_data_plt_powerpc::first_plt_entry_offset): Make private
	and use Target_powerpc::first_plt_entry_offset().
	(Output_data_plt_powerpc::get_plt_entry_size): Similarly and
	rename to plt_entry_size.
	(Output_data_plt_powerpc::add_ifunc_entry,
	add_local_ifunc_entry): Adjust reloc for ELFv2.
	(glink_eh_frame_fde_64): Rename to glink_eh_frame_fde_64v1.
	(glink_eh_frame_fde_64v2): New.
	(Stub_table::plt_call_size): Support ELFv2 sizing.
	(Output_data_glink::add_eh_frame): Use the new FDE.
	(Output_data_glink::set_final_data_size): Adjust for ELFv2 glink.
	(Stub_table::do_write): Write ELFv2 stubs and glink.
	(Target_powerpc::Relocate::relocate): Replaces nop after call
	with ld 2,24(1) and adjust local offset destination for ELFv2.
2013-10-30 13:45:05 +10:30
Alan Modra f9c6b9078c Report overflow on PowerPC64 @h and @ha relocations.
This changes the behaviour of @h and @ha on PowerPC64 to report errors
on 32-bit overflow.  The motivation for this change is that on
PowerPC64, most uses of @h and @ha modifiers and their corresponding
relocations are to build up 32-bit offsets.  We'd like to know when
such offsets overflow.  Only rarely do people use @h or @ha with the
high 32-bit modifiers to build a 64-bit constant.  Those uses will now
need to use two new modifiers, @high and @higha, if the constant isn't
known at assembly time.  For now, we won't report overflow at assembly
time..

This also fixes an error when applying some of the HIGHER and HIGHEST
relocations.

include/elf/
	* ppc64.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
	R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
	R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): New.
	(IS_PPC64_TLS_RELOC): Match new tls relocs.
bfd/
	* reloc.c (BFD_RELOC_PPC64_ADDR16_HIGH, BFD_RELOC_PPC64_ADDR16_HIGHA,
	BFD_RELOC_PPC64_TPREL16_HIGH, BFD_RELOC_PPC64_TPREL16_HIGHA,
	BFD_RELOC_PPC64_DTPREL16_HIGH, BFD_RELOC_PPC64_DTPREL16_HIGHA): New.
	* elf64-ppc.c (ppc64_elf_howto_raw): Add entries for new relocs.
	Make all _HA and _HI relocs report signed overflow.
	(ppc64_elf_reloc_type_lookup): Handle new relocs.
	(must_be_dyn_reloc, ppc64_elf_check_relocs): Likewise.
	(dec_dynrel_count, ppc64_elf_relocate_section): Likewise.
	(ppc64_elf_relocate_section): Don't apply 0x8000 adjust to
	R_PPC64_TPREL16_HIGHER, R_PPC64_TPREL16_HIGHEST,
	R_PPC64_DTPREL16_HIGHER, and R_PPC64_DTPREL16_HIGHEST.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Regenerate.
gas/
	* config/tc-ppc.c (SEX16): Don't mask.
	(REPORT_OVERFLOW_HI): Define as zero.
	(ppc_elf_suffix): Support @high, @higha, @dtprel@high, @dtprel@higha,
	@tprel@high, and @tprel@higha modifiers.
	(md_assemble): Ignore X_unsigned when applying 16-bit insn fields.
	Add (disabled) code to check @h and @ha reloc overflow for powerpc64.
	Handle new relocs.
	(md_apply_fix): Similarly.
elfcpp/
	* powerpc.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
	R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
	R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): Define.
gold/
	* powerpc.cc (Target_powerpc::Scan::check_non_pic): Handle new relocs.
	(Target_powerpc::Scan::global, local): Likewise.
	(Target_powerpc::Relocate::relocate): Likewise.  Check for overflow
	on all ppc64 @h and @ha relocs.
2013-10-30 13:33:15 +10:30
Alan Modra e84fe78fbc * output.h (Output_data_got::add_constant): Tidy.
(Output_data_got::add_constant_pair): New function.
	* powerpc.cc (Output_data_got_powerpc): Override all Output_data_got
	methods used so as to first call reserve_ent().
2013-10-14 02:53:01 +00:00
Roland McGrath 44dcb735e4 gold/
* powerpc.cc (Output_data_got_powerpc): Remove unused methods
	add_got_entry and add_got_entry_pair.
2013-10-11 23:06:08 +00:00
Roland McGrath 52dc3f9c91 Revert inappropriate portions of last change. 2013-10-11 22:16:34 +00:00
Roland McGrath 13323c494d gold/
* configure.ac (TLS_GNU2_DIALECT): Use -Werror in test.
	(HAVE_PUBNAMES): Likewise.
	* configure: Regenerate.
2013-10-11 22:07:40 +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 cc84c10bfe gold/
* target.h (Target::adjust_elf_header, Target::do_adjust_elf_header):
	Remove const from declaration.
	* target.cc (Sized_target::do_adjust_elf_header): Update definition.
	* sparc.cc (Target_sparc::do_adjust_elf_header): Likewise.
	* output.h (Output_file_header): Remove const from member target_
	and corresponding constructor argument.
	* output.cc (Output_file_header::Output_file_header): Update prototype.
	(Output_file_header::do_sized_write): Use this->target_ in place
	of parameters()->target().
2013-10-11 22:02:21 +00:00
Roland McGrath 52f66a2c4d gold/
* testsuite/undef_symbol.cc (Foo::get_a): New method.
2013-10-11 21:59:46 +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
Roland McGrath 43819297ce gold/
* i386.cc (Target_i386): Remove unused member dynbss_.
	* arm.cc (Target_arm): Likewise.
	* powerpc.cc (Target_powerpc): Likewise.
	* sparc.cc (Target_sparc): Likewise.
	* tilegx.cc (Target_tilegx): Likewise.
	* x86_64.cc (Target_x86_64): Likewise.
	* dwarf_reader.h (Dwarf_info_reader): Remove unused members
	type_signature_, type_offset_.
	* plugin.h (Plugin_hook): Remove unused member layout_.
	* readsyms.h (Add_symbols): Remove unused members dirpath_, dirindex_,
	mapfile_.
	(Read_member): Remove unused members input_objects_, symtab_,
	mapfile_, layout_.
	(Check_library): Remove unused member symtab_.
	* archive.h (Lib_group): Remove unused member lib_.
	* archive.cc (Lib_group::Lib_group): Update initializer.
	* incremental.h	(Incremental_binary): Remove unused member target_.
	(Incremental_script_entry): Removed unused member script_.
	* layout.h (Write_symbols_task): Remove unused member input_objects_.
	* icf.h (Icf): Remove unused member num_tracked_relocs.
2013-10-11 21:11:49 +00:00
Roland McGrath 39d9ead7fb gold/
* gold-threads.h (Once): Conditionalize member was_run_lock_ on
	[ENABLE_THREADS && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4], matching
	its only use.
	* gold-threads.cc (Once::Once): Likewise conditionalize initializer.
2013-10-11 21:02:43 +00:00
Roland McGrath 679e4abfc5 gold/
* archive.h: Use struct rather than class for forward declaration
	of Read_symbols_data.
2013-10-11 17:38:32 +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
H.J. Lu b14016f0b2 Use relative relocation for R_X86_64_32 on x32
2013-09-03  Pavel Chupin  <pavel.v.chupin@intel.com>

	PR gold/15927
	* x86_64.cc (Target_x86_64<size>::Scan::global): Use relative
	relocation for R_X86_64_32 on x32.
2013-09-03 17:38:57 +00:00
Roland McGrath eb426534c3 gold/
* output.cc (Output_segment::set_section_addresses): Take new
	Target* argument.  If target->isolate_execinstr() and the segment
	is executable and starts at a target->abi_pagesize() boundary,
	pad its end out to a target->abi_pagesize() boundary with code fill.
	* output.h (Output_segment::set_section_addresses): Update decl.
	* layout.h (Layout::check_output_data_for_reset_values): Take new
	argument RELAX_OUTPUTS.
	(Layout): New member relax_output_list_.
	(Layout::add_relax_output): New method.
	* layout.cc (Layout::Layout): Update constructor.
	(Layout::reset_relax_output): New method.
	(Layout::clean_up_after_relaxation): Call it.
	(Layout::prepare_for_relaxation): Update caller.
	(Layout::set_segment_offsets): Update callers of set_section_addresses.
	Call reset_relax_output before re-processing segments for
	isolate_execinstr case.
	(Layout::write_data): Handle relax_output_list_.
	(Layout::Relaxation_debug_check::check_output_data_for_reset_values):
	Take new argument RELAX_OUTPUTS.  Assert it's an empty collection.
2013-08-27 21:49:48 +00:00
Nick Clifton 9aff4b7ac1 PR binutils/15834
Fix typos:
---
 bfd/bfdio.c                                  |  2 +-
 bfd/elf32-spu.c                              |  2 +-
 bfd/elfnn-aarch64.c                          |  2 +-
 binutils/od-xcoff.c                          |  2 +-
 config/tcl.m4                                |  2 +-
 gas/config/tc-ia64.c                         |  2 +-
 gas/config/tc-sparc.c                        |  2 +-
 gas/config/tc-z80.c                          | 12 ++++++------
 gas/doc/c-i386.texi                          |  6 +++---
 gas/doc/c-m32r.texi                          |  2 +-
 gas/testsuite/gas/d10v/instruction_packing.d |  2 +-
 gas/testsuite/gas/z80/atend.d                |  2 +-
 gold/object.h                                |  2 +-
 include/gdb/remote-sim.h                     |  2 +-
 include/opcode/ChangeLog                     |  2 +-
 include/opcode/i960.h                        |  2 +-
 ld/testsuite/ld-mips-elf/mips16-pic-1.inc    |  2 +-
 opcodes/aarch64-asm.c                        |  2 +-
 opcodes/aarch64-dis.c                        |  2 +-
 opcodes/msp430-dis.c                         |  2 +-
2013-08-23 07:54:19 +00:00
Roland McGrath 93f8221c64 gold/
* i386.cc (Target_i386_nacl::do_code_fill): New virtual function.
	* x86_64.cc (Target_x86_64_nacl::do_code_fill): New virtual function.
2013-08-16 18:12:05 +00:00
Cary Coutant e44c371564 gold/
Revert support for v2 DWP files:

	2013-03-01  Cary Coutant  <ccoutant@google.com>

	    Add dwp support for v2 DWARF package file format.
	    * dwarf_reader.cc (Dwarf_info_reader::visit_type_unit): Add
	    tu_length parameter.  Adjust all callers.
	    * dwarf_reader.h (Dwarf_info_reader::visit_type_unit): Likewise.
	    * dwp.cc: Include dwarf.h.
	    (Section_bounds): New struct type.
	    (Unit_set): New struct type.
	    (Dwo_file::Dwo_file): Initialize new data member.
	    (Dwo_file::read_compunit_index, Dwo_file::read_typeunit_index):
	    Combine and rename to...
	    (Dwo_file::read_unit_index): ...this.
	    (Dwo_file::sized_read_compunit_index)
	    (Dwo_file::sized_read_typeunit_index): Combine and rename to...
	    (Dwo_file::sized_read_unit_index): ...this.
	    (Dwo_file::copy_section): Remove section_name, is_str_offsets
	    parameters; add section_id parameter.
	    (Dwo_file::add_cu_set, Dwo_file::add_tu_set): Combine and rename to...
	    (Dwo_file::add_unit_set): ...this.
	    (Dwo_file::shndx_map_): Remove.
	    (Dwo_file::sect_offsets_): New data member.
	    (Dwp_output_file::Dwp_output_file): Initialize new data members.
	    (Dwp_output_file::add_section): Rename to...
	    (Dwp_output_file::add_contribution): ...this.
	    (Dwp_output_file::add_cu_set): Combine parameters into a struct.
	    (Dwp_output_file::add_tu_set): Likewise.
	    (Dwp_output_file::Contribution): New type.
	    (Dwp_output_file::Section::contributions): New data member.
	    (Dwp_output_file::Cu_or_tu_set): Remove.
	    (Dwp_output_file::Section::Section): New ctor.
	    (Dwp_output_file::Dwp_index::Shndx_pool): Remove.
	    (Dwp_output_file::Dwp_index::Section_table): New type.
	    (Dwp_output_file::Dwp_index::Dwp_index): Initialize new data members.
	    (Dwp_output_file::Dwp_index::enter_set): Change type of "set"
	    parameter.
	    (Dwp_output_file::Dwp_index::shndx_pool): Remove.
	    (Dwp_output_file::Dwp_index::shndx_pool_end): Remove.
	    (Dwp_output_file::Dwp_index::section_table): New member function.
	    (Dwp_output_file::Dwp_index::section_table_end): New member function.
	    (Dwp_output_file::Dwp_index::shndx_pool_size): Remove.
	    (Dwp_output_file::Dwp_index::section_table_rows): New member function.
	    (Dwp_output_file::Dwp_index::section_table_cols): New member function.
	    (Dwp_output_file::Dwp_index::shndx_pool_): Remove.
	    (Dwp_output_file::Dwp_index::section_table_): New data member.
	    (Dwp_output_file::Dwp_index::section_mask_): New data member.
	    (Dwp_output_file::add_output_section): New member function.
	    (Dwp_output_file::write_new_section): New member function.
	    (Dwp_output_file::write_contributions): New member function.
	    (Dwp_output_file::section_id_map_): New data member.
	    (class Dwo_id_info_reader): Remove.
	    (class Unit_reader): New class.
	    (get_dwarf_section_name): New function.
	    (Dwo_file::read_executable): Adjust initializations of class data.
	    (Dwo_file::read): Add support for v2 package file format.
	    (Dwo_file::read_unit_index): Likewise.
	    (Dwo_file::sized_read_unit_index): Likewise.
	    (Dwo_file::copy_section): Likewise.
	    (Dwo_file::add_unit_set): Likewise.
	    (Dwp_output_file::add_output_section): Likewise.
	    (Dwp_output_file::add_contribution): Likewise.
	    (Dwp_output_file::Dwp_index::find_or_add): Use row index to check
	    for empty slot.
	    (Dwp_output_file::Dwp_index::enter_set): Add support for v2 package
	    file format.
	    (Dwp_output_file::Dwp_index::grow): Use row index to check for empty
	    slot.
	    (Dwp_output_file::initialize): Remove unused function.
	    (Dwp_output_file::finalize): Add support for v2 package file format.
	    (Dwp_output_file::write_index): Likewise.
	    * gdb-index.cc (Gdb_index_info_reader::visit_type_unit): Adjust
	    function prototype.
2013-08-07 17:11:24 +00:00
Cary Coutant c6905c28a5 gold/
* object.cc (Sized_relobj::do_output_section_address): New function.
	(Sized_relobj): Instantiate explicitly.
	* object.h (Object::output_section_address): New function.
	(Object::do_output_section_address): New function.
	(Sized_relobj::do_output_section_address): New function.
	* powerpc.cc (Target_powerpc::symval_for_branch): Use it.
2013-07-31 18:47:50 +00:00
Cary Coutant 5cdb4d9821 Add missing author to last ChangeLog entry. 2013-07-30 21:29:50 +00:00
Cary Coutant a67858e046 gold/
* parameters.cc (Parameters::entry): Return target-specific entry
    	symbol name.
    	* target.h (Target::entry_symbol_name): New function.
    	(Target_info::entry_symbol_name): New data member.

    	* arm.cc (Target_arm::arm_info): Add entry_symbol_name.
    	(Target_arm_nacl::arm_nacl_info): Likewise.
    	* i386.cc (Target_i386::i386_info): Likewise.
    	(Target_i386_nacl::i386_nacl_info): Likewise.
    	* powerpc.cc (Target_powerpc::powerpc_info): Likewise.
    	* sparc.cc (Target_sparc::sparc_info): Likewise.
    	* tilegx.cc (Target_tilegx::tilegx_info): Likewise.
    	* x86_64.cc: (Target_x86_64::x86_64_info) Likewise.
    	(Target_x86_64_nacl::x86_64_nacl_info) Likewise.
    	* testsuite/testfile.cc (Target_test::test_target_info): Likewise.
2013-07-30 21:26:53 +00:00
Sterling Augustine 234d4ab880 2013-07-22 Sterling Augustine <saugustine@google.com>
* dwarf_reader.cc (Dwarf_pubnames_table::read_section):
	Convert parameter shndx to local variable. Add parameters symtab
	and symtab_size.  Scan over section names.  Find relocation
	section corresponding to current section.  Create and initialize
	reloc_mapper_ and reloc_type_.
	(Dwarf_pubnames_table::read_header):  Add assertion.  Change
	unit_length to off_t.  Initialize member unit_length_.  Fill in field
	cu_offset_.
	* dwarf_reader.h (Dwarf_pubnames_table::Dwarf_pubnames_table):
	Initialize new fields unit_length_ and cu_offset_.
	(Dwarf_pubnames_table::read_section): Update prototype.
	(Dwarf_pubnames_table::cu_offset): New member function.
	(Dwarf_pubnames_table::subsection_size): Likewise.
	(Dwarf_pubnames_table::cu_offset_, Dwarf_pubnames_table::unit_length):
	New fields.
	(Dwarf_info_reader::symtab, Dwarf_info_reader::symtab_size): Make
	member functions public.
	* gdb_index.cc (Gdb_index_info_reader::read_pubnames_and_pubtypes):
	Update comment.  Rework logic.  Move repeated parts to...
	(Gdb_index_info_reader::read_pubtable): ...here. New function.
	(Gdb_index::Gdb_index): Initialize new fields, pubnames_table_,
	pubtypes_table_, and stmt_list_offset.
	(Gdb_index::map_pubtable_to_dies, Gdb_index::find_pubname_offset,
	Gdb_index::find_pubtype_offset,
	Gdb_index::map_pubnames_and_types_to_dies): Define new functions.
	(Gdb_index::pubnames_read): Update prototype and rework logic.
	* gdb_index.h (Gdb_index_info_reader, Dwarf_pubnames_table):
	Forward declare.
	(Gdb_index::map_pubtable_to_dies, Gdb_index::find_pubname_offset,
	Gdb_index::find_pubtype_offset, Gdb_index::pubnames_table)
	Gdb_index::pubtypes_table, Gdb_index::map_pubnames_and_types_to_dies,
	Gdb_index::map_pubtable_to_dies):
	Declare functions.
	(Gdb_index::pubnames_read): Update declaration.
	(Gdb_index::Pubname_offset_map): New type.
	(Gdb_index::cu_pubname_map_, Gdb_index::cu_pubtype_map_,
	Gdb_index::pubnames_table_, Gdb_index::pubtypes_table_,
	Gdb_index::stmt_list_offset): Declare.
	(Gdb_index::pubnames_shndx_, Gdb_index::pubnames_offet_,
	Gdb_index::pubtypes_object_, Gdb_index::pubtypes_shndx_)
	Gdb_index::pubtypes_offset_): Remove.
2013-07-29 18:29:12 +00:00
Roland McGrath a3ed37d8bc gold/
* options.h (General_options): Add -Trodata-segment option.
	* parameters.cc (Parameters::check_rodata_segment): New function.
	(Parameters::set_target_once): Call it.
	* parameters.h (Parameters): Declare it (private member function).
	* layout.cc (load_seg_unusable_for_headers): New function, broken
	out of Layout::relaxation_loop_body.  If TARGET->isolate_execinstr()
	then validate rodata segment rather than text segment.
	(relaxation_loop_body): Call that.
	(is_text_segment): New function.  Don't admit a non-executable
	segment if TARGET->isolate_execinstr().
	(set_segment_offsets): Call it.  Honor -Trodata-segment option.
2013-07-19 23:07:08 +00:00
Cary Coutant eb5b4dedf4 2013-07-15 Shawn Landden <shawnlandden@gmail.com>
gold/
	PR gold/15070
	* fileread.h (File_read::get_view): Clarify comment about ALIGNED.
	* nacl.h (Sniff_file::View::View): Request aligned view.
2013-07-15 16:49:20 +00:00
Cary Coutant 4d5effb90d gold/
* powerpc.cc (Target_powerpc::write_branch_lookup_table): Use
	correct BRLT entry size.
2013-07-11 21:30:56 +00:00
Alan Modra ba8ca3e739 bfd/
* elf64-ppc.c (struct ppc_stub_hash_entry): Delete "addend".
	(ppc64_elf_size_stubs): Don't set "addend".
	(ppc64_elf_relocate_section): Don't allow calls via
	toc-adjusting stubs without a following nop even in an
	executable, except for self-calls and both libc_start_main
	and .libc_start_main.
gold/
	* powerpc.cc (Target_powerpc::Relocate::relocate): Update self-call
	comment.
2013-07-03 02:22:35 +00:00
Cary Coutant 267257d249 gold/
* dwarf_reader.cc (Dwarf_ranges_table::read_ranges_table): Save
	reloc_type_.
	(Dwarf_ranges_table::read_range_list): Call lookup_reloc.
	(Dwarf_ranges_table::lookup_reloc): New function.
	* dwarf_reader.h (Dwarf_ranges_table::Dwarf_ranges_table): Initialize
	reloc_type_.
	(Dwarf_ranges_table::lookup_reloc): New function.
	(Dwarf_ranges_table::reloc_type_): New data member.
2013-07-01 20:12:11 +00:00
Cary Coutant 06f30c9d10 PR gold/15662
* powerpc.cc (Output_data_brlt_powerpc::reset_brlt_sizes): New
	function.
	(Output_data_brlt_powerpc::finalize_brlt_sizes): New function.
	(Target_powerpc::do_relax): Call the above.
2013-06-27 23:20:35 +00:00
Alan Modra a2d7bf59d6 * powerpc.cc (Target_powerpc::symval_for_branch): Don't assert
on garbage collected .opd section.

	* powerpc.cc (Target_powerpc::do_gc_add_reference): Test dst_shndx
	is non-zero.
	(Target_powerpc::do_gc_mark_symbols): Likewise for sym->shndx().
	(Target_powerpc::do_function_location): Likewise for loc->shndx.
2013-06-27 03:11:22 +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 4ca24d905f gold/
Add missing test case from last patch.
2013-06-06 06:06:56 +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 60e8b3fccd gold/
* object.cc (Sized_relobj_file::get_symbol_location_info): Set
    	type of enclosing symbol.
    	(Relocate_info::location): Check symbol type when describing symbol.
    	* object.h (Symbol_location_info): Remove unused line_number;
    	add enclosing_symbol_type.
    	* testsuite/debug_msg.sh: Adjust expected output.
2013-05-21 20:56:13 +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
Roland McGrath bbc5ae17c4 gold/
* options.h (General_options): Add --rosegment-gap option.
	* options.cc (finalize): --rosegment-gap implies --rosegment.
	* layout.cc (set_segment_offsets): Let user option override
	target->rosegment_gap().
2013-05-10 22:33:35 +00:00
Roland McGrath 0c6e6c39ad gold/
* options.h (General_options): Remove leading space from help
	messages for -nostdlib and --rosegment.
2013-05-10 20:35:47 +00:00
Maciej W. Rozycki cde7cb0129 gold/
PR ld/15365
        * layout.cc (Layout::finalize): Make __ehdr_start STV_HIDDEN.

        ld/
        PR ld/15365
        * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation):
        Restrict __ehdr_start's export class to no less than STV_HIDDEN.

        ld/testsuite/
        PR ld/15365
        * ld-elf/ehdr_start.d: Expect __ehdr_start to be STB_LOCAL.
        * ld-mips-elf/ehdr_start-1.nd: New test.
        * ld-mips-elf/ehdr_start-2.nd: New test.
        * ld-mips-elf/ehdr_start-1.ld: New test linker script.
        * ld-mips-elf/ehdr_start-2.ld: New test linker script.
        * ld-mips-elf/ehdr_start-new.s: New test source.
        * ld-mips-elf/ehdr_start-o32.s: New test source.
        * ld-mips-elf/mips-elf.exp: Run the new tests.
2013-05-03 15:19:27 +00:00
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 6ad3dabab5 gold/
* stringpool.cc (Stringpool_template::new_key_offset): Fix
	uninitialized warning.
2013-05-01 17:37:14 +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
Ian Lance Taylor 0e8048633e * target-reloc.h (relocate_section): If the reloc offset is out of
range, pass VIEW as NULL to relocate.relocate.
	* arm.cc (Target_arm:Relocate::relocate): Check for a NULL view.
	* i386.cc (Target_i386::Relocate::relocate): Likewise.
	* powerpc.cc (Target_powerpc::Relocate::relocate): Likewise.
	* sparc.cc (Target_sparc::Relocate::relocate): Likewise.
	* tilegx.cc (Target_tilegx::Relocate::relocate): Likewise.
	* x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
2013-04-27 00:53:16 +00:00
Cary Coutant e7c5ea405f 2013-04-26 Geoff Pike <gpike@chromium.org>
gold/
	* gold.cc (queue_final_tasks): invoke layout->queue_build_id_tasks().
	* layout.cc (Hash_task): New class.
	(Layout::queue_build_id_tasks): New function.
	(Layout::write_build_id): Handle single-thread portion of build ID
	computation.  (In some cases, all of it is single-threaded.)  Replace
	{sha1,md5}_process_bytes with {sha1,md5}_buffer to get the same
	functionality in fewer lines of code.
	* layout.h (Layout::queue_build_id_tasks): New function declaration.
	* options.h (General_options): make "--build-id" default to tree
	rather than sha1.  Add two new options related to --build-id=tree:
	--build-id-chunk-size-for-treehash and
	--build-id-min-file-size-for-treehash.
	* Makefile.am: add testing of --build-id=tree and related new options
	(these tests will be invoked by "make check").
	* Makefile.in: Regenerate.
2013-04-26 21:38:57 +00:00
Alan Modra 49926cd0c8 bfd/
* config.bfd: Add powerpc64le-linux.
gas/
	* configure.in: Allow little-endian linux.
	* configure: Regenerate.
gold/
	* configure.tgt: Add powerpcle and powerpc64le.
ld/
	* Makefile.am (ALL_EMULATION_SOURCES): Add eelf32lppclinux.c.
	(eelf32lppclinux.c): New rule.
	* Makefile.in: Regenerate.
	* configure.tgt: Merge powerpc-linux and other powerpc-elf targets
	with corresponding little-endian targets.
	* emulparams/elf32lppc.sh: Update comment.
	* emulparams/elf32lppclinux.sh: New.
2013-04-25 13:22:52 +00:00
Alan Modra a40347502e PR gold/15355
* layout.cc (Layout::segment_precedes): Allow more than one
	segment with the same type and flags.
2013-04-21 23:21:56 +00:00
Cary Coutant e79c84aa33 gold/
* layout.cc (Layout::set_relocatable_section_offsets): Don't
	allocate space in file for BSS sections.
2013-04-15 16:40:59 +00:00
Cary Coutant 2199fbe773 gold/
* script-sections.cc (Orphan_output_section): Reset address
	to zero after each orphaned section for relocatable links.
2013-04-15 16:37:30 +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 0cfdc76718 * powerpc.cc (Stub_control::can_add_to_stub_group): Don't set
owner when sections are not adjacent and exceed group size.
	(Target_powerpc::group_sections): Handle corner case.
	(Target_powerpc::Branch_info::make_stub): Handle case where
	stub table doesn't exist due to branches in non-exec sections.
	(Target_powerpc::Relocate::relocate): Likewise.
2013-04-13 10:12:30 +00:00
Alan Modra 6830ee24c7 PR gold/15354
* powerpc.cc (Target_powerpc::make_brlt_section): Name section
	.branch_lt to match bfd ld.  Adjust comments throughout file.
2013-04-11 01:28:27 +00:00
Ian Lance Taylor 54a3d86564 GCC PR c++/56840
* object.cc (do_layout_deferred_sections): Handle .eh_frame
	sections before checking whether they are included in the link.
2013-04-04 16:49:04 +00:00
Sriraman Tallam 9993ba115b 2013-03-29 Sriraman Tallam <tmsriram@google.com>
* archive.cc (Archive::get_elf_object_for_member):  Create the elf
	object before calling the plugin claim_file handler.  Pass the elf
	object of the archive to the plugin. Delete the elf object if the
	plugin claims the file.
2013-03-30 01:03:23 +00:00
Alan Modra ebacd51e16 * layout.cc (Layout::set_segment_offsets): Accept writable .text
segment when omagic.
2013-03-21 04:52:55 +00:00
Alan Modra 117be58fad * dwp.cc (Dwp_output_file::add_contribution): Avoid signed/unsigned
comparison warning.
	* layout.cc (Layout::create_dynamic_symtab): Avoid "may be used
	uninitialized" warning.
2013-03-21 02:00:16 +00:00
Alan Modra 32e2b61d0b * symtab.h (Symbol::clear_version): New function.
* symtab.cc (Symbol_table::set_dynsym_indexes): Don't set object
	is_needed by weak references.  Clear version for symbols defined
	in as-needed objects that are not needed.
2013-03-20 00:25:28 +00:00
Alan Modra b3ccdeb53f * powerpc.cc (Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Make
static and public.  Add report_err param.  Return false for data refs.
	(Target_powerpc::rela_dyn_section): New overloaded function.
	(Target_powerpc::plt_, iplt_): Elucidate.
	(Output_data_plt_powerpc::entry_count): Handle current_data_size()==0.
	(Output_data_plt_powerpc::do_write): Don't write .iplt.
	(Output_data_plt_powerpc::plt_entry_count): Don't add .iplt entries.
	(Target_powerpc::Scan::local, global): Adjust reloc_needs_plt_for_ifunc
	calls.  Put ifunc dynamic relocs in irela_dyn_section.  Only
	push_branch and make_plt_entry for ifunc syms when
	reloc_needs_plt_for_ifunc.
	(Target_powerpc::Relocate::relocate): Don't use plt entry value
	for ifunc unless reloc_needs_plt_for_ifunc.
2013-03-15 08:40:49 +00:00
Alan Modra ad3d8a2f04 * gc.h (gc_process_relocs): Don't look through function descriptors.
* icf.cc (get_section_contents): Do so here instead.
2013-03-15 07:51:32 +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 57420c2084 * gc.h (gc_process_relocs): Look through function descriptors
to determine shndx, symvalue and addend used by ICF.  Tidy
	variable duplication.
2013-03-12 00:42:14 +00:00
Alan Modra dc3714f31f * gold.cc (queue_middle_tasks): Move detect_odr_violations..
* layout.cc (Layout_task_runner::run): ..to here.
	* symtab.h (struct Symbol_location): Extract from..
	(class Symbol_table): ..here.
	* symtab.cc (Symbol_table::linenos_from_loc): Invoke function_location.
	* target.h (class Target): Add function_location and
	do_function_location functions.
	(class Sized_target): Add do_function_location.
	* object.h (class Sized_relobj_file): Move find_shdr..
	(class Object): ..to here.
	* object.cc: Likewise.  Update to suit.  Instantiate.
	(Sized_relobj_file::find_eh_frame): Update find_shdr call.
	* powerpc.cc (class Powerpc_dynobj): New.
	(Target_powerpc::do_function_location): New function.
	(Powerpc_relobj::do_find_special_sections): Update find_shdr call.
	(Powerpc_dynobj::do_read_symbols): New function.
	(Target_powerpc::do_make_elf_object): Make a Powerpc_dynobj.
2013-03-10 23:08:18 +00:00
Ian Lance Taylor 956b03bbdf * options.cc (General_options::string_to_object_format): Accept
"default".
2013-03-08 22:34:46 +00:00