From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id C25DE3858D1E for ; Thu, 28 Apr 2022 08:19:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C25DE3858D1E Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23S6K5d0010293 for ; Thu, 28 Apr 2022 08:19:56 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3fqjmwd9ur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 28 Apr 2022 08:19:55 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23S8D3N7027047 for ; Thu, 28 Apr 2022 08:19:54 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3fm938y4xa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 28 Apr 2022 08:19:53 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23S8JoV253608712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Apr 2022 08:19:50 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7B72442042; Thu, 28 Apr 2022 08:19:50 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 552BC42041; Thu, 28 Apr 2022 08:19:50 +0000 (GMT) Received: from t3560005.lnxne.boe (unknown [9.152.108.100]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 28 Apr 2022 08:19:50 +0000 (GMT) From: Stefan Liebler To: binutils@sourceware.org Cc: krebbel@linux.ibm.com, Stefan Liebler Subject: [PATCH 1/2] [PR ld/22263] s390: Avoid dynamic TLS relocs in PIE Date: Thu, 28 Apr 2022 10:19:42 +0200 Message-Id: <20220428081943.1003366-1-stli@linux.ibm.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: SI--JgV-MXlCykM6z7xY5iVeA4XklSi2 X-Proofpoint-GUID: SI--JgV-MXlCykM6z7xY5iVeA4XklSi2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-27_04,2022-04-27_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 phishscore=0 impostorscore=0 mlxlogscore=680 bulkscore=0 clxscore=1011 lowpriorityscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204280049 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Apr 2022 08:19:58 -0000 No dynamic relocs are needed for TLS defined in an executable, the TP relative offset is known at link time. Fixes FAIL: Build pr22263-1 bfd/ PR ld/22263 * elf64-s390.c (elf_s390_tls_transition): Use bfd_link_dll instead of bfd_link_pic for TLS. (elf_s390_check_relocs): Likewise. (allocate_dynrelocs): Likewise. (elf_s390_relocate_section): Likewise. --- bfd/elf64-s390.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index e780efa7181..00ee386baab 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -774,7 +774,7 @@ elf_s390_tls_transition (struct bfd_link_info *info, int r_type, int is_local) { - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) return r_type; switch (r_type) @@ -1026,7 +1026,7 @@ elf_s390_check_relocs (bfd *abfd, case R_390_TLS_GOTIE20: case R_390_TLS_GOTIE64: case R_390_TLS_IEENT: - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) info->flags |= DF_STATIC_TLS; /* Fall through */ @@ -1107,7 +1107,7 @@ elf_s390_check_relocs (bfd *abfd, if (r_type == R_390_TLS_LE64 && bfd_link_pie (info)) break; - if (!bfd_link_pic (info)) + if (!bfd_link_dll (info)) break; info->flags |= DF_STATIC_TLS; /* Fall through */ @@ -1571,7 +1571,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT we can save the dynamic TLS relocation. */ if (h->got.refcount > 0 - && !bfd_link_pic (info) + && !bfd_link_dll (info) && h->dynindx == -1 && elf_s390_hash_entry(h)->tls_type >= GOT_TLS_IE) { @@ -2662,7 +2662,7 @@ elf_s390_relocate_section (bfd *output_bfd, /* Relocations for tls literal pool entries. */ case R_390_TLS_IE64: - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) { Elf_Internal_Rela outrel; asection *sreloc; @@ -2690,7 +2690,7 @@ elf_s390_relocate_section (bfd *output_bfd, else if (h != NULL) { tls_type = elf_s390_hash_entry(h)->tls_type; - if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE) + if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE) r_type = R_390_TLS_LE64; } if (r_type == R_390_TLS_GD64 && tls_type >= GOT_TLS_IE) @@ -2801,14 +2801,14 @@ elf_s390_relocate_section (bfd *output_bfd, if (local_got_offsets == NULL) abort(); off = local_got_offsets[r_symndx]; - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) goto emit_tls_relocs; } else { off = h->got.offset; tls_type = elf_s390_hash_entry(h)->tls_type; - if (bfd_link_pic (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE) + if (bfd_link_dll (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE) goto emit_tls_relocs; } @@ -2825,7 +2825,7 @@ elf_s390_relocate_section (bfd *output_bfd, break; case R_390_TLS_LDM64: - if (! bfd_link_pic (info)) + if (! bfd_link_dll (info)) /* The literal pool entry this relocation refers to gets ignored by the optimized code of the local exec model. Do nothing and the value will turn out zero. */ @@ -2900,7 +2900,7 @@ elf_s390_relocate_section (bfd *output_bfd, continue; case R_390_TLS_LDO64: - if (bfd_link_pic (info) || (input_section->flags & SEC_DEBUGGING)) + if (bfd_link_dll (info) || (input_section->flags & SEC_DEBUGGING)) relocation -= dtpoff_base (info); else /* When converting LDO to LE, we must negate. */ @@ -2922,7 +2922,7 @@ elf_s390_relocate_section (bfd *output_bfd, if (r_type == R_390_TLS_LOAD) { - if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) + if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1)) { /* IE->LE transition. Four valid cases: lg %rx,(0,%ry) -> sllg %rx,%ry,0 @@ -2972,7 +2972,7 @@ elf_s390_relocate_section (bfd *output_bfd, invalid_tls_insn (input_bfd, input_section, rel); return false; } - if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) + if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1)) { /* GD->LE transition. brasl %r14,__tls_get_addr@plt -> brcl 0,. */ @@ -2991,7 +2991,7 @@ elf_s390_relocate_section (bfd *output_bfd, } else if (r_type == R_390_TLS_LDCALL) { - if (!bfd_link_pic (info)) + if (!bfd_link_dll (info)) { unsigned int insn0, insn1; -- 2.33.1