From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 4E64E385840D for ; Tue, 19 Dec 2023 17:44:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E64E385840D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4E64E385840D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703007854; cv=none; b=GpneJnQZ2ovtNu7GXUMI3pm1O8K0dvCQIaylwk1CqT6YHhG1kBu4GbE9DRHtvKFDu9qCTtFJzYOygUiWK1CJN/Fd5kQPtDOKQpTLq56PdhYn4YAUiEa2WrBBXltQ/ciQHNT4Fy8fE8+FlSMJILM4uMm02gnF70LhYdJOpJFfSpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703007854; c=relaxed/simple; bh=PDajqNHfrp1PKE36LdBYUeV0IaK2GQs7+v1QUB5WuEI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=uxbQhTV8q0xPYyOIwK88ocIY0F+uNfGMelyriru41+jN0FkQVd+We4bWImO5pLRbyXSTXVa4FzxtiNTGqI+b/8Ctp/ZrIKPPniITNe4C7PAWYL2gXGPD22bWSqX5wf5D5nSSkXoCGCjUX2IeYCtNdbh05SqW2VQmV7nloquNcEY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d3c394c1f4so13294875ad.2 for ; Tue, 19 Dec 2023 09:44:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703007852; x=1703612652; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=wfSAV0VYDUgbveuIA4huLINwghQKnq3FcuH1lxhbiR4=; b=X34zufmXV/FFG3ZQCobUREEH1JOWpZAcR0xLHBLvbP8zqHl5Bi216R4skdkSwdxeg/ sVxRm2opDuXmeRDQ8/dD/cOEOlswhbJcEBzWFPYf5JZeLx1OQfHBovJgMTKNacMRLt0v FSScmCSbBzxMSJkTaRtqqFNtvaAVC1ojYplILENH03cPd2T2mPGdIYJW5Wzh6zs7e1CH PKWZpXPPp9wuGEmIjqtiWcTYg+ZDpv3ckHi9TuF1v9Q89gDZjQlrKia+bExqA9jujMGE 6BJwbhYEOGw2RInfdqeDNX+8gXIGGGmnIXqU6eQ+W+aYsN2C07+bZSy38RThh1efi9fK EVSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007852; x=1703612652; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wfSAV0VYDUgbveuIA4huLINwghQKnq3FcuH1lxhbiR4=; b=Enx+rznGadp3xzZx9mXd7wwSzHtYUkFJhsKv6HuogKihnsdtCQlPfHGS7cFMQzbq8X WV1fy/MkkSAjQ7bswoqD2V819lxRQM1KTZly4m0BD8YYo9126ZRiqqjKR3cgzK+xBHEm 8j0kYrKWu+Q/88s8CD+qazqJ0nyjtVEl6CeLh3jXymO+ueeyS9PY+QgVtNdok0FzBE9N hSjKiogxWfkPljvm57c8n4ftYslH2hvrUymUALOigBJKovpIc1+T5PexoJZhESjAFTl4 GGiirQHy4QLu7r2itYRZvcCy4jI6e/ZAfzWDPj+WG6n8yn9yc5UB7JHDf4wVR6g2p6ds LDJQ== X-Gm-Message-State: AOJu0YwVx7BRj0RkL0NwhQSpyGvNJjZFOuXllIx643ony3bZQ7cY9/HZ cR1y8LK6iZFBwpkO3SnAtTPVstYgM9P8pYZgP74= X-Google-Smtp-Source: AGHT+IHofP6snIyXw1htmfvvBZtas+RJt59HEN49v6OB+20GgOLZoYLG+G+PvEcIEGm/5zfGKh95lg== X-Received: by 2002:a17:902:d4c3:b0:1d3:ce75:a691 with SMTP id o3-20020a170902d4c300b001d3ce75a691mr2078538plg.35.1703007852175; Tue, 19 Dec 2023 09:44:12 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c3:f221:61c5:6e1b:a722:cc66? ([2804:1b3:a7c3:f221:61c5:6e1b:a722:cc66]) by smtp.gmail.com with ESMTPSA id d3-20020a170903230300b001d08bbcf78bsm21322404plh.74.2023.12.19.09.44.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Dec 2023 09:44:11 -0800 (PST) Message-ID: <98a131f9-b847-4e99-8ddd-01b3993d92b0@linaro.org> Date: Tue, 19 Dec 2023 14:44:08 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] RISC-V: Enable static-pie. Content-Language: en-US To: yanzhang.wang@intel.com, libc-alpha@sourceware.org Cc: carlos@redhat.com, palmer@dabbelt.com References: <20230810233348.1214955-1-yanzhang.wang@intel.com> <20230815014434.1902446-1-yanzhang.wang@intel.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20230815014434.1902446-1-yanzhang.wang@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 14/08/23 22:44, yanzhang.wang--- via Libc-alpha 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. To enable this support as default woudl equires GCC commit b20e59f49b51b7baf05e1b727be5da947e617496 that pass the expected ld flags. Otherwise, building static-pie will fail with missing _DYNAMIC: riscv64-glibc-linux-gnu-gcc -o [...] support/test-run-command -nostdlib -nostartfiles -static -static-pie [...] [...]libc.a(dl-reloc-static-pie.o): in function `_dl_relocate_static_pie': [...]elf/dl-reloc-static-pie.c:48: undefined reference to `_DYNAMIC' I think you will need to add something similar to what loongarch did on sysdeps/loongarch/configure.ac and check whether compile do actually supports -static-pie. > --- > sysdeps/riscv/configure | 1 + > sysdeps/riscv/configure.ac | 3 +++ > sysdeps/riscv/dl-machine.h | 2 +- > 3 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure > index acd1f5e743..ecaf8e2a0b 100644 > --- a/sysdeps/riscv/configure > +++ b/sysdeps/riscv/configure > @@ -31,3 +31,4 @@ printf "%s\n" "$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