+2017-09-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf32-i386.c (elf_i386_relocate_section): Don't change r_type
+ when calling elf_i386_tls_transition. Don't use ELF32_R_TYPE
+ to get the relocation type again.
+ * elf64-x86-64.c (elf_x86_64_relocate_section): Don't change
+ r_type when calling elf_x86_64_tls_transition. Don't use
+ ELF32_R_TYPE to get the relocation type again.
+
2017-09-05 H.J. Lu <hongjiu.lu@intel.com>
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Properly set
relend = relocs + input_section->reloc_count;
for (; rel < relend; wrel++, rel++)
{
- unsigned int r_type;
+ unsigned int r_type, r_type_tls;
reloc_howto_type *howto;
unsigned long r_symndx;
struct elf_link_hash_entry *h;
if (tls_type == GOT_TLS_IE)
tls_type = GOT_TLS_IE_NEG;
+ r_type_tls = r_type;
if (! elf_i386_tls_transition (info, input_bfd,
input_section, contents,
symtab_hdr, sym_hashes,
- &r_type, tls_type, rel,
+ &r_type_tls, tls_type, rel,
relend, h, r_symndx, TRUE))
return FALSE;
- if (r_type == R_386_TLS_LE_32)
+ if (r_type_tls == R_386_TLS_LE_32)
{
BFD_ASSERT (! unresolved_reloc);
- if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GD)
+ if (r_type == R_386_TLS_GD)
{
unsigned int type;
bfd_vma roff;
wrel++;
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GOTDESC)
+ else if (r_type == R_386_TLS_GOTDESC)
{
/* GDesc -> LE transition.
It's originally something like:
contents + roff);
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_DESC_CALL)
+ else if (r_type == R_386_TLS_DESC_CALL)
{
/* GDesc -> LE transition.
It's originally:
bfd_put_8 (output_bfd, 0x90, contents + roff + 1);
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_IE)
+ else if (r_type == R_386_TLS_IE)
{
unsigned int val;
}
else
BFD_FAIL ();
- if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GOTIE)
+ if (r_type == R_386_TLS_GOTIE)
bfd_put_32 (output_bfd, -elf_i386_tpoff (info, relocation),
contents + rel->r_offset);
else
if (off >= (bfd_vma) -2
&& ! GOT_TLS_GDESC_P (tls_type))
abort ();
- if (r_type == R_386_TLS_GOTDESC
- || r_type == R_386_TLS_DESC_CALL)
+ if (r_type_tls == R_386_TLS_GOTDESC
+ || r_type_tls == R_386_TLS_DESC_CALL)
{
relocation = htab->sgotplt_jump_table_size + offplt;
unresolved_reloc = FALSE;
}
- else if (r_type == ELF32_R_TYPE (rel->r_info))
+ else if (r_type_tls == r_type)
{
bfd_vma g_o_t = htab->elf.sgotplt->output_section->vma
+ htab->elf.sgotplt->output_offset;
relocation += g_o_t;
unresolved_reloc = FALSE;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GD)
+ else if (r_type == R_386_TLS_GD)
{
unsigned int val, type;
bfd_vma roff;
wrel++;
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GOTDESC)
+ else if (r_type == R_386_TLS_GOTDESC)
{
/* GDesc -> IE transition.
It's originally something like:
contents + roff);
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_DESC_CALL)
+ else if (r_type == R_386_TLS_DESC_CALL)
{
/* GDesc -> IE transition.
It's originally:
relend = relocs + input_section->reloc_count;
for (; rel < relend; wrel++, rel++)
{
- unsigned int r_type;
+ unsigned int r_type, r_type_tls;
reloc_howto_type *howto;
unsigned long r_symndx;
struct elf_link_hash_entry *h;
else if (h != NULL)
tls_type = elf_x86_hash_entry (h)->tls_type;
+ r_type_tls = r_type;
if (! elf_x86_64_tls_transition (info, input_bfd,
input_section, contents,
symtab_hdr, sym_hashes,
- &r_type, tls_type, rel,
+ &r_type_tls, tls_type, rel,
relend, h, r_symndx, TRUE))
return FALSE;
- if (r_type == R_X86_64_TPOFF32)
+ if (r_type_tls == R_X86_64_TPOFF32)
{
bfd_vma roff = rel->r_offset;
BFD_ASSERT (! unresolved_reloc);
- if (ELF32_R_TYPE (rel->r_info) == R_X86_64_TLSGD)
+ if (r_type == R_X86_64_TLSGD)
{
/* GD->LE transition. For 64bit, change
.byte 0x66; leaq foo@tlsgd(%rip), %rdi
wrel++;
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_X86_64_GOTPC32_TLSDESC)
+ else if (r_type == R_X86_64_GOTPC32_TLSDESC)
{
/* GDesc -> LE transition.
It's originally something like:
contents + roff);
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_X86_64_TLSDESC_CALL)
+ else if (r_type == R_X86_64_TLSDESC_CALL)
{
/* GDesc -> LE transition.
It's originally:
bfd_put_8 (output_bfd, 0x90, contents + roff + 1);
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_X86_64_GOTTPOFF)
+ else if (r_type == R_X86_64_GOTTPOFF)
{
/* IE->LE transition:
For 64bit, originally it can be one of:
if (off >= (bfd_vma) -2
&& ! GOT_TLS_GDESC_P (tls_type))
abort ();
- if (r_type == ELF32_R_TYPE (rel->r_info))
+ if (r_type_tls == r_type)
{
if (r_type == R_X86_64_GOTPC32_TLSDESC
|| r_type == R_X86_64_TLSDESC_CALL)
{
bfd_vma roff = rel->r_offset;
- if (ELF32_R_TYPE (rel->r_info) == R_X86_64_TLSGD)
+ if (r_type == R_X86_64_TLSGD)
{
/* GD->IE transition. For 64bit, change
.byte 0x66; leaq foo@tlsgd(%rip), %rdi
wrel++;
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_X86_64_GOTPC32_TLSDESC)
+ else if (r_type == R_X86_64_GOTPC32_TLSDESC)
{
/* GDesc -> IE transition.
It's originally something like:
contents + roff);
continue;
}
- else if (ELF32_R_TYPE (rel->r_info) == R_X86_64_TLSDESC_CALL)
+ else if (r_type == R_X86_64_TLSDESC_CALL)
{
/* GDesc -> IE transition.
It's originally: