2017-06-20 Eric Christopher <echristo@gmail.com>
[deliverable/binutils-gdb.git] / gold / aarch64.cc
index 7309ded676a32c86559eabb563929a8ac2fe0c14..11bb48e3b0048786601af7133ed11c46eac286be 100644 (file)
@@ -930,7 +930,7 @@ private:
 
 // Erratum stub class. An erratum stub differs from a reloc stub in that for
 // each erratum occurrence, we generate an erratum stub. We never share erratum
-// stubs, whereas for reloc stubs, different branches insns share a single reloc
+// stubs, whereas for reloc stubs, different branch insns share a single reloc
 // stub as long as the branch targets are the same. (More to the point, reloc
 // stubs can be shared because they're used to reach a specific target, whereas
 // erratum stubs branch back to the original control flow.)
@@ -3768,13 +3768,13 @@ Target_aarch64<size, big_endian>::scan_reloc_for_stub(
       if (gsym->use_plt_offset(arp->reference_flags()))
        {
          // This uses a PLT, change the symbol value.
-         symval.set_output_value(this->plt_section()->address()
-                                 + gsym->plt_offset());
+         symval.set_output_value(this->plt_address_for_global(gsym));
          psymval = &symval;
        }
       else if (gsym->is_undefined())
        {
-         // There is no need to generate a stub symbol is undefined.
+          // There is no need to generate a stub symbol if the original symbol
+          // is undefined.
           gold_debug(DEBUG_TARGET,
                      "stub: not creating a stub for undefined symbol %s in file %s",
                      gsym->name(), aarch64_relobj->name().c_str());
@@ -4001,11 +4001,6 @@ Target_aarch64<size, big_endian>::scan_reloc_section_for_stubs(
          psymval = &symval2;
        }
 
-      // If symbol is a section symbol, we don't know the actual type of
-      // destination.  Give up.
-      if (psymval->is_section_symbol())
-       continue;
-
       this->scan_reloc_for_stub(relinfo, r_type, sym, r_sym, psymval,
                                addend, view_address + offset);
     }  // End of iterating relocs in a section
@@ -5437,8 +5432,14 @@ maybe_apply_stub(unsigned int r_type,
 
   const The_aarch64_relobj* aarch64_relobj =
       static_cast<const The_aarch64_relobj*>(object);
-  // We don't create stubs for undefined symbols so don't look for one.
-  if (gsym && gsym->is_undefined())
+  const AArch64_reloc_property* arp =
+    aarch64_reloc_property_table->get_reloc_property(r_type);
+  gold_assert(arp != NULL);
+
+  // We don't create stubs for undefined symbols, but do for weak.
+  if (gsym
+      && !gsym->use_plt_offset(arp->reference_flags())
+      && gsym->is_undefined())
     {
       gold_debug(DEBUG_TARGET,
                 "stub: looking for a stub for undefined symbol %s in file %s",
@@ -5457,9 +5458,6 @@ maybe_apply_stub(unsigned int r_type,
   Address new_branch_target = stub_table->address() + stub->offset();
   typename elfcpp::Swap<size, big_endian>::Valtype branch_offset =
       new_branch_target - address;
-  const AArch64_reloc_property* arp =
-      aarch64_reloc_property_table->get_reloc_property(r_type);
-  gold_assert(arp != NULL);
   typename This::Status status = This::template
       rela_general<32>(view, branch_offset, 0, arp);
   if (status != This::STATUS_OKAY)
@@ -7736,8 +7734,8 @@ Target_aarch64<size, big_endian>::Relocate::tls_ld_to_le(
     {
       // Ideally we should give up gd_to_le relaxation and do gd access.
       // However the gd_to_le relaxation decision has been made early
-      // in the scan stage, where we did not allocate any GOT entry for
-      // this symbol. Therefore we have to exit and report error now.
+      // in the scan stage, where we did not allocate a GOT entry for
+      // this symbol. Therefore we have to exit and report an error now.
       gold_error(_("unexpected reloc insn sequence while relaxing "
                   "tls gd to le for reloc %u."), r_type);
       return aarch64_reloc_funcs::STATUS_BAD_RELOC;
This page took 0.025152 seconds and 4 git commands to generate.