From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 2A3253858D1E for ; Mon, 26 Jun 2023 20:13:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A3253858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1b7dd061e9aso13153235ad.2 for ; Mon, 26 Jun 2023 13:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1687810435; x=1690402435; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=rd1hAA+X17/tKZv5btof7AmQyssmyfWN1ol/5V4xvI8=; b=pX7qHswQlga7WqTltGuguDue9Osi1lgyLM1r0Pwt0yhYNTaUARchSDgtfFJEVt/SJJ d8yZXxnSVqhC8g6Ejrtr6kwNif5L1nrboSxu/YyPixOf7Ms7pwZq9XuGxtnnBEZ/9d9h Z/P2fS8f1azQRitl0XaZFh1nQyVhXOaEOwQjU0vEXrYcYFirb1CBuVC22788TaZT4fLQ IJ0UIXusznNsCeMizjwlHcyj/ydi7dOP0TtNCJcfS83yB2vsAJtyvV/CyvTcD0/ojn0c yWwSlf+ZfANOEMycyD+G/1/MbJ5NIPLhAn9iXFE1BxxoTNrTFlq61HRf360Mjoe3G4P9 c5Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687810435; x=1690402435; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rd1hAA+X17/tKZv5btof7AmQyssmyfWN1ol/5V4xvI8=; b=Ku0dSNv0aHTCB5NOeyxLLZKQdinLJb5AnF8IJllTt/+KjUeusxrLtlG8s/JcyWj489 M06UcmCYWZ1nHadF+OgMYayUp0XkjJ2/tISzxngp+jk9AvzTtiY3pHuqoPn0C0xSzdYG 1lW9cLoF9Jq+jK2qavC4ASHf2u1gKQ4AfOpCCZ0Y86knbpNM1V/DnPQ6bZaBJ6v8uptw uMGjrY3hF4wpEYGPjRN8S+YmeEiVHNVspCQEt7nG3DU2SfaaQkckTRl6l/NfpklJQ79s zswZP1MlS5SGWURfitGpGKoHxUtacUnSv3Fzc2atbwJ3Jg6wKDFyNHSpDQV2T98kK0gB 0Q0A== X-Gm-Message-State: AC+VfDwhOrY2NL9mB7yf1DHb4yu10bokOhmDlOYwdK7o8h7v6nyPYbix 1vManwCrIOKPCaz44g4aSaPSdjHrzuhtZklPVbY= X-Google-Smtp-Source: ACHHUZ4slLx6ndKiVE/uS+qkgE07mdT9BWYfzthgTnhOwx+dvbuRDY9trskHkT0LsGqXBM85EnVJ1Q== X-Received: by 2002:a17:902:7781:b0:1b3:f5c3:7682 with SMTP id o1-20020a170902778100b001b3f5c37682mr4936189pll.68.1687810435558; Mon, 26 Jun 2023 13:13:55 -0700 (PDT) Received: from localhost ([135.180.227.0]) by smtp.gmail.com with ESMTPSA id u10-20020a17090282ca00b001b8062c1db3sm2051372plz.82.2023.06.26.13.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 13:13:55 -0700 (PDT) Date: Mon, 26 Jun 2023 13:13:55 -0700 (PDT) X-Google-Original-Date: Mon, 26 Jun 2023 13:13:53 PDT (-0700) Subject: Re: [PATCH] RISC-V: Stop referencing __global_pointer$ under PIC In-Reply-To: CC: libc-alpha@sourceware.org, Jeff Law From: Palmer Dabbelt To: maskray@google.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 26 Jun 2023 13:12:41 PDT (-0700), maskray@google.com wrote: > On Thu, Jun 8, 2023 at 9:45 AM Palmer Dabbelt wrote: >> >> This has some cascading fallout related to PC-relative references to >> SHN_ABS that Jim reported in [1]. I have a workaround for that issue in >> binutils [2], but GP isn't useful in PIC so we might as well just stop >> referencing it at all. >> >> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=24678 >> Link: https://inbox.sourceware.org/binutils/20230608155214.32435-1-palmer@rivosinc.com/T/#u >> Signed-off-by: Palmer Dabbelt >> >> --- >> >> I haven't tested thiis or the binutils patch. There's a handful of >> coupled issues here that might take a bit to untangle, but this came up >> in the RISC-V LLVM sync this morning so I figured it would be best to >> send something along. >> --- >> sysdeps/riscv/start.S | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S >> index 6dfe65273f..5eaa8ccf2d 100644 >> --- a/sysdeps/riscv/start.S >> +++ b/sysdeps/riscv/start.S >> @@ -71,7 +71,9 @@ END (ENTRY_POINT) >> load_gp: >> .option push >> .option norelax >> +#if !(defined(__PIC__) || defined(__pic__) || defined(PIC) || defined(pic)) >> lla gp, __global_pointer$ >> +#endif >> .option pop >> ret >> >> -- >> 2.40.1 >> > > I haven't read all the discussion yet.. If we want to detect > -fpic/-fPIC (no distinction in LLVM for non-sparc-non-ppc32 targets). > Checking just __PIC__ is sufficient. __PIC__ seems more popular than > __pic__ for open-source software. I found all four used other places in glibc and figured I'd just do the same, I'm not really sure it's necessary but it doesn't seem to hurt. > > % riscv64-linux-gnu-gcc -fpic -dM -E -xc /dev/null | grep -i pic > #define __pic__ 1 > #define __PIC__ 1 > #define __riscv_cmodel_pic 1 > % clang --target=riscv64 -fpic -dM -E -xc /dev/null | grep -i pic > #define __PIC__ 1 > #define __pic__ 1 > > (-fPIC changes the macro replacements to 2.) > > -- > 宋方睿