From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id E0C21398B896 for ; Wed, 18 Aug 2021 21:10:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0C21398B896 Received: by mail-pj1-x102d.google.com with SMTP id j1so3495517pjv.3 for ; Wed, 18 Aug 2021 14:10:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=feXU3EuaCVhTH6dGVsxxwJr/ICt5ozpjAe7KXjeoaDs=; b=S2xfKWSEaDhrjv2JbmNJhl7Q/vGSNNo6wWXlT7GHyrWlY9Tj//681DBgACX8DtHF+Y gHNVy3rVZfq35xtIw6k88x4vuQ4kOnddYGIL5YvVOPoZ89Wf4XGP+5j7upCDhBekCMI2 GaCpdLTbcxmpOUUtSnZq4pEgwQ8TSusv956Fv+KAcxPZ3wDQvsSO7AnhMj7yHZYAHzhd vDYvk3XZxmaZaki23nwLWwuxvU1iOTeAgRR3hx2WPOEsdeSeJoU/acCoAx00CycvLuMb xw2sll0ugT3BdATSao16kFsXAYzrSdTgtjiGmyhG+7jZs3YKhNkOetn7CM0oPfndED22 27FQ== X-Gm-Message-State: AOAM533k6AB5SQrMCMNeDymZiarzAWcFCXPMp4OgIQzCyIPmQdQGEdki +dJibKcdmiBOsUjBJBur/6Yg+BGAvHuHIw== X-Google-Smtp-Source: ABdhPJxlbZJWdpJfjj3W89ipczyYpjuhJXc6CN1FkI1GwCRUm4OWzjMLdBkWoU4yLLHa93TEQhLQwQ== X-Received: by 2002:a17:902:a604:b029:12c:dda2:30c4 with SMTP id u4-20020a170902a604b029012cdda230c4mr8552113plq.73.1629320999662; Wed, 18 Aug 2021 14:09:59 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id j35sm781149pgm.55.2021.08.18.14.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 14:09:59 -0700 (PDT) Date: Wed, 18 Aug 2021 14:09:59 -0700 (PDT) X-Google-Original-Date: Wed, 18 Aug 2021 14:09:57 PDT (-0700) Subject: Re: [PATCH] riscv: Drop reliance on _GLOBAL_OFFSET_TABLE_[0] In-Reply-To: CC: libc-alpha@sourceware.org, Darius Rad From: Palmer Dabbelt To: maskray@google.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=-27.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 21:10:11 -0000 On Wed, 18 Aug 2021 09:31:39 PDT (-0700), maskray@google.com wrote: > 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. Works for me. Thanks!