From patchwork Tue Nov 26 10:53:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 101909 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D165F3858CDA for ; Tue, 26 Nov 2024 10:54:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D165F3858CDA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=J0U68rsZ X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 6AB7E3858D37 for ; Tue, 26 Nov 2024 10:53:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AB7E3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6AB7E3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732618399; cv=none; b=jBxJc0JuGpVxQwL0GJTRsfUrooy8AAFj16q7tItu1xliWkGnNB39JAf2rb5S7qaAKCiRjVnDEZSVjVB8Hj7QbgMLnVSMLEqDWYa9Rz5KGTjt2turonzE6ygLV7siseSemXreW89+A7TLE+qkKA6o9Vpwfg+uxviDHUb5bivd1uc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732618399; c=relaxed/simple; bh=eiws+R6fEoAyYwgaZlTxELnTVYwdKCBLUc4b2Dsscjc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=qhJStODgsWIBZVOiIMHcW14bZ/FEfdmnej/Te+EXbRSMvxTj4v05kjSdVGNmMtVR71DOgl81NPS3xOdc620ApQfP47t1imQWkgsZOFPF2TY7poDGCVzajKQHSB/yf8+XxjstAEcIK1Qf5MQBcfeiGcg+qQj0gk9vk1P+J4ALWo8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AB7E3858D37 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-724e5fb3f9dso3373599b3a.3 for ; Tue, 26 Nov 2024 02:53:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732618398; x=1733223198; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=Vbje8WJS1VHAa4UrbE74fLSQ9PJw3XP19lFBfz/KN90=; b=J0U68rsZw9W77HvLn5di/7PqC/tlOJHgI8g8gCLIPjcnbkiMOENFBpFd4exzli7Y0C 2ay5MevegYWIGOXRVCwslq6pcTexRbHnrF6YROFx58vrXg6aqCMfhknh+c7Kkqvre04n LCxJa2IS6NMq24oEmYQwNxLCHkA5VDJTQFyrsOGA+lDPaKI3007bbMofde4S58McQwHo ssctklEkLVeXMZwu5L5pgDiGTzGzByT8dXL/sPzZpNxQmmU8eIiSiol4NdRoP/LOW8I1 DAM48hCLAwOojH2A66kioVakVsWdS2NhInSTtqXtvBatazYkVlMdehfRK2T9tkXYNiZj +mUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732618398; x=1733223198; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Vbje8WJS1VHAa4UrbE74fLSQ9PJw3XP19lFBfz/KN90=; b=NERfy/R6dPHUW9uL86m+hTumlCRybF/f9ZjOlLEUZU4gP8VofDb6oUx1Ppuqkchvlx EkODcdmjOlYAwu1bNV+qK52W36NkYFb1DIE67Fv+lSuNRG2nGrOgVH+CLqrUbiDMr57G WPsFBY8Z3w/te9U//nYYK9Ycb+4gHFXgNbiIA407BzbBI4DhG0Ftdl0P6yR9wynO5jc9 Yz3uaBo9COHfWFvfTXnfnkGVE+iSUQwnfYtnOk5tXyQC6A/M8LxRNld9ELFaRTOSGXgv a09tjH5dRm0amAyjaSOSASTO5OLihtFUwlrL1F23X6mvDQ+smNH/Km13OUss5Dzf0Crv 3d3g== X-Gm-Message-State: AOJu0YzAXkYC1JyjE88j68qYmnTyZWjeVp2zvPW76114AtRQniznJ44F lI7v4rm/zCj1jTHlWeLoGi1UKU2l67KpX9tales3T5XElwKY7YcQw+wWdQ== X-Gm-Gg: ASbGncs3kpMJeOzoV2JlYcc/A2HIcQqxti6g58IjYXiitZ3WhvO+vmAaCl8HAHf7yRq NXUr+opCzExTvckbxOgO7l8H5ChxFowgFzV3c+hDEz7X+UtTeDg3RtbPmKtecFaEVaqXclCu8+E A0ziK9zJG5i4k9r49TbouzdULOBlnIHRB2rpqzcWp6CyJsZ/0IrcMYRDVBQ4SkMq1rL/P4fJW7K 3hzibOznowhkJPGmhN5LV23F/ip02tBiWdlWQtaze6GCc4LFy9g+CjUZ/AmKUR+9GIcJmyVpszr bOgkjnuqfYFMAtcfv15r X-Google-Smtp-Source: AGHT+IGeRwh/o1b0blRCzlx6JMO7BfqK+bBUxc+BAanPjw/bQcmTlmMtzvJqWEbr/V8qwmx1S/HNAQ== X-Received: by 2002:a05:6a00:3d53:b0:724:680d:d12c with SMTP id d2e1a72fcca58-724df60395amr22001545b3a.12.1732618397991; Tue, 26 Nov 2024 02:53:17 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72523d3d08csm859948b3a.4.2024.11.26.02.53.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 02:53:17 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id D7B021140399; Tue, 26 Nov 2024 21:23:14 +1030 (ACDT) Date: Tue, 26 Nov 2024 21:23:14 +1030 From: Alan Modra To: binutils@sourceware.org Subject: PR32387 ppc64 TLS optimization bug with -fno-plt code Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3033.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org The inline plt code emitted by gcc is incompatible with the linker/ld.so --tls-get-addr-optimize scheme. This is the runtime optimisation where the first call to __tls_get_addr results in __tls_get_addr updating the tls_index pair, then the special linker stub using that to short-circuit second and subsequent calls for a given tls symbol. Enabled by default when the linker sees __tls_get_addr_opt is preseent, and enabled in ld.so when DT_PPC64_OPT has PPC64_OPT_TLS set. Note that this is distinct from link-time tls optimisation. PR 32387 * elf64-ppc.c (ppc64_elf_check_relocs): Disable tls_get_addr_opt on detecting inline plt calls to __tls_get_addr. diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 9674fcdd6be..f7debc1edbc 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -4915,6 +4915,15 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, tls_type = 0; switch (r_type) { + case R_PPC64_PLTSEQ: + case R_PPC64_PLTSEQ_NOTOC: + /* Inline plt call code emitted by gcc doesn't support + modifying the tls_index words to short-circuit + __tls_get_addr calls. See PR32387. */ + if (h != NULL && (h == tga || h == dottga)) + htab->params->tls_get_addr_opt = 0; + break; + case R_PPC64_TLSGD: case R_PPC64_TLSLD: /* These special tls relocs tie a call to __tls_get_addr with