From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by sourceware.org (Postfix) with ESMTPS id 6A2563969C15 for ; Wed, 18 Aug 2021 16:31:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A2563969C15 Received: by mail-yb1-xb32.google.com with SMTP id z5so6434950ybj.2 for ; Wed, 18 Aug 2021 09:31:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OCXLXQKuDgqlvWAAAo0tel/aSATS4PXaJMMyRiczyaw=; b=QVmJpwMVz7XYpOmcVg0pJAnzBBuB24uH3irIV6uYc16zhW1xF2N0XWVj3dTcVMPD93 TieHmR1Ub+NtVL07Inc7eMfC6xTz+JBxPy78h57jZcvgk/zX6BFR1zX0gBuclCYRPsNp m/ONZufSfNylLflwdBVbm7TmqnbDAL7UZGEnKJ8M3iRqdAXMts8Ur+VExRzz6QxjPxZq dxwdUIFF2YIm0OZ4mktoJIV4DQBq/bOFvXuf6inXgZvH7z6ivhXa7RZanGRRfC1/I/hA spqWu+AypT/SIBOC+8/l3fCa6YnvpR7ZVCPRvyeXVOWIgnj+sYc/FLthjjlBxT1WhNSW NQNw== X-Gm-Message-State: AOAM531KEzchYmhVdWe4TR0MQP6tZeAj5bti06gGngm/ZVl7aajgGMDN GX3oQCx+xoBt6i6icNTxvBZHEL1vw3z3UngMJ9xXSQ== X-Google-Smtp-Source: ABdhPJwUiVVFLsIaWPfT74nSuNo80CzjYx8ndh1qJjAQMpPdAIf38wEjqL5/FijXXC3Beeq2y0IJ5ydYlxcFC0KLX1I= X-Received: by 2002:a25:4c02:: with SMTP id z2mr12211459yba.308.1629304310802; Wed, 18 Aug 2021 09:31:50 -0700 (PDT) MIME-Version: 1.0 References: <20210818043744.1481986-1-maskray@google.com> In-Reply-To: From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Wed, 18 Aug 2021 09:31:39 -0700 Message-ID: Subject: Re: [PATCH] riscv: Drop reliance on _GLOBAL_OFFSET_TABLE_[0] To: Palmer Dabbelt Cc: libc-alpha@sourceware.org, Darius Rad Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-23.7 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2021 16:32:01 -0000 On Wed, Aug 18, 2021 at 9:22 AM Palmer Dabbelt wrote: > > On Tue, 17 Aug 2021 21:37:44 PDT (-0700), maskray@google.com wrote: > > &__ehdr_start is a better way to get the load address. > > > > This is similar to commits b37b75d269883a2c553bb7019a813094eb4e2dd1 > > (x86-64) and 43d06ed218fc8be58987bdfd00e21e5720f0b862 (aarch64). > > --- > > sysdeps/riscv/dl-machine.h | 21 ++++++++++----------- > > 1 file changed, 10 insertions(+), 11 deletions(-) > > > > diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h > > index aedf69fcdd..5b0746175c 100644 > > --- a/sysdeps/riscv/dl-machine.h > > +++ b/sysdeps/riscv/dl-machine.h > > @@ -76,27 +76,26 @@ elf_machine_matches_host (const ElfW(Ehdr) *ehdr) > > return 1; > > } > > > > +/* Return the run-time load address of the shared object. */ > > +static inline ElfW(Addr) > > +elf_machine_load_address (void) > > +{ > > + extern const ElfW(Ehdr) __ehdr_start attribute_hidden; > > + return (ElfW(Addr)) &__ehdr_start; > > +} > > + > > /* Return the link-time address of _DYNAMIC. */ > > static inline ElfW(Addr) > > elf_machine_dynamic (void) > > { > > - extern ElfW(Addr) _GLOBAL_OFFSET_TABLE_ __attribute__ ((visibility ("hidden"))); > > - return _GLOBAL_OFFSET_TABLE_; > > + extern ElfW(Dyn) _DYNAMIC[] attribute_hidden; > > + return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address (); > > } > > > > #define STRINGXP(X) __STRING (X) > > #define STRINGXV(X) STRINGV_ (X) > > #define STRINGV_(...) # __VA_ARGS__ > > > > -/* Return the run-time load address of the shared object. */ > > -static inline ElfW(Addr) > > -elf_machine_load_address (void) > > -{ > > - ElfW(Addr) load_addr; > > - asm ("lla %0, _DYNAMIC" : "=r" (load_addr)); > > - return load_addr - elf_machine_dynamic (); > > -} > > - > > /* Initial entry point code for the dynamic linker. > > The C function `_dl_start' is the real entry point; > > its return value is the user program's entry point. */ > > Reviewed-by: Palmer Dabbelt > Acked-by: Palmer Dabbelt > > LMK if you want me to commit this, but from the history it looks like > you have commit access so feel free to yourself (assuming you've built > it for all our targets). > > Thanks! I have the commit access:) Checked with scripts/build-many-glibcs.py /tmp/glibc-many glibcs riscv64-linux-gnu-rv64imafdc-lp64d --keep all (and riscv32-linux-gnu-rv32imac-ilp32) and ran elf/ldconfig & elf/ld.so with qemu-riscv64-static.