S/390: Return with an error for broken tls rewrites
bfd/ChangeLog: 2017-06-12 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * elf32-s390.c (elf_s390_relocate_section): Return false in case the rewriting fails. * elf64-s390.c (elf_s390_relocate_section): Likewise.
This commit is contained in:
parent
fd0219988d
commit
3704e3589d
2 changed files with 32 additions and 10 deletions
|
@ -3231,7 +3231,6 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
unsigned int insn, ry;
|
||||
|
||||
insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
|
||||
ry = 0;
|
||||
if ((insn & 0xff00f000) == 0x58000000)
|
||||
/* l %rx,0(%ry,0) -> lr %rx,%ry + bcr 0,0 */
|
||||
ry = (insn & 0x000f0000);
|
||||
|
@ -3245,7 +3244,10 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
/* l %rx,0(%r12,%ry) -> lr %rx,%ry + bcr 0,0 */
|
||||
ry = (insn & 0x0000f000) << 4;
|
||||
else
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
{
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
return FALSE;
|
||||
}
|
||||
insn = 0x18000700 | (insn & 0x00f00000) | ry;
|
||||
bfd_put_32 (output_bfd, insn, contents + rel->r_offset);
|
||||
}
|
||||
|
@ -3258,7 +3260,10 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
if ((insn & 0xff000fff) != 0x4d000000 &&
|
||||
(insn & 0xffff0000) != 0xc0e50000 &&
|
||||
(insn & 0xff000000) != 0x0d000000)
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
{
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
return FALSE;
|
||||
}
|
||||
if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
|
||||
{
|
||||
if ((insn & 0xff000000) == 0x0d000000)
|
||||
|
@ -3287,7 +3292,10 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
/* If basr is used in the pic case to invoke
|
||||
_tls_get_offset, something went wrong before. */
|
||||
if ((insn & 0xff000000) == 0x0d000000)
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
{
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((insn & 0xff000000) == 0x4d000000)
|
||||
{
|
||||
|
@ -3317,7 +3325,10 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
if ((insn & 0xff000fff) != 0x4d000000 &&
|
||||
(insn & 0xffff0000) != 0xc0e50000 &&
|
||||
(insn & 0xff000000) != 0x0d000000)
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
{
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((insn & 0xff000000) == 0x0d000000)
|
||||
{
|
||||
|
|
|
@ -3197,8 +3197,10 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
insn0 = bfd_get_32 (input_bfd, contents + rel->r_offset);
|
||||
insn1 = bfd_get_16 (input_bfd, contents + rel->r_offset + 4);
|
||||
if (insn1 != 0x0004)
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
ry = 0;
|
||||
{
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
return FALSE;
|
||||
}
|
||||
if ((insn0 & 0xff00f000) == 0xe3000000)
|
||||
/* lg %rx,0(%ry,0) -> sllg %rx,%ry,0 */
|
||||
ry = (insn0 & 0x000f0000);
|
||||
|
@ -3212,7 +3214,10 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
/* lg %rx,0(%r12,%ry) -> sllg %rx,%ry,0 */
|
||||
ry = (insn0 & 0x0000f000) << 4;
|
||||
else
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
{
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
return FALSE;
|
||||
}
|
||||
insn0 = 0xeb000000 | (insn0 & 0x00f00000) | ry;
|
||||
insn1 = 0x000d;
|
||||
bfd_put_32 (output_bfd, insn0, contents + rel->r_offset);
|
||||
|
@ -3226,7 +3231,10 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
insn0 = bfd_get_32 (input_bfd, contents + rel->r_offset);
|
||||
insn1 = bfd_get_16 (input_bfd, contents + rel->r_offset + 4);
|
||||
if ((insn0 & 0xffff0000) != 0xc0e50000)
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
{
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
return FALSE;
|
||||
}
|
||||
if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
|
||||
{
|
||||
/* GD->LE transition.
|
||||
|
@ -3253,7 +3261,10 @@ elf_s390_relocate_section (bfd *output_bfd,
|
|||
insn0 = bfd_get_32 (input_bfd, contents + rel->r_offset);
|
||||
insn1 = bfd_get_16 (input_bfd, contents + rel->r_offset + 4);
|
||||
if ((insn0 & 0xffff0000) != 0xc0e50000)
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
{
|
||||
invalid_tls_insn (input_bfd, input_section, rel);
|
||||
return FALSE;
|
||||
}
|
||||
/* LD->LE transition.
|
||||
brasl %r14,__tls_get_addr@plt -> brcl 0,. */
|
||||
insn0 = 0xc0040000;
|
||||
|
|
Loading…
Add table
Reference in a new issue