From 6579e31a8757a1df50ca408dd1b3cd3fe59bb4b6 Mon Sep 17 00:00:00 2001 From: Han Shen Date: Thu, 14 Jan 2016 14:26:29 -0800 Subject: Backport trunk patch for not applying dynamic relocs. Note, there is a small change from the origin patch - while in the upstream patch, the option --no-apply-dynamic is default off, it is on by default in this CL. This should not bring any changes to android or chromeos, because the relocation value this CL changes is not used by chromeos, and is not used by android either (after the fix in bionic months ago). The backported patch is - commit 0eccf19f96d6218dd7c2f8d13f0546c2b942cc08 Author: Cary Coutant Date: Thu Nov 5 12:24:14 2015 -0800 Add aarch64-specific --no-apply-dynamic-relocs option. With --no-apply-dynamic-relocs on aarch64 targets, gold will not apply link-time values for absolute relocations that become dynamic relocations. This provides a workaround for broken Android dynamic linkers that use the link-time value as an extra addend to the relocation. gold/ PR gold/19163 * aarch64.cc (Target_aarch64::Relocate::relocate): Don't apply certain relocations if --no-apply-dynamic-relocs is set. * options.h (--apply-dynamic-relocs): New aarch64-specific option. Tested - build whole toolchain and built android N9 image. Change-Id: Ida524bbee2a83574cd9e78ffdad9270787327c78 --- binutils-2.25/gold/ChangeLog | 9 ++++++++- binutils-2.25/gold/aarch64.cc | 25 +++++++++++++++++++++++++ binutils-2.25/gold/options.h | 7 +++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index 24e8755..bf9cc55 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,4 +1,11 @@ -2015-10.27 Han Shen +2015-11-05 Cary Coutant + + PR gold/19163 + * aarch64.cc (Target_aarch64::Relocate::relocate): Don't apply + certain relocations if --no-apply-dynamic-relocs is set. + * options.h (--apply-dynamic-relocs): New aarch64-specific option. + +2015-10-27 Han Shen PR gold/19042 - unsupported reloc 311/312. diff --git a/binutils-2.25/gold/aarch64.cc b/binutils-2.25/gold/aarch64.cc index 1148bf7..1cc68d1 100644 --- a/binutils-2.25/gold/aarch64.cc +++ b/binutils-2.25/gold/aarch64.cc @@ -6907,16 +6907,41 @@ Target_aarch64::Relocate::relocate( break; case elfcpp::R_AARCH64_ABS64: + if (!parameters->options().apply_dynamic_relocs() + && parameters->options().output_is_position_independent() + && gsym != NULL + && gsym->needs_dynamic_reloc(reloc_property->reference_flags()) + && !gsym->can_use_relative_reloc(false)) + // We have generated an absolute dynamic relocation, so do not + // apply the relocation statically. (Works around bugs in older + // Android dynamic linkers.) + break; reloc_status = Reloc::template rela_ua<64>( view, object, psymval, addend, reloc_property); break; case elfcpp::R_AARCH64_ABS32: + if (!parameters->options().apply_dynamic_relocs() + && parameters->options().output_is_position_independent() + && gsym != NULL + && gsym->needs_dynamic_reloc(reloc_property->reference_flags())) + // We have generated an absolute dynamic relocation, so do not + // apply the relocation statically. (Works around bugs in older + // Android dynamic linkers.) + break; reloc_status = Reloc::template rela_ua<32>( view, object, psymval, addend, reloc_property); break; case elfcpp::R_AARCH64_ABS16: + if (!parameters->options().apply_dynamic_relocs() + && parameters->options().output_is_position_independent() + && gsym != NULL + && gsym->needs_dynamic_reloc(reloc_property->reference_flags())) + // We have generated an absolute dynamic relocation, so do not + // apply the relocation statically. (Works around bugs in older + // Android dynamic linkers.) + break; reloc_status = Reloc::template rela_ua<16>( view, object, psymval, addend, reloc_property); break; diff --git a/binutils-2.25/gold/options.h b/binutils-2.25/gold/options.h index 6502e1f..db5254b 100644 --- a/binutils-2.25/gold/options.h +++ b/binutils-2.25/gold/options.h @@ -644,6 +644,13 @@ class General_options N_("Allow unresolved references in shared libraries"), N_("Do not allow unresolved references in shared libraries")); + // Note: this is cherry-picked from upstream patch 0eccf19f9. But the default + // value is changed from "true" to "false". + DEFINE_bool(apply_dynamic_relocs, options::TWO_DASHES, '\0', false, + N_("Apply link-time values for dynamic relocations (default)"), + N_("(aarch64 only) Do not apply link-time values " + "for dynamic relocations")); + DEFINE_bool(as_needed, options::TWO_DASHES, '\0', false, N_("Only set DT_NEEDED for shared libraries if used"), N_("Always DT_NEEDED for shared libraries")); -- cgit v1.1 From c327c9c1bcffd231fcaa05f3fd8c047d1fe0afcc Mon Sep 17 00:00:00 2001 From: Han Shen Date: Wed, 20 Jan 2016 16:36:53 -0800 Subject: Backport trunk patch wrt wrong stub generated for aarch64 large DSOs. Tested by build.py for linux aarch64 toolchains. The upstream patch is: commit 9a472eda40ba686e45bf4922455518ffa3c887e1 Author: Han Shen Date: Fri Jan 15 09:31:23 2016 -0800 [gold][aarch64] PR gold/19472 - DSOs need pc-relative stubs. The stub generated during relaxation uses absolute addressing mode for shared libraries, which is not correct. Use pc-relative addressing instead. gold/ChangeLog: 2016-01-15 Han Shen PR gold/19472 - DSOs need pc-relative stubs. * aarch64.cc (Reloc_stub::stub_type_for_reloc): Return PC-relative stub type for DSOs and pie executables. Change-Id: Id0022975cf93600117ff5bf300b9d736d6ad1f80 --- binutils-2.25/gold/ChangeLog | 7 +++++++ binutils-2.25/gold/aarch64.cc | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index bf9cc55..2ba3b2b 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,3 +1,10 @@ +2016-01-15 Han Shen + + PR gold/19472 - need pc-relative stubs. + + * aarch64.cc (Reloc_stub::stub_type_for_reloc): Return PC-relative + stub type for DSOs and pie executables. + 2015-11-05 Cary Coutant PR gold/19163 diff --git a/binutils-2.25/gold/aarch64.cc b/binutils-2.25/gold/aarch64.cc index 1cc68d1..445f324 100644 --- a/binutils-2.25/gold/aarch64.cc +++ b/binutils-2.25/gold/aarch64.cc @@ -1327,10 +1327,12 @@ Reloc_stub::stub_type_for_reloc( if (aarch64_valid_for_adrp_p(location, dest)) return ST_ADRP_BRANCH; - if (parameters->options().output_is_position_independent() - && parameters->options().output_is_executable()) + // Always use PC-relative addressing in case of -shared or -pie. + if (parameters->options().output_is_position_independent()) return ST_LONG_BRANCH_PCREL; + // This saves 2 insns per stub, compared to ST_LONG_BRANCH_PCREL. + // But is only applicable to non-shared or non-pie. return ST_LONG_BRANCH_ABS; } -- cgit v1.1 From 546435180dfe950e1c6b8447c695655d4bd8b553 Mon Sep 17 00:00:00 2001 From: Han Shen Date: Thu, 4 Feb 2016 14:18:54 -0800 Subject: Backport upstream patch to fix linker internal error. The error happens while linking a huge arm32 binary (for example, a debuggable chrome browser on arm) - the plt jump offset overflows. This fixes the problem by introducing another level of indirection. By default this does not affect anything. However in case of plt jump offset overflow, instead of triggering an internal error, the linker generates a proper message and suggests add "--long-plt" to the linker command. Tested via linking debug chrome browser for arm32. Also tested by build.py on android. The upstream patch - commit ce3e49806d505721e0875e704de0b6fcba7660ed Author: Peter Collingbourne Date: Thu Dec 17 16:50:35 2015 -0800 Implement --long-plt flag (ARM only). gold/ PR gold/18780 * arm.cc (Target_arm::do_make_data_plt): Choose PLT generator based on value of --long-plt flag. (Output_data_plt_arm_standard::do_get_plt_entry_size): Moved to Output_data_plt_arm_short. (Output_data_plt_arm_standard::do_fill_plt_entry): Likewise. (Output_data_plt_arm_standard::plt_entry): Likewise. (Output_data_plt_arm_standard::do_fill_first_plt_entry): Fix variable reference. (Output_data_plt_arm_short): New class. (Output_data_plt_arm_short::do_fill_plt_entry): Error out on too large PLT offsets instead of asserting. (Output_data_plt_arm_long): New class. * options.h (General_options): Define --long-plt flag. Change-Id: Ia61126a09f2213d1ca5c3635ec9e5b36a63f6cf3 --- binutils-2.25/gold/ChangeLog | 17 ++++++ binutils-2.25/gold/arm.cc | 127 ++++++++++++++++++++++++++++++++++++------- binutils-2.25/gold/options.h | 4 ++ 3 files changed, 127 insertions(+), 21 deletions(-) diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index 2ba3b2b..aa93c36 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,3 +1,20 @@ +2015-12-17 Peter Collingbourne + + PR gold/18780 + * arm.cc (Target_arm::do_make_data_plt): Choose PLT generator based + on value of --long-plt flag. + (Output_data_plt_arm_standard::do_get_plt_entry_size): Moved to + Output_data_plt_arm_short. + (Output_data_plt_arm_standard::do_fill_plt_entry): Likewise. + (Output_data_plt_arm_standard::plt_entry): Likewise. + (Output_data_plt_arm_standard::do_fill_first_plt_entry): Fix + variable reference. + (Output_data_plt_arm_short): New class. + (Output_data_plt_arm_short::do_fill_plt_entry): Error out on too large + PLT offsets instead of asserting. + (Output_data_plt_arm_long): New class. + * options.h (General_options): Define --long-plt flag. + 2016-01-15 Han Shen PR gold/19472 - need pc-relative stubs. diff --git a/binutils-2.25/gold/arm.cc b/binutils-2.25/gold/arm.cc index 86920c4..94149d6 100644 --- a/binutils-2.25/gold/arm.cc +++ b/binutils-2.25/gold/arm.cc @@ -62,7 +62,10 @@ template class Output_data_plt_arm; template -class Output_data_plt_arm_standard; +class Output_data_plt_arm_short; + +template +class Output_data_plt_arm_long; template class Stub_table; @@ -2558,7 +2561,11 @@ class Target_arm : public Sized_target<32, big_endian> Output_data_space* got_irelative) { gold_assert(got_plt != NULL && got_irelative != NULL); - return new Output_data_plt_arm_standard( + if (parameters->options().long_plt()) + return new Output_data_plt_arm_long( + layout, got, got_plt, got_irelative); + else + return new Output_data_plt_arm_short( layout, got, got_plt, got_irelative); } @@ -7777,29 +7784,14 @@ class Output_data_plt_arm_standard : public Output_data_plt_arm do_first_plt_entry_offset() const { return sizeof(first_plt_entry); } - // Return the size of a PLT entry. - virtual unsigned int - do_get_plt_entry_size() const - { return sizeof(plt_entry); } - virtual void do_fill_first_plt_entry(unsigned char* pov, Arm_address got_address, Arm_address plt_address); - virtual void - do_fill_plt_entry(unsigned char* pov, - Arm_address got_address, - Arm_address plt_address, - unsigned int got_offset, - unsigned int plt_offset); - private: // Template for the first PLT entry. static const uint32_t first_plt_entry[5]; - - // Template for subsequent PLT entries. - static const uint32_t plt_entry[3]; }; // ARM PLTs. @@ -7827,7 +7819,7 @@ Output_data_plt_arm_standard::do_fill_first_plt_entry( { // Write first PLT entry. All but the last word are constants. const size_t num_first_plt_words = (sizeof(first_plt_entry) - / sizeof(plt_entry[0])); + / sizeof(first_plt_entry[0])); for (size_t i = 0; i < num_first_plt_words - 1; i++) elfcpp::Swap<32, big_endian>::writeval(pov + i * 4, first_plt_entry[i]); // Last word in first PLT entry is &GOT[0] - . @@ -7836,9 +7828,39 @@ Output_data_plt_arm_standard::do_fill_first_plt_entry( } // Subsequent entries in the PLT. +// This class generates short (12-byte) entries, for displacements up to 2^28. template -const uint32_t Output_data_plt_arm_standard::plt_entry[3] = +class Output_data_plt_arm_short : public Output_data_plt_arm_standard +{ + public: + Output_data_plt_arm_short(Layout* layout, + Arm_output_data_got* got, + Output_data_space* got_plt, + Output_data_space* got_irelative) + : Output_data_plt_arm_standard(layout, got, got_plt, got_irelative) + { } + + protected: + // Return the size of a PLT entry. + virtual unsigned int + do_get_plt_entry_size() const + { return sizeof(plt_entry); } + + virtual void + do_fill_plt_entry(unsigned char* pov, + Arm_address got_address, + Arm_address plt_address, + unsigned int got_offset, + unsigned int plt_offset); + + private: + // Template for subsequent PLT entries. + static const uint32_t plt_entry[3]; +}; + +template +const uint32_t Output_data_plt_arm_short::plt_entry[3] = { 0xe28fc600, // add ip, pc, #0xNN00000 0xe28cca00, // add ip, ip, #0xNN000 @@ -7847,7 +7869,7 @@ const uint32_t Output_data_plt_arm_standard::plt_entry[3] = template void -Output_data_plt_arm_standard::do_fill_plt_entry( +Output_data_plt_arm_short::do_fill_plt_entry( unsigned char* pov, Arm_address got_address, Arm_address plt_address, @@ -7856,8 +7878,9 @@ Output_data_plt_arm_standard::do_fill_plt_entry( { int32_t offset = ((got_address + got_offset) - (plt_address + plt_offset + 8)); + if (offset < 0 || offset > 0x0fffffff) + gold_error(_("PLT offset too large, try linking with --long-plt")); - gold_assert(offset >= 0 && offset < 0x0fffffff); uint32_t plt_insn0 = plt_entry[0] | ((offset >> 20) & 0xff); elfcpp::Swap<32, big_endian>::writeval(pov, plt_insn0); uint32_t plt_insn1 = plt_entry[1] | ((offset >> 12) & 0xff); @@ -7866,6 +7889,68 @@ Output_data_plt_arm_standard::do_fill_plt_entry( elfcpp::Swap<32, big_endian>::writeval(pov + 8, plt_insn2); } +// This class generates long (16-byte) entries, for arbitrary displacements. + +template +class Output_data_plt_arm_long : public Output_data_plt_arm_standard +{ + public: + Output_data_plt_arm_long(Layout* layout, + Arm_output_data_got* got, + Output_data_space* got_plt, + Output_data_space* got_irelative) + : Output_data_plt_arm_standard(layout, got, got_plt, got_irelative) + { } + + protected: + // Return the size of a PLT entry. + virtual unsigned int + do_get_plt_entry_size() const + { return sizeof(plt_entry); } + + virtual void + do_fill_plt_entry(unsigned char* pov, + Arm_address got_address, + Arm_address plt_address, + unsigned int got_offset, + unsigned int plt_offset); + + private: + // Template for subsequent PLT entries. + static const uint32_t plt_entry[4]; +}; + +template +const uint32_t Output_data_plt_arm_long::plt_entry[4] = +{ + 0xe28fc200, // add ip, pc, #0xN0000000 + 0xe28cc600, // add ip, ip, #0xNN00000 + 0xe28cca00, // add ip, ip, #0xNN000 + 0xe5bcf000, // ldr pc, [ip, #0xNNN]! +}; + +template +void +Output_data_plt_arm_long::do_fill_plt_entry( + unsigned char* pov, + Arm_address got_address, + Arm_address plt_address, + unsigned int got_offset, + unsigned int plt_offset) +{ + int32_t offset = ((got_address + got_offset) + - (plt_address + plt_offset + 8)); + + uint32_t plt_insn0 = plt_entry[0] | (offset >> 28); + elfcpp::Swap<32, big_endian>::writeval(pov, plt_insn0); + uint32_t plt_insn1 = plt_entry[1] | ((offset >> 20) & 0xff); + elfcpp::Swap<32, big_endian>::writeval(pov + 4, plt_insn1); + uint32_t plt_insn2 = plt_entry[2] | ((offset >> 12) & 0xff); + elfcpp::Swap<32, big_endian>::writeval(pov + 8, plt_insn2); + uint32_t plt_insn3 = plt_entry[3] | (offset & 0xfff); + elfcpp::Swap<32, big_endian>::writeval(pov + 12, plt_insn3); +} + // Write out the PLT. This uses the hand-coded instructions above, // and adjusts them as needed. This is all specified by the arm ELF // Processor Supplement. diff --git a/binutils-2.25/gold/options.h b/binutils-2.25/gold/options.h index db5254b..0fa26f1 100644 --- a/binutils-2.25/gold/options.h +++ b/binutils-2.25/gold/options.h @@ -841,6 +841,10 @@ class General_options "veneer"), NULL); + DEFINE_bool(long_plt, options::TWO_DASHES, '\0', false, + N_("(ARM only) Generate long PLT entries"), + N_("(ARM only) Do not generate long PLT entries")); + DEFINE_bool(g, options::EXACTLY_ONE_DASH, '\0', false, N_("Ignored"), NULL); -- cgit v1.1 From 48ba8648ee02f246c4fb286d7918f750c2b4ea4f Mon Sep 17 00:00:00 2001 From: Rahul Chaudhry Date: Wed, 3 Feb 2016 15:52:58 -0800 Subject: Silence "Erratum 843419 found and fixed" info messages from gold. BUG: 26536732 Tested by building binutils on ubuntu, and using the newly built gold to link volantis binaries. The info messages are gone. This patch is backported from upstream - commit e3dbf58233db3ad72f1ba624dc7f13ffd2728f25 Author: Han Shen Date: Thu Feb 11 09:47:49 2016 -0800 Remove info message for every erratum 843419 found and fixed. 2016-02-11 Rahul Chaudhry * aarch64.cc (Target_aarch64::scan_erratum_843419_span): Remove info message for every erratum 843419 found and fixed. Change-Id: I9792795096c919b006e98fdfdb01b448e597d605 --- binutils-2.25/gold/ChangeLog | 5 +++++ binutils-2.25/gold/aarch64.cc | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index aa93c36..d734a15 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,3 +1,8 @@ +2016-02-11 Rahul Chaudhry + + * aarch64.cc (Target_aarch64::scan_erratum_843419_span): Remove + info message for every erratum 843419 found and fixed. + 2015-12-17 Peter Collingbourne PR gold/18780 diff --git a/binutils-2.25/gold/aarch64.cc b/binutils-2.25/gold/aarch64.cc index 445f324..176c5cb 100644 --- a/binutils-2.25/gold/aarch64.cc +++ b/binutils-2.25/gold/aarch64.cc @@ -8207,10 +8207,6 @@ Target_aarch64::scan_erratum_843419_span( } if (do_report) { - gold_info(_("Erratum 843419 found and fixed at \"%s\", " - "section %d, offset 0x%08x."), - relobj->name().c_str(), shndx, - (unsigned int)(span_start + offset)); unsigned int erratum_insn_offset = span_start + offset + insn_offset; Address erratum_address = -- cgit v1.1 From 066607388945f542727bd5035fb8d84bfd798034 Mon Sep 17 00:00:00 2001 From: Han Shen Date: Thu, 10 Mar 2016 16:58:00 -0800 Subject: Backport upstream CL to fix x86_64 clang test-stlport segfaults. Upstream patch being backported: commit fc5a9bd57cbb974b8fc3aeb9a15d644cd9103451 Author: Cary Coutant Date: Fri Feb 26 07:50:15 2016 -0800 Discard FDEs for zero-length address ranges. 2016-02-26 Egor Kochetov Cary Coutant gold/ PR gold/19735 * ehframe.h (Cie::fde_encoding): New method. * ehframe.cc (Eh_frame::read_fde): Discard FDEs for zero-length address ranges. TESTED=only tested building with 'build.py' BUG=26085687 Change-Id: I52e90fba86b113a557dd4d29d36ecb4c512f3f7a --- binutils-2.25/gold/ChangeLog | 8 ++++++++ binutils-2.25/gold/ehframe.cc | 39 ++++++++++++++++++++++++++++++++++----- binutils-2.25/gold/ehframe.h | 5 +++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index d734a15..fc4250e 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,3 +1,11 @@ +2016-02-26 Egor Kochetov + Cary Coutant + + PR gold/19735 + * ehframe.h (Cie::fde_encoding): New method. + * ehframe.cc (Eh_frame::read_fde): Discard FDEs for zero-length + address ranges. + 2016-02-11 Rahul Chaudhry * aarch64.cc (Target_aarch64::scan_erratum_843419_span): Remove diff --git a/binutils-2.25/gold/ehframe.cc b/binutils-2.25/gold/ehframe.cc index 4f92618..fc45e87 100644 --- a/binutils-2.25/gold/ehframe.cc +++ b/binutils-2.25/gold/ehframe.cc @@ -1010,6 +1010,8 @@ Eh_frame::read_fde(Sized_relobj_file* object, // pointer to a PC relative offset when generating a shared library. relocs->advance(pfdeend - pcontents); + // Find the section index for code that this FDE describes. + // If we have discarded the section, we can also discard the FDE. unsigned int fde_shndx; const int sym_size = elfcpp::Elf_sizes::sym_size; if (symndx >= symbols_size / sym_size) @@ -1018,13 +1020,40 @@ Eh_frame::read_fde(Sized_relobj_file* object, bool is_ordinary; fde_shndx = object->adjust_sym_shndx(symndx, sym.get_st_shndx(), &is_ordinary); + bool is_discarded = (is_ordinary + && fde_shndx != elfcpp::SHN_UNDEF + && fde_shndx < object->shnum() + && !object->is_section_included(fde_shndx)); + + // Fetch the address range field from the FDE. The offset and size + // of the field depends on the PC encoding given in the CIE, but + // it is always an absolute value. If the address range is 0, this + // FDE corresponds to a function that was discarded during optimization + // (too late to discard the corresponding FDE). + uint64_t address_range = 0; + int pc_size = cie->fde_encoding() & 7; + if (pc_size == elfcpp::DW_EH_PE_absptr) + pc_size = size == 32 ? elfcpp::DW_EH_PE_udata4 : elfcpp::DW_EH_PE_udata8; + switch (pc_size) + { + case elfcpp::DW_EH_PE_udata2: + address_range = elfcpp::Swap<16, big_endian>::readval(pfde + 2); + break; + case elfcpp::DW_EH_PE_udata4: + address_range = elfcpp::Swap<32, big_endian>::readval(pfde + 4); + break; + case elfcpp::DW_EH_PE_udata8: + gold_assert(size == 64); + address_range = elfcpp::Swap_unaligned<64, big_endian>::readval(pfde + 8); + break; + default: + // All other cases were rejected in Eh_frame::read_cie. + gold_unreachable(); + } - if (is_ordinary - && fde_shndx != elfcpp::SHN_UNDEF - && fde_shndx < object->shnum() - && !object->is_section_included(fde_shndx)) + if (is_discarded || address_range == 0) { - // This FDE applies to a section which we are discarding. We + // This FDE applies to a discarded function. We // can discard this FDE. this->merge_map_.add_mapping(object, shndx, (pfde - 8) - pcontents, pfdeend - (pfde - 8), -1); diff --git a/binutils-2.25/gold/ehframe.h b/binutils-2.25/gold/ehframe.h index e9c9da8..8c0df99 100644 --- a/binutils-2.25/gold/ehframe.h +++ b/binutils-2.25/gold/ehframe.h @@ -322,6 +322,11 @@ class Cie unsigned int addralign, Eh_frame_hdr* eh_frame_hdr, Post_fdes* post_fdes); + // Return the FDE encoding. + unsigned char + fde_encoding() const + { return this->fde_encoding_; } + friend bool operator<(const Cie&, const Cie&); friend bool operator==(const Cie&, const Cie&); -- cgit v1.1 From 78eb6804689b812b374e2e5d248a96977f13ffd1 Mon Sep 17 00:00:00 2001 From: Yunlian Jiang Date: Fri, 1 Apr 2016 09:50:02 -0700 Subject: Backport upstream CL to fix x86_32 clang segfaults. Upstream patch being backported: commit 84d543b7ed93bf6511cdf45791f4f0b717dfb718 Author: Sriraman Tallam Date: Fri Feb 5 15:07:45 2016 -0800 2016-02-05 Sriraman Tallam * icf.cc (get_rel_addend): New function. (get_section_contents): Move merge section addend computation to a new function. Ignore negative values for SHT_REL and SHT_RELA addends. Fix bug to not read past the length of the section. Fix bug related to addend computation for MERGE sections. Tested via cbuildbot for ChromeOS and build on Android mnc-dr-release for hammerhead --- binutils-2.25/gold/ChangeLog | 10 ++++ binutils-2.25/gold/icf.cc | 115 +++++++++++++++++++++++++------------------ 2 files changed, 78 insertions(+), 47 deletions(-) diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index fc4250e..c222155 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,3 +1,13 @@ +2016-02-05 Sriraman Tallam + + * icf.cc (get_rel_addend): New function. + (get_section_contents): Move merge section addend computation to a + new function. Ignore negative values for SHT_REL and SHT_RELA addends. + Fix bug to not read past the length of the section. + + Fix bug related to addend computation for MERGE sections. + + 2016-02-26 Egor Kochetov Cary Coutant diff --git a/binutils-2.25/gold/icf.cc b/binutils-2.25/gold/icf.cc index ad88715..1ae1829 100644 --- a/binutils-2.25/gold/icf.cc +++ b/binutils-2.25/gold/icf.cc @@ -213,6 +213,45 @@ preprocess_for_unique_sections(const std::vector& id_section, } } +// For SHF_MERGE sections that use REL relocations, the addend is stored in +// the text section at the relocation offset. Read the addend value given +// the pointer to the addend in the text section and the addend size. +// Update the addend value if a valid addend is found. +// Parameters: +// RELOC_ADDEND_PTR : Pointer to the addend in the text section. +// ADDEND_SIZE : The size of the addend. +// RELOC_ADDEND_VALUE : Pointer to the addend that is updated. + +inline void +get_rel_addend(const unsigned char* reloc_addend_ptr, + const unsigned int addend_size, + uint64_t* reloc_addend_value) +{ + switch (addend_size) + { + case 0: + break; + case 1: + *reloc_addend_value = + read_from_pointer<8>(reloc_addend_ptr); + break; + case 2: + *reloc_addend_value = + read_from_pointer<16>(reloc_addend_ptr); + break; + case 4: + *reloc_addend_value = + read_from_pointer<32>(reloc_addend_ptr); + break; + case 8: + *reloc_addend_value = + read_from_pointer<64>(reloc_addend_ptr); + break; + default: + gold_unreachable(); + } +} + // This returns the buffer containing the section's contents, both // text and relocs. Relocs are differentiated as those pointing to // sections that could be folded and those that cannot. Only relocs @@ -397,58 +436,36 @@ get_section_contents(bool first_iteration, uint64_t entsize = (it_v->first)->section_entsize(it_v->second); long long offset = it_a->first; - - unsigned long long addend = it_a->second; - // Ignoring the addend when it is a negative value. See the - // comments in Merged_symbol_value::Value in object.h. - if (addend < 0xffffff00) - offset = offset + addend; - - // For SHT_REL relocation sections, the addend is stored in the - // text section at the relocation offset. - uint64_t reloc_addend_value = 0; + // Handle SHT_RELA and SHT_REL addends, only one of these + // addends exists. + // Get the SHT_RELA addend. For RELA relocations, we have + // the addend from the relocation. + uint64_t reloc_addend_value = it_a->second; + + // Handle SHT_REL addends. + // For REL relocations, we need to fetch the addend from the + // section contents. const unsigned char* reloc_addend_ptr = contents + static_cast(*it_o); - switch(*it_addend_size) - { - case 0: - { - break; - } - case 1: - { - reloc_addend_value = - read_from_pointer<8>(reloc_addend_ptr); - break; - } - case 2: - { - reloc_addend_value = - read_from_pointer<16>(reloc_addend_ptr); - break; - } - case 4: - { - reloc_addend_value = - read_from_pointer<32>(reloc_addend_ptr); - break; - } - case 8: - { - reloc_addend_value = - read_from_pointer<64>(reloc_addend_ptr); - break; - } - default: - gold_unreachable(); - } - offset = offset + reloc_addend_value; + + // Update the addend value with the SHT_REL addend if + // available. + get_rel_addend(reloc_addend_ptr, *it_addend_size, + &reloc_addend_value); + + // Ignore the addend when it is a negative value. See the + // comments in Merged_symbol_value::value in object.h. + if (reloc_addend_value < 0xffffff00) + offset = offset + reloc_addend_value; section_size_type secn_len; + const unsigned char* str_contents = (it_v->first)->section_contents(it_v->second, &secn_len, false) + offset; + gold_assert (offset < (long long) secn_len); + if ((secn_flags & elfcpp::SHF_STRINGS) != 0) { // String merge section. @@ -489,10 +506,14 @@ get_section_contents(bool first_iteration, } else { - // Use the entsize to determine the length. - buffer.append(reinterpret_cast secn_len) + bufsize = secn_len - offset; + buffer.append(reinterpret_cast(str_contents), - entsize); + bufsize); } buffer.append("@"); } -- cgit v1.1 From 405fb1a937f705403a28d5591a1bb530b4efe9ed Mon Sep 17 00:00:00 2001 From: Nikola Veljkovic Date: Wed, 6 Apr 2016 19:46:06 +0200 Subject: Revert "Fix DT_MIPS_RLD_MAP_REL tag for n64 target and 32-bit host." This reverts commit 7e80b87f7ff08c7c13f38d76a953b0cd753403aa. Conflicts: binutils-2.25/bfd/ChangeLog Change-Id: I1c0e3d5e9483001db6a4ffe807d6246c2f3ca126 --- binutils-2.25/bfd/ChangeLog | 6 ------ binutils-2.25/bfd/elfxx-mips.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/binutils-2.25/bfd/ChangeLog b/binutils-2.25/bfd/ChangeLog index f124354..ab62ce4 100644 --- a/binutils-2.25/bfd/ChangeLog +++ b/binutils-2.25/bfd/ChangeLog @@ -6,12 +6,6 @@ float only when Tag_ABI_VFP_args is 1, using new enum value AEABI_VFP_args_vfp to check that. -2015-07-23 Joseph Myers - - * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections) - : Add target address to host address - difference, not to host pointer. - 2015-04-01 Tejas Belagod Marcus Shawcroft Jiong Wang diff --git a/binutils-2.25/bfd/elfxx-mips.c b/binutils-2.25/bfd/elfxx-mips.c index 998549d..2f46602 100644 --- a/binutils-2.25/bfd/elfxx-mips.c +++ b/binutils-2.25/bfd/elfxx-mips.c @@ -11515,7 +11515,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, s = h->root.u.def.section; dt_addr = (sdyn->output_section->vma + sdyn->output_offset - + (b - sdyn->contents)); + + b - sdyn->contents); rld_addr = (s->output_section->vma + s->output_offset + h->root.u.def.value); dyn.d_un.d_ptr = rld_addr - dt_addr; -- cgit v1.1 From 42704eb7fb240faa66f388f6a28d1e2d1c7cf470 Mon Sep 17 00:00:00 2001 From: Nikola Veljkovic Date: Wed, 6 Apr 2016 19:46:14 +0200 Subject: Revert "Add support for the new tag DT_MIPS_RLD_MAP2." This reverts commit 51d71fd2cc99f309cb792cc48ae910baeb92b2a0. --- binutils-2.25/bfd/elfxx-mips.c | 33 +++------------------------------ binutils-2.25/binutils/readelf.c | 1 - binutils-2.25/include/elf/mips.h | 3 --- 3 files changed, 3 insertions(+), 34 deletions(-) diff --git a/binutils-2.25/bfd/elfxx-mips.c b/binutils-2.25/bfd/elfxx-mips.c index 2f46602..a876ff3 100644 --- a/binutils-2.25/bfd/elfxx-mips.c +++ b/binutils-2.25/bfd/elfxx-mips.c @@ -7616,7 +7616,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) htab->sstubs = s; if (!mips_elf_hash_table (info)->use_rld_obj_head - && info->executable + && !info->shared && bfd_get_linker_section (abfd, ".rld_map") == NULL) { s = bfd_make_section_anyway_with_flags (abfd, ".rld_map", @@ -7680,7 +7680,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) (void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); } - if (info->executable) + if (!info->shared) { const char *name; @@ -9721,7 +9721,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, info->combreloc = 0; } } - else if (info->executable + else if (! info->shared && ! mips_elf_hash_table (info)->use_rld_obj_head && CONST_STRNEQ (name, ".rld_map")) { @@ -9784,10 +9784,6 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0)) return FALSE; - if (info->executable - && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP2, 0)) - return FALSE; - /* The DT_DEBUG entry may be filled in by the dynamic linker and used by the debugger. */ if (info->executable @@ -11501,27 +11497,6 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, } break; - case DT_MIPS_RLD_MAP2: - { - struct elf_link_hash_entry *h; - bfd_vma dt_addr, rld_addr; - h = mips_elf_hash_table (info)->rld_symbol; - if (!h) - { - dyn_to_skip = MIPS_ELF_DYN_SIZE (dynobj); - swap_out_p = FALSE; - break; - } - s = h->root.u.def.section; - - dt_addr = (sdyn->output_section->vma + sdyn->output_offset - + b - sdyn->contents); - rld_addr = (s->output_section->vma + s->output_offset - + h->root.u.def.value); - dyn.d_un.d_ptr = rld_addr - dt_addr; - } - break; - case DT_MIPS_OPTIONS: s = (bfd_get_section_by_name (output_bfd, MIPS_ELF_OPTIONS_SECTION_NAME (output_bfd))); @@ -15446,8 +15421,6 @@ _bfd_mips_elf_get_target_dtag (bfd_vma dtag) return "MIPS_HIPAGENO"; case DT_MIPS_RLD_MAP: return "MIPS_RLD_MAP"; - case DT_MIPS_RLD_MAP2: - return "MIPS_RLD_MAP2"; case DT_MIPS_DELTA_CLASS: return "MIPS_DELTA_CLASS"; case DT_MIPS_DELTA_CLASS_NO: diff --git a/binutils-2.25/binutils/readelf.c b/binutils-2.25/binutils/readelf.c index 83518c7..5ddcb55 100644 --- a/binutils-2.25/binutils/readelf.c +++ b/binutils-2.25/binutils/readelf.c @@ -1618,7 +1618,6 @@ get_mips_dynamic_type (unsigned long type) case DT_MIPS_GOTSYM: return "MIPS_GOTSYM"; case DT_MIPS_HIPAGENO: return "MIPS_HIPAGENO"; case DT_MIPS_RLD_MAP: return "MIPS_RLD_MAP"; - case DT_MIPS_RLD_MAP2: return "MIPS_RLD_MAP2"; case DT_MIPS_DELTA_CLASS: return "MIPS_DELTA_CLASS"; case DT_MIPS_DELTA_CLASS_NO: return "MIPS_DELTA_CLASS_NO"; case DT_MIPS_DELTA_INSTANCE: return "MIPS_DELTA_INSTANCE"; diff --git a/binutils-2.25/include/elf/mips.h b/binutils-2.25/include/elf/mips.h index 87704e0..22aefa6 100644 --- a/binutils-2.25/include/elf/mips.h +++ b/binutils-2.25/include/elf/mips.h @@ -748,9 +748,6 @@ extern void bfd_mips_elf32_swap_reginfo_out /* Points to the base of a writable PLT. */ #define DT_MIPS_RWPLT 0x70000034 - -/* Address of run time loader map, used for debugging. */ -#define DT_MIPS_RLD_MAP2 0x70000035 /* Flags which may appear in a DT_MIPS_FLAGS entry. */ -- cgit v1.1 From a696d1d39e22f355b9f7762a0beeed014df761da Mon Sep 17 00:00:00 2001 From: Matthew Fortune Date: Wed, 6 Apr 2016 13:43:18 +0200 Subject: Add support for DT_MIPS_RLD_MAP_REL. This tag makes it possible to access the debug map when debugging position independent executables. bfd/ * elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Use executable instead of !shared to indicate an application vs shared library. (_bfd_mips_elf_size_dynamic_sections): Likewise. (_bfd_mips_elf_finish_dynamic_sections): Handle DT_MIPS_RLD_MAP_REL. (_bfd_mips_elf_get_target_dtag): Likewise. binutils/ * readelf.c (get_mips_dynamic_type): Handle DT_MIPS_RLD_MAP_REL. include/ * elf/mips.h (DT_MIPS_RLD_MAP_REL): New macro. ld/testsuite/ * ld-mips-elf/pic-and-nonpic-3b.ad: Adjust for extra dynamic tag. * ld-mips-elf/pic-and-nonpic-4b.ad: Likewise. * ld-mips-elf/pic-and-nonpic-5b.ad: Likewise. * ld-mips-elf/pic-and-nonpic-6-n32.ad: Likewise. * ld-mips-elf/pic-and-nonpic-6-n64.ad: Likewise. * ld-mips-elf/pic-and-nonpic-6-o32.ad: Likewise. * ld-mips-elf/tlsdyn-o32-1.d: Likewise. * ld-mips-elf/tlsdyn-o32-1.got: Likewise. * ld-mips-elf/tlsdyn-o32-2.d: Likewise. * ld-mips-elf/tlsdyn-o32-2.got: Likewise. * ld-mips-elf/tlsdyn-o32-3.d: Likewise. * ld-mips-elf/tlsdyn-o32-3.got: Likewise. * ld-mips-elf/tlsdyn-o32.d: Likewise. * ld-mips-elf/tlsdyn-o32.got: Likewise. * ld-mips-elf/pie-n32.d: New file. * ld-mips-elf/pie-n64.d: Likewise. * ld-mips-elf/pie-o32.d: Likewise. * ld-mips-elf/pie.s: Likewise. * ld-mips-elf/mips-elf.exp: Add new tests. Change-Id: I9fa38c2876a39c29ae3718bae0ade55c677f96fd --- binutils-2.25/bfd/ChangeLog | 8 +++++ binutils-2.25/bfd/elfxx-mips.c | 38 ++++++++++++++++++++-- binutils-2.25/binutils/ChangeLog | 4 +++ binutils-2.25/binutils/readelf.c | 1 + binutils-2.25/include/ChangeLog | 4 +++ binutils-2.25/include/elf/mips.h | 3 ++ binutils-2.25/ld/testsuite/ChangeLog | 22 +++++++++++++ .../ld/testsuite/ld-mips-elf/mips-elf.exp | 9 +++++ .../ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.ad | 1 + .../ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.ad | 1 + .../ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.ad | 1 + .../testsuite/ld-mips-elf/pic-and-nonpic-6-n32.ad | 1 + .../testsuite/ld-mips-elf/pic-and-nonpic-6-n64.ad | 1 + .../testsuite/ld-mips-elf/pic-and-nonpic-6-o32.ad | 1 + binutils-2.25/ld/testsuite/ld-mips-elf/pie-n32.d | 23 +++++++++++++ binutils-2.25/ld/testsuite/ld-mips-elf/pie-n64.d | 23 +++++++++++++ binutils-2.25/ld/testsuite/ld-mips-elf/pie-o32.d | 23 +++++++++++++ binutils-2.25/ld/testsuite/ld-mips-elf/pie.s | 6 ++++ .../ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d | 4 +-- .../ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got | 2 +- .../ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d | 4 +-- .../ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got | 2 +- .../ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d | 4 +-- .../ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got | 2 +- .../ld/testsuite/ld-mips-elf/tlsdyn-o32.d | 2 +- .../ld/testsuite/ld-mips-elf/tlsdyn-o32.got | 2 +- 26 files changed, 178 insertions(+), 14 deletions(-) create mode 100644 binutils-2.25/ld/testsuite/ld-mips-elf/pie-n32.d create mode 100644 binutils-2.25/ld/testsuite/ld-mips-elf/pie-n64.d create mode 100644 binutils-2.25/ld/testsuite/ld-mips-elf/pie-o32.d create mode 100644 binutils-2.25/ld/testsuite/ld-mips-elf/pie.s diff --git a/binutils-2.25/bfd/ChangeLog b/binutils-2.25/bfd/ChangeLog index ab62ce4..f3c81a8 100644 --- a/binutils-2.25/bfd/ChangeLog +++ b/binutils-2.25/bfd/ChangeLog @@ -1,3 +1,11 @@ +2015-06-26 Matthew Fortune + + * elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Use executable + instead of !shared to indicate an application vs shared library. + (_bfd_mips_elf_size_dynamic_sections): Likewise. + (_bfd_mips_elf_finish_dynamic_sections): Handle DT_MIPS_RLD_MAP_REL. + (_bfd_mips_elf_get_target_dtag): Likewise. + 2014-12-25 Thomas Preud'homme * elf32-arm.c (elf32_arm_merge_eabi_attributes): Handle new diff --git a/binutils-2.25/bfd/elfxx-mips.c b/binutils-2.25/bfd/elfxx-mips.c index a876ff3..3b77759 100644 --- a/binutils-2.25/bfd/elfxx-mips.c +++ b/binutils-2.25/bfd/elfxx-mips.c @@ -7616,7 +7616,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) htab->sstubs = s; if (!mips_elf_hash_table (info)->use_rld_obj_head - && !info->shared + && info->executable && bfd_get_linker_section (abfd, ".rld_map") == NULL) { s = bfd_make_section_anyway_with_flags (abfd, ".rld_map", @@ -7680,7 +7680,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) (void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); } - if (!info->shared) + if (info->executable) { const char *name; @@ -9721,7 +9721,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, info->combreloc = 0; } } - else if (! info->shared + else if (info->executable && ! mips_elf_hash_table (info)->use_rld_obj_head && CONST_STRNEQ (name, ".rld_map")) { @@ -9784,6 +9784,10 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0)) return FALSE; + if (info->executable + && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP_REL, 0)) + return FALSE; + /* The DT_DEBUG entry may be filled in by the dynamic linker and used by the debugger. */ if (info->executable @@ -11492,11 +11496,37 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, break; } s = h->root.u.def.section; + + /* The MIPS_RLD_MAP tag stores the absolute address of the + debug pointer. */ dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset + h->root.u.def.value); } break; + case DT_MIPS_RLD_MAP_REL: + { + struct elf_link_hash_entry *h; + bfd_vma dt_addr, rld_addr; + h = mips_elf_hash_table (info)->rld_symbol; + if (!h) + { + dyn_to_skip = MIPS_ELF_DYN_SIZE (dynobj); + swap_out_p = FALSE; + break; + } + s = h->root.u.def.section; + + /* The MIPS_RLD_MAP_REL tag stores the offset to the debug + pointer, relative to the address of the tag. */ + dt_addr = (sdyn->output_section->vma + sdyn->output_offset + + b - sdyn->contents); + rld_addr = (s->output_section->vma + s->output_offset + + h->root.u.def.value); + dyn.d_un.d_ptr = rld_addr - dt_addr; + } + break; + case DT_MIPS_OPTIONS: s = (bfd_get_section_by_name (output_bfd, MIPS_ELF_OPTIONS_SECTION_NAME (output_bfd))); @@ -15421,6 +15451,8 @@ _bfd_mips_elf_get_target_dtag (bfd_vma dtag) return "MIPS_HIPAGENO"; case DT_MIPS_RLD_MAP: return "MIPS_RLD_MAP"; + case DT_MIPS_RLD_MAP_REL: + return "MIPS_RLD_MAP_REL"; case DT_MIPS_DELTA_CLASS: return "MIPS_DELTA_CLASS"; case DT_MIPS_DELTA_CLASS_NO: diff --git a/binutils-2.25/binutils/ChangeLog b/binutils-2.25/binutils/ChangeLog index 9f7e17c..3e0ea7c 100644 --- a/binutils-2.25/binutils/ChangeLog +++ b/binutils-2.25/binutils/ChangeLog @@ -1,3 +1,7 @@ +2015-06-26 Matthew Fortune + + * readelf.c (get_mips_dynamic_type): Handle DT_MIPS_RLD_MAP_REL. + 2014-12-25 Thomas Preud'homme * readelf.c (arm_attr_tag_ABI_VFP_args): Add "compatible". diff --git a/binutils-2.25/binutils/readelf.c b/binutils-2.25/binutils/readelf.c index 5ddcb55..e59dd2e 100644 --- a/binutils-2.25/binutils/readelf.c +++ b/binutils-2.25/binutils/readelf.c @@ -1618,6 +1618,7 @@ get_mips_dynamic_type (unsigned long type) case DT_MIPS_GOTSYM: return "MIPS_GOTSYM"; case DT_MIPS_HIPAGENO: return "MIPS_HIPAGENO"; case DT_MIPS_RLD_MAP: return "MIPS_RLD_MAP"; + case DT_MIPS_RLD_MAP_REL: return "MIPS_RLD_MAP_REL"; case DT_MIPS_DELTA_CLASS: return "MIPS_DELTA_CLASS"; case DT_MIPS_DELTA_CLASS_NO: return "MIPS_DELTA_CLASS_NO"; case DT_MIPS_DELTA_INSTANCE: return "MIPS_DELTA_INSTANCE"; diff --git a/binutils-2.25/include/ChangeLog b/binutils-2.25/include/ChangeLog index 0204432..27f0e43 100644 --- a/binutils-2.25/include/ChangeLog +++ b/binutils-2.25/include/ChangeLog @@ -1,3 +1,7 @@ +2015-06-26 Matthew Fortune + + * elf/mips.h (DT_MIPS_RLD_MAP_REL): New macro. + 2014-10-30 Andrew Pinski * elf/mips.h (AFL_EXT_OCTEON3): Define. diff --git a/binutils-2.25/include/elf/mips.h b/binutils-2.25/include/elf/mips.h index 22aefa6..537c089 100644 --- a/binutils-2.25/include/elf/mips.h +++ b/binutils-2.25/include/elf/mips.h @@ -748,6 +748,9 @@ extern void bfd_mips_elf32_swap_reginfo_out /* Points to the base of a writable PLT. */ #define DT_MIPS_RWPLT 0x70000034 + +/* Relative offset of run time loader map, used for debugging. */ +#define DT_MIPS_RLD_MAP_REL 0x70000035 /* Flags which may appear in a DT_MIPS_FLAGS entry. */ diff --git a/binutils-2.25/ld/testsuite/ChangeLog b/binutils-2.25/ld/testsuite/ChangeLog index 1526978..dcddad5 100644 --- a/binutils-2.25/ld/testsuite/ChangeLog +++ b/binutils-2.25/ld/testsuite/ChangeLog @@ -1,3 +1,25 @@ +2015-06-26 Matthew Fortune + + * ld-mips-elf/pic-and-nonpic-3b.ad: Adjust for extra dynamic tag. + * ld-mips-elf/pic-and-nonpic-4b.ad: Likewise. + * ld-mips-elf/pic-and-nonpic-5b.ad: Likewise. + * ld-mips-elf/pic-and-nonpic-6-n32.ad: Likewise. + * ld-mips-elf/pic-and-nonpic-6-n64.ad: Likewise. + * ld-mips-elf/pic-and-nonpic-6-o32.ad: Likewise. + * ld-mips-elf/tlsdyn-o32-1.d: Likewise. + * ld-mips-elf/tlsdyn-o32-1.got: Likewise. + * ld-mips-elf/tlsdyn-o32-2.d: Likewise. + * ld-mips-elf/tlsdyn-o32-2.got: Likewise. + * ld-mips-elf/tlsdyn-o32-3.d: Likewise. + * ld-mips-elf/tlsdyn-o32-3.got: Likewise. + * ld-mips-elf/tlsdyn-o32.d: Likewise. + * ld-mips-elf/tlsdyn-o32.got: Likewise. + * ld-mips-elf/pie-n32.d: New file. + * ld-mips-elf/pie-n64.d: Likewise. + * ld-mips-elf/pie-o32.d: Likewise. + * ld-mips-elf/pie.s: Likewise. + * ld-mips-elf/mips-elf.exp: Add new tests. + 2014-12-25 Thomas Preud'homme * ld-arm/attr-merge-2a.s: Add Tag_ABI_VFP_args. diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/mips-elf.exp b/binutils-2.25/ld/testsuite/ld-mips-elf/mips-elf.exp index 21c809f..c587d57 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -186,6 +186,15 @@ if { $linux_gnu } { } } +# Test PIE debug dynamic tags +if { $linux_gnu } { + run_dump_test "pie-o32" + if { $has_newabi } { + run_dump_test "pie-n32" + run_dump_test "pie-n64" + } +} + if $has_newabi { if { $embedded_elf } { run_dump_test "elf-rel-got-n32-embed" \ diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.ad b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.ad index 227d15d..9f5ca90 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.ad +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.ad @@ -8,6 +8,7 @@ Dynamic section at offset .* contains .*: 0x0000000a \(STRSZ\) .* 0x0000000b \(SYMENT\) .* 0x70000016 \(MIPS_RLD_MAP\) * 0x80000 + 0x70000035 \(MIPS_RLD_MAP_REL\) .* 0x00000015 \(DEBUG\) * 0x0 0x00000003 \(PLTGOT\) * 0xa0000 0x70000001 \(MIPS_RLD_VERSION\) * 1 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.ad b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.ad index e14a2d3..1bea044 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.ad +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.ad @@ -8,6 +8,7 @@ Dynamic section at offset .* contains .*: 0x0000000a \(STRSZ\) .* 0x0000000b \(SYMENT\) .* 0x70000016 \(MIPS_RLD_MAP\) * 0x80000 + 0x70000035 \(MIPS_RLD_MAP_REL\) .* 0x00000015 \(DEBUG\) * 0x0 0x00000003 \(PLTGOT\) * 0xa0000 0x00000011 \(REL\) * 0x43000 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.ad b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.ad index d7a672f..972ace1 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.ad +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.ad @@ -9,6 +9,7 @@ Dynamic section at offset .* contains .*: 0x0000000a \(STRSZ\) .* 0x0000000b \(SYMENT\) .* 0x70000016 \(MIPS_RLD_MAP\) * 0x80000 + 0x70000035 \(MIPS_RLD_MAP_REL\) .* 0x00000015 \(DEBUG\) * 0x0 0x00000016 \(TEXTREL\) * 0x0 0x00000003 \(PLTGOT\) * 0xa0000 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.ad b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.ad index 5df3c6c..28ee34a 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.ad +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.ad @@ -8,6 +8,7 @@ Dynamic section at offset .* contains .*: 0x0000000a \(STRSZ\) .* 0x0000000b \(SYMENT\) .* 0x70000016 \(MIPS_RLD_MAP\) * 0x80000 + 0x70000035 \(MIPS_RLD_MAP_REL\) .* 0x00000015 \(DEBUG\) * 0x0 0x00000003 \(PLTGOT\) * 0xa0000 0x00000011 \(REL\) * 0x43000 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.ad b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.ad index d8fc300..7b2ce4c 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.ad +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.ad @@ -8,6 +8,7 @@ Dynamic section at offset .* contains .*: 0x0+0000000a \(STRSZ\) .* 0x0+0000000b \(SYMENT\) .* 0x0+70000016 \(MIPS_RLD_MAP\) * 0x80000 + 0x0+70000035 \(MIPS_RLD_MAP_REL\) .* 0x0+00000015 \(DEBUG\) * 0x0 0x0+00000003 \(PLTGOT\) * 0xa0000 0x0+00000011 \(REL\) * 0x43000 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.ad b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.ad index 5df3c6c..28ee34a 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.ad +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.ad @@ -8,6 +8,7 @@ Dynamic section at offset .* contains .*: 0x0000000a \(STRSZ\) .* 0x0000000b \(SYMENT\) .* 0x70000016 \(MIPS_RLD_MAP\) * 0x80000 + 0x70000035 \(MIPS_RLD_MAP_REL\) .* 0x00000015 \(DEBUG\) * 0x0 0x00000003 \(PLTGOT\) * 0xa0000 0x00000011 \(REL\) * 0x43000 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pie-n32.d b/binutils-2.25/ld/testsuite/ld-mips-elf/pie-n32.d new file mode 100644 index 0000000..bcfbcd2 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pie-n32.d @@ -0,0 +1,23 @@ +#source: pie.s +#as: -march=from-abi -mabi=n32 -EB +#ld: -melf32btsmipn32 -pie +#readelf: -d + +Dynamic section at offset 0x180 contains 16 entries: + Tag * Type * Name/Value + 0x00000004 \(HASH\) * 0x228 + 0x00000005 \(STRTAB\) * 0x304 + 0x00000006 \(SYMTAB\) * 0x264 + 0x0000000a \(STRSZ\) * 72 \(bytes\) + 0x0000000b \(SYMENT\) * 16 \(bytes\) + 0x70000035 \(MIPS_RLD_MAP_REL\) * 0x101b8 + 0x00000015 \(DEBUG\) * 0x0 + 0x00000003 \(PLTGOT\) * 0x10370 + 0x70000001 \(MIPS_RLD_VERSION\) * 1 + 0x70000005 \(MIPS_FLAGS\) * NOTPOT + 0x70000006 \(MIPS_BASE_ADDRESS\) * 0x0 + 0x7000000a \(MIPS_LOCAL_GOTNO\) * 2 + 0x70000011 \(MIPS_SYMTABNO\) * 10 + 0x70000012 \(MIPS_UNREFEXTNO\) * 13 + 0x70000013 \(MIPS_GOTSYM\) * 0xa + 0x00000000 \(NULL\) * 0x0 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pie-n64.d b/binutils-2.25/ld/testsuite/ld-mips-elf/pie-n64.d new file mode 100644 index 0000000..bf2238c --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pie-n64.d @@ -0,0 +1,23 @@ +#source: pie.s +#as: -march=from-abi -mabi=64 -EB +#ld: -melf64btsmip -pie +#readelf: -d + +Dynamic section at offset 0x208 contains 16 entries: + Tag * Type * Name/Value + 0x0+00000004 \(HASH\) * 0x358 + 0x0+00000005 \(STRTAB\) * 0x488 + 0x0+00000006 \(SYMTAB\) * 0x398 + 0x0+0000000a \(STRSZ\) * 72 \(bytes\) + 0x0+0000000b \(SYMENT\) * 24 \(bytes\) + 0x0+70000035 \(MIPS_RLD_MAP_REL\) * 0x102a8 + 0x0+00000015 \(DEBUG\) * 0x0 + 0x0+00000003 \(PLTGOT\) * 0x10510 + 0x0+70000001 \(MIPS_RLD_VERSION\) * 1 + 0x0+70000005 \(MIPS_FLAGS\) * NOTPOT + 0x0+70000006 \(MIPS_BASE_ADDRESS\) * 0x0 + 0x0+7000000a \(MIPS_LOCAL_GOTNO\) * 2 + 0x0+70000011 \(MIPS_SYMTABNO\) * 10 + 0x0+70000012 \(MIPS_UNREFEXTNO\) * 13 + 0x0+70000013 \(MIPS_GOTSYM\) * 0xa + 0x0+00000000 \(NULL\) * 0x0 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pie-o32.d b/binutils-2.25/ld/testsuite/ld-mips-elf/pie-o32.d new file mode 100644 index 0000000..5a9a308 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pie-o32.d @@ -0,0 +1,23 @@ +#source: pie.s +#as: -mabi=32 -EB +#ld: -melf32btsmip -pie +#readelf: -d + +Dynamic section at offset 0x178 contains 16 entries: + Tag * Type * Name/Value + 0x00000004 \(HASH\) * 0x220 + 0x00000005 \(STRTAB\) * 0x2fc + 0x00000006 \(SYMTAB\) * 0x25c + 0x0000000a \(STRSZ\) * 72 \(bytes\) + 0x0000000b \(SYMENT\) * 16 \(bytes\) + 0x70000035 \(MIPS_RLD_MAP_REL\) * 0x101c0 + 0x00000015 \(DEBUG\) * 0x0 + 0x00000003 \(PLTGOT\) * 0x10370 + 0x70000001 \(MIPS_RLD_VERSION\) * 1 + 0x70000005 \(MIPS_FLAGS\) * NOTPOT + 0x70000006 \(MIPS_BASE_ADDRESS\) * 0x0 + 0x7000000a \(MIPS_LOCAL_GOTNO\) * 2 + 0x70000011 \(MIPS_SYMTABNO\) * 10 + 0x70000012 \(MIPS_UNREFEXTNO\) * 13 + 0x70000013 \(MIPS_GOTSYM\) * 0xa + 0x00000000 \(NULL\) * 0x0 diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/pie.s b/binutils-2.25/ld/testsuite/ld-mips-elf/pie.s new file mode 100644 index 0000000..c7f2b20 --- /dev/null +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/pie.s @@ -0,0 +1,6 @@ + .abicalls + .global __start + .ent __start +__start: + jr $31 + .end __start diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d index ca52d8b..6b8f96c 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d @@ -5,7 +5,7 @@ Disassembly of section .text: .* <__start>: .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7c40 addiu gp,gp,31808 + .*: 279c7c30 addiu gp,gp,31792 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) @@ -55,7 +55,7 @@ Disassembly of section .text: .* : .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7b80 addiu gp,gp,31616 + .*: 279c7b70 addiu gp,gp,31600 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got index d70fdd0..86eba9c 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got @@ -13,6 +13,6 @@ OFFSET TYPE VALUE Contents of section .got: - 10000020 00000000 80000000 0040047c 00000000 ................ + 10000020 00000000 80000000 0040048c 00000000 .........@...... 10000030 00000000 00000000 00000000 00000000 ................ 10000040 00000000 00000001 00000000 ............ diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d index ca52d8b..6b8f96c 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d @@ -5,7 +5,7 @@ Disassembly of section .text: .* <__start>: .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7c40 addiu gp,gp,31808 + .*: 279c7c30 addiu gp,gp,31792 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) @@ -55,7 +55,7 @@ Disassembly of section .text: .* : .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7b80 addiu gp,gp,31616 + .*: 279c7b70 addiu gp,gp,31600 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got index 6b00157..434820d 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got @@ -13,6 +13,6 @@ OFFSET TYPE VALUE Contents of section .got: - 10000020 00000000 80000000 0040047c 00000000 .* + 10000020 00000000 80000000 0040048c 00000000 .* 10000030 00000000 00000000 00000000 00000000 .* 10000040 00000000 00000001 00000000 .* diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d index 78eb882..758a4f2 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d @@ -5,7 +5,7 @@ Disassembly of section .text: .* : .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7c40 addiu gp,gp,31808 + .*: 279c7c30 addiu gp,gp,31792 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) @@ -51,7 +51,7 @@ Disassembly of section .text: .* <__start>: .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7b90 addiu gp,gp,31632 + .*: 279c7b80 addiu gp,gp,31616 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got index 01eb44f..043d491 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got @@ -13,6 +13,6 @@ OFFSET TYPE VALUE Contents of section .got: - 10000020 00000000 80000000 0040052c 00000000 .* + 10000020 00000000 80000000 0040053c 00000000 .* 10000030 00000000 00000000 00000000 00000000 .* 10000040 00000000 00000001 00000000 .* diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32.d b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32.d index 699035b..ea50960 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32.d +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32.d @@ -5,7 +5,7 @@ Disassembly of section .text: .* <__start>: .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7bf0 addiu gp,gp,31728 + .*: 279c7be0 addiu gp,gp,31712 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) diff --git a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32.got b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32.got index a1587a6..7942188 100644 --- a/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32.got +++ b/binutils-2.25/ld/testsuite/ld-mips-elf/tlsdyn-o32.got @@ -13,6 +13,6 @@ OFFSET TYPE VALUE Contents of section .got: - 10000020 00000000 80000000 004004cc 00000000 ................ + 10000020 00000000 80000000 004004dc 00000000 .........@...... 10000030 00000000 00000000 00000001 00000000 ................ 10000040 00000000 00000000 00000000 ............ -- cgit v1.1 From d929cfd50d770364fd652d252abc19598b0cc84c Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 27 Jul 2015 16:04:40 +0200 Subject: Fix DT_MIPS_RLD_MAP_REL tag for n64 target and 32-bit host. Cherry-picked from upstream: d5cff5df74b18e1e5ed94de8f4c9adee3ffd95c6 For the case of MIPS n64 target and 32-bit host, the computation of the DT_MIPS_RLD_MAP_REL tag involves sdyn->output_section->vma + sdyn->output_offset (64-bit) being added to b (32-bit host pointer), so losing the high part and resulting in an incorrect DT_MIPS_RLD_MAP_REL tag, and all dynamically linked glibc tests failing for n64. This patch fixes this (spot-tested with glibc tests; however, I don't have a self-contained testcase for this bug). * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections) : Add target address to host address difference, not to host pointer. Change-Id: If4984d632723a36a3d6c739a96706b5636f975bc Conflicts: binutils-2.25/bfd/ChangeLog --- binutils-2.25/bfd/ChangeLog | 6 ++++++ binutils-2.25/bfd/elfxx-mips.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/binutils-2.25/bfd/ChangeLog b/binutils-2.25/bfd/ChangeLog index f3c81a8..f229d66 100644 --- a/binutils-2.25/bfd/ChangeLog +++ b/binutils-2.25/bfd/ChangeLog @@ -1,3 +1,9 @@ +2015-07-23 Joseph Myers + + * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections) + : Add target address to host address + difference, not to host pointer. + 2015-06-26 Matthew Fortune * elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Use executable diff --git a/binutils-2.25/bfd/elfxx-mips.c b/binutils-2.25/bfd/elfxx-mips.c index 3b77759..02440cd 100644 --- a/binutils-2.25/bfd/elfxx-mips.c +++ b/binutils-2.25/bfd/elfxx-mips.c @@ -11520,7 +11520,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, /* The MIPS_RLD_MAP_REL tag stores the offset to the debug pointer, relative to the address of the tag. */ dt_addr = (sdyn->output_section->vma + sdyn->output_offset - + b - sdyn->contents); + + (b - sdyn->contents)); rld_addr = (s->output_section->vma + s->output_offset + h->root.u.def.value); dyn.d_un.d_ptr = rld_addr - dt_addr; -- cgit v1.1 From 21efffa54e136e1b45d8016339bda25690b2b7fd Mon Sep 17 00:00:00 2001 From: Yunlian Jiang Date: Tue, 17 May 2016 11:33:06 -0700 Subject: GOLD/DWP: exit without segfault if the binary is not built with debug fission. dwp segfaults when trying to get .dwp file from a binary built without debug fission. This patch fixes that. upstream thread is https://sourceware.org/ml/binutils/2016-05/msg00204.html BUG=None TEST=dwp still works with files built with debug fission and dwp does not segfault on files that are not built with debug fission. --- binutils-2.25/gold/dwp.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/binutils-2.25/gold/dwp.cc b/binutils-2.25/gold/dwp.cc index 121f37b..9eef68a 100644 --- a/binutils-2.25/gold/dwp.cc +++ b/binutils-2.25/gold/dwp.cc @@ -2427,6 +2427,10 @@ main(int argc, char** argv) if (exe_filename == NULL && files.empty()) gold_fatal(_("no input files and no executable specified")); + // If there are no DWO files, there is nothing to do. + if (files.empty()) + return EXIT_SUCCESS; + if (verify_only) { // Get list of DWO files in the DWP file and compare with -- cgit v1.1 From 4520d6bee11b130d3f05175db13d3000f7ecf1a8 Mon Sep 17 00:00:00 2001 From: Rahul Chaudhry Date: Tue, 28 Jun 2016 14:17:59 -0700 Subject: Revert "Disable the warning of a hidden symbol matches a reference to be resolved." Bug: 21502954 This change reverts https://android-review.googlesource.com/#/c/155101/, to be replaced by the upstream patch with tests. - https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=c20ceeb226168ffd84078ef74d890c2b7f69a435 Change-Id: Id929c8422a016638f860ac508eeafc7080584600 --- binutils-2.25/gold/ChangeLog | 9 +++++++++ binutils-2.25/gold/resolve.cc | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index c222155..cd95752 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,3 +1,12 @@ +2016-06-28 Rahul Chaudhry + + Revert patch -- to be replaced by the upstream patch with tests. + + 2015-06-16 Yiran Wang + + * resolve.cc disable the warning of a hidden symbol matches a + reference to be resolved + 2016-02-05 Sriraman Tallam * icf.cc (get_rel_addend): New function. diff --git a/binutils-2.25/gold/resolve.cc b/binutils-2.25/gold/resolve.cc index 54de87d..07dff4a 100644 --- a/binutils-2.25/gold/resolve.cc +++ b/binutils-2.25/gold/resolve.cc @@ -279,8 +279,15 @@ Symbol_table::resolve(Sized_symbol* to, && (to->visibility() == elfcpp::STV_HIDDEN || to->visibility() == elfcpp::STV_INTERNAL)) { - // it is good to be helpful, but the warning leads to build error - // for some users, so disable it if not really wanted. + // A dynamic object cannot reference a hidden or internal symbol + // defined in another object. + gold_warning(_("%s symbol '%s' in %s is referenced by DSO %s"), + (to->visibility() == elfcpp::STV_HIDDEN + ? "hidden" + : "internal"), + to->demangled_name().c_str(), + to->object()->name().c_str(), + object->name().c_str()); return; } else -- cgit v1.1 From 6422a80df992e4542dbd4fb70a04f316065674af Mon Sep 17 00:00:00 2001 From: Rahul Chaudhry Date: Tue, 28 Jun 2016 14:33:51 -0700 Subject: Remove warning about references from shared objects to hidden symbols. Bug: 21502954 This patch is backported from upstream - commit c20ceeb226168ffd84078ef74d890c2b7f69a435 Author: Yiran Wang Date: Mon Jul 20 08:47:57 2015 -0700 Remove warning about references from shared objects to hidden symbols. gold/ PR gold/15574 * resolve.cc (Symbol_table): Remove warning about references from shared objects to hidden symbols. * testsuite/Makefile.am (hidden_test): Add hidden_test.syms. * testsuite/Makefile.in: Regenerate. * testsuite/hidden_test.sh: Check dynamic symbol table; update expected error messages. Change-Id: Ie6fb67071c7f478859069b7b4bf629cd44f91844 --- binutils-2.25/gold/ChangeLog | 11 +++++++++++ binutils-2.25/gold/resolve.cc | 13 ++++--------- binutils-2.25/gold/testsuite/Makefile.am | 4 +++- binutils-2.25/gold/testsuite/Makefile.in | 3 +++ binutils-2.25/gold/testsuite/hidden_test.sh | 24 ++++++++++++++---------- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index cd95752..9e84837 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,3 +1,14 @@ +2015-07-20 Yiran Wang + Cary Coutant + + PR gold/15574 + * resolve.cc (Symbol_table): Remove warning about references + from shared objects to hidden symbols. + * testsuite/Makefile.am (hidden_test): Add hidden_test.syms. + * testsuite/Makefile.in: Regenerate. + * testsuite/hidden_test.sh: Check dynamic symbol table; update + expected error messages. + 2016-06-28 Rahul Chaudhry Revert patch -- to be replaced by the upstream patch with tests. diff --git a/binutils-2.25/gold/resolve.cc b/binutils-2.25/gold/resolve.cc index 07dff4a..b49c45c 100644 --- a/binutils-2.25/gold/resolve.cc +++ b/binutils-2.25/gold/resolve.cc @@ -279,15 +279,10 @@ Symbol_table::resolve(Sized_symbol* to, && (to->visibility() == elfcpp::STV_HIDDEN || to->visibility() == elfcpp::STV_INTERNAL)) { - // A dynamic object cannot reference a hidden or internal symbol - // defined in another object. - gold_warning(_("%s symbol '%s' in %s is referenced by DSO %s"), - (to->visibility() == elfcpp::STV_HIDDEN - ? "hidden" - : "internal"), - to->demangled_name().c_str(), - to->object()->name().c_str(), - object->name().c_str()); + // The symbol is hidden, so a reference from a shared object + // cannot bind to it. We tried issuing a warning in this case, + // but that produces false positives when the symbol is + // actually resolved in a different shared object (PR 15574). return; } else diff --git a/binutils-2.25/gold/testsuite/Makefile.am b/binutils-2.25/gold/testsuite/Makefile.am index a9caa6b..ce1af05 100644 --- a/binutils-2.25/gold/testsuite/Makefile.am +++ b/binutils-2.25/gold/testsuite/Makefile.am @@ -1894,11 +1894,13 @@ endif MCMODEL_MEDIUM # referenced by a shared library. check_SCRIPTS += hidden_test.sh check_DATA += hidden_test.err -MOSTLYCLEANFILES += hidden_test hidden_test.err +MOSTLYCLEANFILES += hidden_test hidden_test.err hidden_test.syms libhidden.so: hidden_test_1.c gcctestdir/ld $(COMPILE) -Bgcctestdir/ -g -shared -fPIC -w -o $@ $(srcdir)/hidden_test_1.c hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld $(LINK) -Bgcctestdir/ -Wl,-R,. hidden_test_main.o libhidden.so 2>hidden_test.err +hidden_test.syms: hidden_test + $(TEST_NM) -D hidden_test > $@ hidden_test.err: hidden_test @touch hidden_test.err diff --git a/binutils-2.25/gold/testsuite/Makefile.in b/binutils-2.25/gold/testsuite/Makefile.in index 3cdf45e..17a73fd 100644 --- a/binutils-2.25/gold/testsuite/Makefile.in +++ b/binutils-2.25/gold/testsuite/Makefile.in @@ -507,6 +507,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ discard_locals_relocatable_test2.out \ @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ hidden_test \ @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ hidden_test.err \ +@GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ hidden_test.syms \ @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ retain_symbols_file_test \ @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ retain_symbols_file_test.in \ @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ retain_symbols_file_test.stdout \ @@ -5624,6 +5625,8 @@ uninstall-am: @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ $(COMPILE) -Bgcctestdir/ -g -shared -fPIC -w -o $@ $(srcdir)/hidden_test_1.c @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,-R,. hidden_test_main.o libhidden.so 2>hidden_test.err +@GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@hidden_test.syms: hidden_test +@GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ $(TEST_NM) -D hidden_test > $@ @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@hidden_test.err: hidden_test @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@ @touch hidden_test.err @GCC_TRUE@@TEST_AS_NATIVE_LINKER_TRUE@retain_symbols_file_test.so: basic_pic_test.o gcctestdir/ld diff --git a/binutils-2.25/gold/testsuite/hidden_test.sh b/binutils-2.25/gold/testsuite/hidden_test.sh index 39ebbf6..05633d0 100755 --- a/binutils-2.25/gold/testsuite/hidden_test.sh +++ b/binutils-2.25/gold/testsuite/hidden_test.sh @@ -29,11 +29,11 @@ # error messages are issued for the references to internal and # hidden symbols. The errors will be found in hidden_test.err. -check() +check_missing() { - if ! grep -q "$2" "$1" + if grep -q "$2" "$1" then - echo "Did not find expected error in $1:" + echo "Found unexpected error in $1:" echo " $2" echo "" echo "Actual error output below:" @@ -42,25 +42,29 @@ check() fi } -check_missing() +check_missing_sym() { if grep -q "$2" "$1" then - echo "Found unexpected error in $1:" + echo "Found unexpected symbol in $1:" echo " $2" echo "" - echo "Actual error output below:" + echo "Actual nm output below:" cat "$1" exit 1 fi } -# We should see errors for hidden and internal symbols. -check hidden_test.err "hidden symbol 'main_hidden' in hidden_test_main.o is referenced by DSO libhidden.so" -check hidden_test.err "internal symbol 'main_internal' in hidden_test_main.o is referenced by DSO libhidden.so" - # We shouldn't see errors for the default and protected symbols. check_missing hidden_test.err "main_default" check_missing hidden_test.err "main_protected" +# We shouldn't see errors for the hidden and internal symbols either (PR 15574). +check_missing hidden_test.err "main_hidden" +check_missing hidden_test.err "main_internal" + +# We shouldn't see the hidden or internal symbols in the dynamic symbol table. +check_missing_sym hidden_test.syms "main_hidden" +check_missing_sym hidden_test.syms "main_internal" + exit 0 -- cgit v1.1