+ // Whether we should use the PLT offset associated with a symbol for
+ // a relocation. FLAGS is a set of Reference_flags.
+
+ bool
+ use_plt_offset(int flags) const
+ {
+ // If the symbol doesn't have a PLT offset, then naturally we
+ // don't want to use it.
+ if (!this->has_plt_offset())
+ return false;
+
+ // For a STT_GNU_IFUNC symbol we always have to use the PLT entry.
+ if (this->type() == elfcpp::STT_GNU_IFUNC)
+ return true;
+
+ // If we are going to generate a dynamic relocation, then we will
+ // wind up using that, so no need to use the PLT entry.
+ if (this->needs_dynamic_reloc(flags))
+ return false;
+
+ // If the symbol is from a dynamic object, we need to use the PLT
+ // entry.
+ if (this->is_from_dynobj())
+ return true;
+
+ // If we are generating a shared object, and this symbol is
+ // undefined or preemptible, we need to use the PLT entry.
+ if (parameters->options().shared()
+ && (this->is_undefined() || this->is_preemptible()))
+ return true;
+
+ // If this is a call to a weak undefined symbol, we need to use
+ // the PLT entry; the symbol may be defined by a library loaded
+ // at runtime.
+ if ((flags & FUNCTION_CALL) && this->is_weak_undefined())
+ return true;
+
+ // Otherwise we can use the regular definition.
+ return false;
+ }
+