From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 98A6D3858D20 for ; Fri, 11 Aug 2023 01:57:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 98A6D3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dabbelt.com Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bbc64f9a91so13580565ad.0 for ; Thu, 10 Aug 2023 18:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20221208.gappssmtp.com; s=20221208; t=1691719076; x=1692323876; 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=UGXZzmNAgzc/ZgfiWpuK0Zgh89865blSrJYvINZTVKw=; b=XI5k2Xs/SmLsRSXzJMnDvBMZ3UlufXA1F1P2mHVnNDShmHDLeV8qufqYJgOYBtYJzP Snzqxt63lCWm3z7JyaLJwbAFARMbygjKdrLmbv1Z0rWzB8TwQG7CH9GBVrOvYMpLUUP+ nbagRdj9+kJFdDGJzGrHjyZDdpR/8jvuyXDA7999Pvz4n+wqqbkA2Bf6o1R9PE5mIAcM 805zT3x93TKajFtgqIXkr4f+D9JUGIYQqXIMT62+RBQfJax9tUWzbhA0PbTwcLuXTymG nr28oGAqYobo1gL7hEE2Fad1e/lIhWAX7KjesWw+wbP/k8WAdH5q2R1SRf3u54VkieWA 2jCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691719076; x=1692323876; 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=UGXZzmNAgzc/ZgfiWpuK0Zgh89865blSrJYvINZTVKw=; b=JXTooheBgvrt8tr2iIUw0If27ohDKV7AEK+QKE63jSioPs4PmtunLS10fwFUryJKc+ pVPKILmduK/Q3WrDWJcvB9a7ITM1fCWzYlDXzAAJwGztN7LObISjwu4Rmw7jdId/M0gs Ifx5afpLHmqs+q8JyLysIimpkkFcklyzvdkoxY5aBNP3kLhntvcm7CEPP8W6EiyOp5if PfO6KL3mM86jeVaMn4V9UDExB1RERPYf+zsBDvcKiURMTPFq0qsHSFXZ72T+O319ffTV tVqZGM4iE4sXDg2/NlSYrkQwfYVw9p1gW6sRlu0X0QcPcZBygzznMYjiyDf2lbfsQhzm LUKA== X-Gm-Message-State: AOJu0Yw0/ERt3JcyAaj/HDt8MsrYnv05/6i+pvLTi/A102ek077If6He BY9Zvh0ybq26qelAkhPs65/TQE96M4s8EwNWyxI= X-Google-Smtp-Source: AGHT+IE03UK4e6fnTYoDwfuc9J2+Y2TgMD7w3XKihOH/ESfxhVXUV3fJBzNSS4VO4VFjfj44MFkHYA== X-Received: by 2002:a17:902:f68d:b0:1bc:14f0:b76c with SMTP id l13-20020a170902f68d00b001bc14f0b76cmr594298plg.65.1691719076164; Thu, 10 Aug 2023 18:57:56 -0700 (PDT) Received: from localhost ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id x5-20020a170902b40500b001b890009634sm2459128plr.139.2023.08.10.18.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 18:57:54 -0700 (PDT) Date: Thu, 10 Aug 2023 18:57:54 -0700 (PDT) X-Google-Original-Date: Thu, 10 Aug 2023 18:57:53 PDT (-0700) Subject: Re: [PATCH] RISC-V: Enable static-pie. In-Reply-To: <20230810233348.1214955-1-yanzhang.wang@intel.com> CC: libc-alpha@sourceware.org From: Palmer Dabbelt To: libc-alpha@sourceware.org, yanzhang.wang@intel.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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,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 List-Id: On Thu, 10 Aug 2023 16:33:48 PDT (-0700), libc-alpha@sourceware.org wrote: > From: Yanzhang Wang > > This patch referents the commit 374cef3 to add static-pie support. And > because the dummy link map is used when relocating ourselves, so need > not to set __global_pointer$ at this time. Do you have test results? IIRC the only reason we didn't enable this when submitting the original port was because we didn't have time to test it. If it's passing a reasonable amount of the tests it's fine with me, but we need to at least look because there could be lurking issues. > --- > sysdeps/riscv/configure | 2 ++ > sysdeps/riscv/configure.ac | 3 +++ > sysdeps/riscv/dl-machine.h | 2 +- > 3 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure > index 2372225a26..340163779f 100644 > --- a/sysdeps/riscv/configure > +++ b/sysdeps/riscv/configure > @@ -29,3 +29,5 @@ fi > $as_echo "$libc_cv_riscv_r_align" >&6; } > config_vars="$config_vars > riscv-r-align = $libc_cv_riscv_r_align" > + > +$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h > diff --git a/sysdeps/riscv/configure.ac b/sysdeps/riscv/configure.ac > index dbcc216689..36da2b5396 100644 > --- a/sysdeps/riscv/configure.ac > +++ b/sysdeps/riscv/configure.ac > @@ -16,3 +16,6 @@ EOF > fi > rm -rf conftest.*]) > LIBC_CONFIG_VAR([riscv-r-align], [$libc_cv_riscv_r_align]) > + > +dnl Static PIE is supported. > +AC_DEFINE(SUPPORT_STATIC_PIE) > diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h > index c0c9bd93ad..ad875c0828 100644 > --- a/sysdeps/riscv/dl-machine.h > +++ b/sysdeps/riscv/dl-machine.h > @@ -323,7 +323,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], > gotplt[1] = (ElfW(Addr)) l; > } > > - if (l->l_type == lt_executable) > + if (l->l_type == lt_executable && l->l_scope != NULL) > { > /* The __global_pointer$ may not be defined by the linker if the > $gp register does not be used to access the global variable