Message ID | 20220114034126.25733-1-palmer@rivosinc.com |
---|---|
State | Deferred, archived |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> 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 5C6CC385842F for <patchwork@sourceware.org>; Fri, 14 Jan 2022 03:42:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 8D3D93858D37 for <gcc-patches@gcc.gnu.org>; Fri, 14 Jan 2022 03:42:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D3D93858D37 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-pg1-x52a.google.com with SMTP id t32so1685012pgm.7 for <gcc-patches@gcc.gnu.org>; Thu, 13 Jan 2022 19:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=subject:date:message-id:mime-version:content-transfer-encoding:cc :from:to; bh=oNQ2/H+mNnfOu/mtNXEzUfKPyG8tajdbmw4ifcQvfos=; b=PPLvgpQ83k9SHKKZd+MMDrApj1HhxR+Ht2XRbfcrTaO05hbqRdukjEZE7zQ5YqLWDf fbHoZtQ4a7tQqWxEdy4241ex3+s8eFGObSeCRyB4XmP88RG6x3e+nneVHIukr6mQEJNs 6PDsluvBjeuPxJQ7b5OZsf/jY7xD0F7Gb0/5nTG3siu9nezQli0p2Z6Exp9P6bzVLnw4 znJZ/1QIrPnq2dVL9v/3g524xFxd4/pIeqwcYLQP8KatGlgrWF5XHwd/PwBwJLHxYeE2 fVLcEukU2J0oN9ATWEIojJfn/ozZWcs/t0WuSfbMG7j+SWuW3pVCz6OXaDh/WwlNstGC enKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:date:message-id:mime-version :content-transfer-encoding:cc:from:to; bh=oNQ2/H+mNnfOu/mtNXEzUfKPyG8tajdbmw4ifcQvfos=; b=MussqU8lOh74vKrNhkwRKf+iMGoKkNgpjZsh7kkte6t3S2maggjqzknymTKr5e1xae xxHnzbhK9q4eWHeXFfQGczpNP35Jhax8uQm0NQVhFdzaJsmmOkOCVTquPM1yRevALPcE /wNREauIMHL1Ag3sf7reiMk774OotYFvGZ/4ZGXoYJVQue5OtPaFdhpVtY67UxBAmVFz zYxSHl3tX+q35YJuZr7AfLi7gxg+hYQDwZLeFyaYwKWQLmUuv13vv1ZbESbBKcIwV6cu 5t1iwgs4jMyuVyfHXgtepGN5CtgDCbu/Or46ssPfLmHgoro7Y7l5SW0VGagRJeDTC7l+ xz2A== X-Gm-Message-State: AOAM530k3zMEzQTqv8xm/BDlZ1pQ4Q+CugCMLc92vBwmq28X7NBeSEnF 0ybDY8/hOpv8JV3gJ2UlFH21Ig== X-Google-Smtp-Source: ABdhPJwaEDKAL1qwhDGXUVxoFdI4P4umFM+LxBqsTTOiE7DHx2OfL4y/633+u9chRgMxKQtbV/ghEA== X-Received: by 2002:a63:7110:: with SMTP id m16mr6369665pgc.621.1642131735596; Thu, 13 Jan 2022 19:42:15 -0800 (PST) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id 10sm4083507pfm.56.2022.01.13.19.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jan 2022 19:42:14 -0800 (PST) Subject: [PATCH] RISC-V: Document the degree of position independence that medany affords Date: Thu, 13 Jan 2022 19:41:26 -0800 Message-Id: <20220114034126.25733-1-palmer@rivosinc.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Palmer Dabbelt <palmer@rivosinc.com> To: gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-12.2 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
RISC-V: Document the degree of position independence that medany affords
|
|
Commit Message
Palmer Dabbelt
Jan. 14, 2022, 3:41 a.m. UTC
The code generated by -mcmodel=medany is defined to be
position-independent, but is not guarnteed to function correctly when
linked into position-independent executables or libraries. See the
recent discussion at the psABI specification [1] for more details.
[1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/245
gcc/ChangeLog:
* doc/invoke.texi: Document the degree of position independence
that -mcmodel=medany affords.
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
---
gcc/doc/invoke.texi | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Fri, Jan 14, 2022 at 4:42 AM Palmer Dabbelt <palmer@rivosinc.com> wrote: > > The code generated by -mcmodel=medany is defined to be > position-independent, but is not guarnteed to function correctly when > linked into position-independent executables or libraries. See the > recent discussion at the psABI specification [1] for more details. > > [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/245 > > gcc/ChangeLog: > > * doc/invoke.texi: Document the degree of position independence > that -mcmodel=medany affords. > > Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> > --- > gcc/doc/invoke.texi | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 5504971ea81..eaba12bb61f 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -27568,6 +27568,10 @@ Generate code for the medium-any code model. The program and its statically > defined symbols must be within any single 2 GiB address range. Programs can be > statically or dynamically linked. > > +The code generated by the medium-any code model is position-independent, but is > +not guarnteed to function correctly when linked into position-independent > +executables or libraries. Typo: guarnteed -> guaranteed I think it would be more helpful from a user perspective if a hint to the solution (i.e. use -fPIC) would be there. What about something like this: """ The code generated by the medium-any code model is position-independent. However, to link such code into position-independent executables or libraries, the corresponding flags to enable position-independent code generation still need to be provided (e.g. -fPIC or -fPIE). """ > @item -mexplicit-relocs > @itemx -mno-exlicit-relocs > Use or do not use assembler relocation operators when dealing with symbolic > -- > 2.32.0
On Thu, 13 Jan 2022 21:54:45 PST (-0800), gcc-patches@gcc.gnu.org wrote: > On Fri, Jan 14, 2022 at 4:42 AM Palmer Dabbelt <palmer@rivosinc.com> wrote: >> >> The code generated by -mcmodel=medany is defined to be >> position-independent, but is not guarnteed to function correctly when >> linked into position-independent executables or libraries. See the >> recent discussion at the psABI specification [1] for more details. >> >> [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/245 >> >> gcc/ChangeLog: >> >> * doc/invoke.texi: Document the degree of position independence >> that -mcmodel=medany affords. >> >> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> >> --- >> gcc/doc/invoke.texi | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi >> index 5504971ea81..eaba12bb61f 100644 >> --- a/gcc/doc/invoke.texi >> +++ b/gcc/doc/invoke.texi >> @@ -27568,6 +27568,10 @@ Generate code for the medium-any code model. The program and its statically >> defined symbols must be within any single 2 GiB address range. Programs can be >> statically or dynamically linked. >> >> +The code generated by the medium-any code model is position-independent, but is >> +not guarnteed to function correctly when linked into position-independent >> +executables or libraries. > > Typo: guarnteed -> guaranteed Thanks. IDK why I still can't figure out how to spell that word ;) > I think it would be more helpful from a user perspective if a hint to > the solution > (i.e. use -fPIC) would be there. What about something like this: > """ > The code generated by the medium-any code model is position-independent. > However, to link such code into position-independent executables or libraries, > the corresponding flags to enable position-independent code generation > still need to be provided (e.g. -fPIC or -fPIE). > """ I'd tried to make this more detailed, but everything I came up with was too verbose. What you've got reads well, but it's not entirely accurate: * A lot of distros are defaulting to PIE now and there's "-fpic" and "-fpie", so it's really more of a "maybe pass -fpic, -fpie, -fPIE or -fPIC but definitely don't pass the -no versions of those" requirement. * The code sequences generated by medany (without any of those PIC/pie options enabled) can be linked into position-independent executables, it's just might not result in symbol addresses that resolve as expected. Given that those constraints are well documented elsewhere (the GCC documentation for the arguments, and the psABI threads for the compiler/linker thing) I don't think it's strictly necessary to include everything here. The rest of these blurbs are pretty terse and require users to understand these non-local definitions, so it's certainly in line with what's there. That said, I do think this one is pretty tricky (it certainly tricked me), so if you or someone else has a better way of describing the actual constraints directly here then I'm all ears -- I couldn't come up with anything, though. [As an aside, when I had the -fPIC blurb in medany I'd also added it to medlow as it's exactly the same there, but that also seemed too verbose.] >> @item -mexplicit-relocs >> @itemx -mno-exlicit-relocs >> Use or do not use assembler relocation operators when dealing with symbolic >> -- >> 2.32.0
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 5504971ea81..eaba12bb61f 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -27568,6 +27568,10 @@ Generate code for the medium-any code model. The program and its statically defined symbols must be within any single 2 GiB address range. Programs can be statically or dynamically linked. +The code generated by the medium-any code model is position-independent, but is +not guarnteed to function correctly when linked into position-independent +executables or libraries. + @item -mexplicit-relocs @itemx -mno-exlicit-relocs Use or do not use assembler relocation operators when dealing with symbolic