bfd/
	* elfxx-mips.c (mips_elf_recreate_got): Remove free.
	(mips_elf_resolve_final_got_entries): Remove bogus comment.
bfd/
	* elfxx-mips.c (mips_elf_merge_got_with): Only use arg->global_count
	if there are TLS relocations.
bfd/
	* elfxx-mips.c (mips_elf_sort_hash_table_f): Remove asserts.
bfd/
	* elfxx-mips.c (mips_elf_count_global_tls_entries)
	(mips_elf_count_global_tls_relocs): Don't count indirect or
	warning symbols.
	(mips_elf_multi_got, mips_elf_lay_out_got): Assert that the right
	number of TLS entries were allocated.

ld/testsuite/
	* ld-mips-elf/tlsdyn-o32-2.got, ld-mips-elf/tlsdyn-o32-3.got: Remove
	unused GOT entries.
bfd/
	* elfxx-mips.c (mips_got_info): Move global_gotsym to...
	(mips_elf_link_hash_table): ...here.  Update rest of file accordingly.
bfd/
	* elfxx-mips.c (mips_elf_multi_got): Simplify size calculation.
bfd/
	* elfxx-mips.c (mips_elf_record_local_got_symbol): Always set
	gotidx to -1.
bfd/
	* elfxx-mips.c (mips_elf_create_got_info): New function.
	(mips_elf_get_got_for_bfd, mips_elf_multi_got): Use it.
	(mips_elf_create_got_section): Likewise.
bfd/
	* elfxx-mips.c (mips_elf_multi_got_entry_hash): Rename to...
	(mips_elf_got_entry_hash): ...this, deleting the old version.
	(mips_elf_create_got_info): Use mips_elf_got_entry_hash for
	both types of GOT.

ld/testsuite/
	* ld-mips-elf/tls-hidden3.d, ld-mips-elf/tls-hidden3.got,
	ld-mips-elf/tls-multi-got-1.got, ld-mips-elf/tlsbin-o32.d,
	ld-mips-elf/tlsbin-o32.got, ld-mips-elf/tlsdyn-o32-1.d,
	ld-mips-elf/tlsdyn-o32-1.got, ld-mips-elf/tlsdyn-o32-2.d,
	ld-mips-elf/tlsdyn-o32-2.got, ld-mips-elf/tlsdyn-o32-3.d,
	ld-mips-elf/tlsdyn-o32-3.got, ld-mips-elf/tlsdyn-o32.d,
	ld-mips-elf/tlsdyn-o32.got, ld-mips-elf/tlslib-o32.d,
	ld-mips-elf/tlslib-o32.got, ld-mips-elf/tlslib-o32-hidden.got,
	ld-mips-elf/tlslib-o32-ver.got: Adjust GOT layout for new
	got_entry hash function.
bfd/
	* elfxx-mips.c (mips_got_entry): Update comment above tls_type entry
	to say that each structure represents only one type of TLS reference.
	(GOT_TLS_TYPE): New define.
	(mips_elf_link_hash_entry): Temporarily split tls_type and
	tls_got_offset into two variables each.
	(mips_elf_link_hash_newfunc): Update accordingly.
	(mips_elf_got_entry_eq, mips_elf_got_entry_hash)
	(mips_elf_multi_got_entry_eq): Require the tls_type to be the same.
	(mips_elf_reloc_tls_type, mips_tls_got_entries): New functions.
	(mips_tls_got_relocs): Use a switch statement.
	(mips_elf_count_global_tls_entries): Handle the new hash entry fields.
	(mips_elf_initialize_tls_slots): Use a switch statement.  Avoid
	local "offset" variable.
	(mips_tls_got_index): Remove r_type argument and assert.  Remove
	code that handled entries with two TLS types; always use the
	original got_index instead.
	(mips_tls_single_got_index): New function.
	(mips_elf_local_got_index): Use entry->tls_type to check for
	TLS entries.  Use mips_tls_single_got_index.  Update call to
	mips_tls_got_index.
	(mips_elf_global_got_index): Use mips_elf_reloc_tls_type.
	Use p->tls_type to check for TLS entries.  Update call to
	mips_tls_got_index.  Use mips_tls_single_got_index.
	(mips_elf_create_local_got_entry): Use mips_elf_reloc_tls_type.
	Use entry.tls_type to check for TLS entries.
	(mips_elf_record_global_got_symbol): Replace tls_flag argument
	with r_type argument.  Use mips_elf_reloc_tls_type.
	Set up the new hash entry fields.
	(mips_elf_record_local_got_symbol): Replace tls_flag argument
	with r_type argument.  Use mips_elf_reloc_tls_type and
	mips_tls_got_entries.  Remove code that handled entries
	with multiple TLS types.
	(mips_elf_make_got_per_bfd): Use mips_tls_got_entries.
	(mips_elf_initialize_tls_index): Handle new hash entry fields.
	Use equality rather than masks when checking for specific TLS types.
	Use mips_tls_got_entries.  Remove code that handled entries
	with multiple TLS types.
	(mips_elf_calculate_relocation): Use TLS_RELOC_P instead of
	testing the hash table entry.
	(_bfd_mips_elf_check_relocs): Update calls to
	mips_elf_record_global_got_symbol and mips_elf_record_local_got_symbol.
	(_bfd_mips_elf_finish_dynamic_symbol): Don't check h->type.
	(_bfd_mips_elf_copy_indirect_symbol): Handle new hash entry fields.
bfd/
	* elfxx-mips.c (mips_got_info): Add relocs field.
	(mips_elf_set_global_got_offset_arg, mips_elf_count_tls_arg): Replace
	with...
	(mips_elf_traverse_got_arg): ...this new structure.
	(mips_elf_count_local_tls_relocs): Delete.
	(mips_elf_count_global_tls_relocs): Likewise.
	(mips_elf_count_got_entry): New function.
	(mips_elf_count_local_got_entries): Likewise.
	(mips_elf_count_global_tls_entries): Take a mips_elf_traverse_got_arg
	rather than a mips_elf_count_tls_arg.  Count both relocs and entries.
	(mips_elf_record_local_got_symbol): Don't count got entries here.
	(mips_elf_make_got_per_bfd): Use mips_elf_count_got_entry.
	(mips_elf_set_global_got_offset): Split into...
	(mips_elf_set_global_got_area, mips_elf_set_global_gotidx): ...these
	new functions.  Take a mips_elf_traverse_got_arg rather than a
	mips_elf_set_global_got_offset_arg.  Don't count TLS relocs here.
	Use g->relocs to record the number of relocs needed for global GOT
	entries.
	(mips_elf_multi_got): Use mips_elf_traverse_got_arg rather than
	mips_elf_set_global_got_offset_arg.  Use the relocs field to count
	relocations.  Update for above function split.
	(mips_elf_lay_out_got): Use mips_elf_count_local_got_entries
	to count both the number of GOT entries and the number of TLS
	relocs required by local entries.  Likewise
	mips_elf_count_global_tls_entries and global entries.
	Remove uses of mips_elf_count_local_tls_relocs and
	mips_elf_count_global_tls_relocs.
bfd/
	* elfxx-mips.c (mips_elf_recreate_got): Don't change the entry;
	create another one if necessary.
	(mips_elf_set_gotidx): New function.
	(mips_elf_set_global_gotidx): Use it.
	(mips_elf_initialize_tls_index): Likewise.  Take a
	mips_elf_traverse_got_arg as argument.
	(mips_elf_lay_out_got): Update use of mips_elf_initialize_tls_index.
	(mips_elf_multi_got): Likewise.  Cope with error returns from
	mips_elf_set_global_gotidx.