summaryrefslogtreecommitdiffstats
path: root/binutils-2.25/gold
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-09-08 19:26:40 +0200
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-09-08 19:26:40 +0200
commit2b84c0ca027e029eae1e5f825696d62fa8c4e95f (patch)
tree08415b3d502063e686db71856e9983ed3f634a22 /binutils-2.25/gold
parent33f0f8829308781a59b094a6ed8c6ad62539b11f (diff)
parent129dec3ed0e1fc07f75a4322014d770cfd642f4d (diff)
downloadtoolchain_binutils-2b84c0ca027e029eae1e5f825696d62fa8c4e95f.tar.gz
toolchain_binutils-2b84c0ca027e029eae1e5f825696d62fa8c4e95f.tar.bz2
toolchain_binutils-2b84c0ca027e029eae1e5f825696d62fa8c4e95f.zip
Merge branch 'master' of https://android.googlesource.com/toolchain/binutils
Diffstat (limited to 'binutils-2.25/gold')
-rw-r--r--binutils-2.25/gold/ChangeLog76
-rw-r--r--binutils-2.25/gold/aarch64.cc35
-rw-r--r--binutils-2.25/gold/arm.cc127
-rw-r--r--binutils-2.25/gold/dwp.cc4
-rw-r--r--binutils-2.25/gold/ehframe.cc39
-rw-r--r--binutils-2.25/gold/ehframe.h5
-rw-r--r--binutils-2.25/gold/icf.cc115
-rw-r--r--binutils-2.25/gold/options.h11
-rw-r--r--binutils-2.25/gold/resolve.cc6
-rw-r--r--binutils-2.25/gold/testsuite/Makefile.am4
-rw-r--r--binutils-2.25/gold/testsuite/Makefile.in3
-rwxr-xr-xbinutils-2.25/gold/testsuite/hidden_test.sh24
12 files changed, 356 insertions, 93 deletions
diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog
index 24e87559..9e84837e 100644
--- a/binutils-2.25/gold/ChangeLog
+++ b/binutils-2.25/gold/ChangeLog
@@ -1,4 +1,78 @@
-2015-10.27 Han Shen <shenhan@google.com>
+2015-07-20 Yiran Wang <yiran@google.com>
+ Cary Coutant <ccoutant@gmail.com>
+
+ 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 <rahulchaudhry@google.com>
+
+ Revert patch -- to be replaced by the upstream patch with tests.
+
+ 2015-06-16 Yiran Wang <yiran@google.com>
+
+ * resolve.cc disable the warning of a hidden symbol matches a
+ reference to be resolved
+
+2016-02-05 Sriraman Tallam <tmsriram@google.com>
+
+ * 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 <egor.kochetov@intel.com>
+ Cary Coutant <ccoutant@gmail.com>
+
+ 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 <rahulchaudhry@google.com>
+
+ * aarch64.cc (Target_aarch64::scan_erratum_843419_span): Remove
+ info message for every erratum 843419 found and fixed.
+
+2015-12-17 Peter Collingbourne <pcc@google.com>
+
+ 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 <shenhan@google.com>
+
+ 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 <ccoutant@gmail.com>
+
+ 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 <shenhan@google.com>
PR gold/19042 - unsupported reloc 311/312.
diff --git a/binutils-2.25/gold/aarch64.cc b/binutils-2.25/gold/aarch64.cc
index a62833bf..aa540f0b 100644
--- a/binutils-2.25/gold/aarch64.cc
+++ b/binutils-2.25/gold/aarch64.cc
@@ -1327,10 +1327,12 @@ Reloc_stub<size, big_endian>::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;
}
@@ -6907,16 +6909,41 @@ Target_aarch64<size, big_endian>::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;
@@ -8180,10 +8207,6 @@ Target_aarch64<size, big_endian>::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 =
diff --git a/binutils-2.25/gold/arm.cc b/binutils-2.25/gold/arm.cc
index 86920c4f..94149d61 100644
--- a/binutils-2.25/gold/arm.cc
+++ b/binutils-2.25/gold/arm.cc
@@ -62,7 +62,10 @@ template<bool big_endian>
class Output_data_plt_arm;
template<bool big_endian>
-class Output_data_plt_arm_standard;
+class Output_data_plt_arm_short;
+
+template<bool big_endian>
+class Output_data_plt_arm_long;
template<bool big_endian>
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<big_endian>(
+ if (parameters->options().long_plt())
+ return new Output_data_plt_arm_long<big_endian>(
+ layout, got, got_plt, got_irelative);
+ else
+ return new Output_data_plt_arm_short<big_endian>(
layout, got, got_plt, got_irelative);
}
@@ -7777,29 +7784,14 @@ class Output_data_plt_arm_standard : public Output_data_plt_arm<big_endian>
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<big_endian>::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<big_endian>::do_fill_first_plt_entry(
}
// Subsequent entries in the PLT.
+// This class generates short (12-byte) entries, for displacements up to 2^28.
template<bool big_endian>
-const uint32_t Output_data_plt_arm_standard<big_endian>::plt_entry[3] =
+class Output_data_plt_arm_short : public Output_data_plt_arm_standard<big_endian>
+{
+ public:
+ Output_data_plt_arm_short(Layout* layout,
+ Arm_output_data_got<big_endian>* got,
+ Output_data_space* got_plt,
+ Output_data_space* got_irelative)
+ : Output_data_plt_arm_standard<big_endian>(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<bool big_endian>
+const uint32_t Output_data_plt_arm_short<big_endian>::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<big_endian>::plt_entry[3] =
template<bool big_endian>
void
-Output_data_plt_arm_standard<big_endian>::do_fill_plt_entry(
+Output_data_plt_arm_short<big_endian>::do_fill_plt_entry(
unsigned char* pov,
Arm_address got_address,
Arm_address plt_address,
@@ -7856,8 +7878,9 @@ Output_data_plt_arm_standard<big_endian>::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<big_endian>::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<bool big_endian>
+class Output_data_plt_arm_long : public Output_data_plt_arm_standard<big_endian>
+{
+ public:
+ Output_data_plt_arm_long(Layout* layout,
+ Arm_output_data_got<big_endian>* got,
+ Output_data_space* got_plt,
+ Output_data_space* got_irelative)
+ : Output_data_plt_arm_standard<big_endian>(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<bool big_endian>
+const uint32_t Output_data_plt_arm_long<big_endian>::plt_entry[4] =
+{
+ 0xe28fc200, // add ip, pc, #0xN0000000
+ 0xe28cc600, // add ip, ip, #0xNN00000
+ 0xe28cca00, // add ip, ip, #0xNN000
+ 0xe5bcf000, // ldr pc, [ip, #0xNNN]!
+};
+
+template<bool big_endian>
+void
+Output_data_plt_arm_long<big_endian>::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/dwp.cc b/binutils-2.25/gold/dwp.cc
index 121f37b1..9eef68ab 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
diff --git a/binutils-2.25/gold/ehframe.cc b/binutils-2.25/gold/ehframe.cc
index 4f926181..fc45e877 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<size, big_endian>* 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<size>::sym_size;
if (symndx >= symbols_size / sym_size)
@@ -1018,13 +1020,40 @@ Eh_frame::read_fde(Sized_relobj_file<size, big_endian>* 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 e9c9da89..8c0df99b 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&);
diff --git a/binutils-2.25/gold/icf.cc b/binutils-2.25/gold/icf.cc
index ad887154..1ae18291 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<Section_id>& 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<unsigned long long>(*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<const
+ // Use the entsize to determine the length to copy.
+ uint64_t bufsize = entsize;
+ // If entsize is too big, copy all the remaining bytes.
+ if ((offset + entsize) > secn_len)
+ bufsize = secn_len - offset;
+ buffer.append(reinterpret_cast<const
char*>(str_contents),
- entsize);
+ bufsize);
}
buffer.append("@");
}
diff --git a/binutils-2.25/gold/options.h b/binutils-2.25/gold/options.h
index 6502e1fc..0fa26f16 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"));
@@ -834,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);
diff --git a/binutils-2.25/gold/resolve.cc b/binutils-2.25/gold/resolve.cc
index 54de87d9..b49c45c2 100644
--- a/binutils-2.25/gold/resolve.cc
+++ b/binutils-2.25/gold/resolve.cc
@@ -279,8 +279,10 @@ Symbol_table::resolve(Sized_symbol<size>* 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.
+ // 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 a9caa6bc..ce1af05a 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 3cdf45e6..17a73fdf 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 39ebbf68..05633d04 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