From: Andreas Krebbel Date: Fri, 9 Jun 2017 09:19:01 +0000 (+0200) Subject: S/390: Return with an error for broken tls rewrites X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3704e3589d3d187fbf76e688388b1a92fd627c8d;p=binutils-gdb.git S/390: Return with an error for broken tls rewrites bfd/ChangeLog: 2017-06-12 Andreas Krebbel * elf32-s390.c (elf_s390_relocate_section): Return false in case the rewriting fails. * elf64-s390.c (elf_s390_relocate_section): Likewise. --- diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index fc4992e8873..c26bdcf900a 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -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) { diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index b1f5b89036b..08e726f3c82 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -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;