From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A567E3858CDB for ; Fri, 12 May 2023 20:11:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A567E3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683922311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lTd3glUIcjbzMYzD0y3YK45Rr9bB3gRLWeqmbjveWC8=; b=fb3l5DJoB3ZP7LNnfDzIaaZGKXQN0bPFDU4BOsaqy7g+i5bx+YZSTr6J7jJsrhVyGdn9uu lzR31/nVhGsRB/i040xoxTlbbY267ZldegEJ0efilc8ELZcMsi5xtj5+0FT2+QViwuJ8t8 DdgHnLIauD6UR1GqVhMyYtC42QdtAC0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-127-Ni7VtfMvOjOXmSRl3A0aXg-1; Fri, 12 May 2023 16:11:48 -0400 X-MC-Unique: Ni7VtfMvOjOXmSRl3A0aXg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69B05101A551; Fri, 12 May 2023 20:11:47 +0000 (UTC) Received: from oldenburg3.str.redhat.com (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 126BF48FB11; Fri, 12 May 2023 20:11:44 +0000 (UTC) From: Florian Weimer To: Fangrui Song Cc: Lukasz Stelmach , libc-alpha@sourceware.org, schwab@suse.de, palmer@dabbelt.com, adhemerval.zanella@linaro.org, joseph@codesourcery.com, binutils@sourceware.org, Marek Pikula , Marek Szyprowski , Karol Lewandowski Subject: Re: global pointer gets overwritten with dlopen(3) on RISC-V References: Date: Fri, 12 May 2023 22:11:43 +0200 In-Reply-To: (Fangrui Song's message of "Fri, 12 May 2023 12:50:01 -0700") Message-ID: <877ctdpaww.fsf@oldenburg3.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Fangrui Song: >>1. Make -mno-relax the default for ld(1) (on Linux?). We have no >>benchmarks whatsoever, but global variables aren't very popular in >>application code these days and the gp register allows access to a >>single memory page (4kB) only. No big deal really. > > I do agree that --no-relax-gp is a sensible default choice for GNU ld. > https://maskray.me/blog/2021-03-14-the-dark-side-of-riscv-linker-relaxation#global-pointer-relaxation > > Perhaps you can start a separate topic on binutils? :) > > According to a doc from SiFive about -static -mcpu=sifive-u74 builds, > https://docs.google.com/spreadsheets/d/14V7cPbyc80AcGHzsMaw9hYb232dzRbGCmTApnxj-SpU/edit#gid=0 > global pointer relaxation saves at best 0.5% size (I guess that refers > to .text. If we count all allocable sections, the percentage is likely > even smaller.) For a mature toolchain, 0.5% in code size reduction would be *a lot*, so I wouldn't dismiss that. Do we have a reproducer? Is the issue actually about gp relaxation for the main executable? Thanks, Florian