+/* Calculate size of GOT entries for symbol given its TLS_TYPE. */
+
+static inline unsigned int
+got_entries_needed (int tls_type)
+{
+ unsigned int need = 0;
+
+ if ((tls_type & GOT_NORMAL) != 0)
+ need += GOT_ENTRY_SIZE;
+ if ((tls_type & GOT_TLS_GD) != 0)
+ need += GOT_ENTRY_SIZE * 2;
+ if ((tls_type & GOT_TLS_IE) != 0)
+ need += GOT_ENTRY_SIZE;
+ return need;
+}
+
+/* Calculate size of relocs needed for symbol given its TLS_TYPE and
+ NEEDed GOT entries. TPREL_KNOWN says a TPREL offset can be
+ calculated at link time. DTPREL_KNOWN says the same for a DTPREL
+ offset. */
+
+static inline unsigned int
+got_relocs_needed (int tls_type, unsigned int need,
+ bfd_boolean dtprel_known, bfd_boolean tprel_known)
+{
+ /* All the entries we allocated need relocs.
+ Except for GD and IE with local symbols. */
+ if ((tls_type & GOT_TLS_GD) != 0 && dtprel_known)
+ need -= GOT_ENTRY_SIZE;
+ if ((tls_type & GOT_TLS_IE) != 0 && tprel_known)
+ need -= GOT_ENTRY_SIZE;
+ return need * sizeof (Elf32_External_Rela) / GOT_ENTRY_SIZE;
+}
+