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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 5DC723858D29 for ; Thu, 23 Sep 2021 17:40:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5DC723858D29 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-30o1teuYMKuIjZ0_Zx9wXA-1; Thu, 23 Sep 2021 13:40:21 -0400 X-MC-Unique: 30o1teuYMKuIjZ0_Zx9wXA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8A40108468F; Thu, 23 Sep 2021 17:40:20 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.176]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADD8D60936; Thu, 23 Sep 2021 17:40:10 +0000 (UTC) From: Florian Weimer To: =?utf-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Cc: "H.J. Lu" , GNU C Library , "Carlos O'Donell" , Adhemerval Zanella , Joseph Myers Subject: Re: [PATCH v2] elf: Avoid nested functions in the loader (all ports) [BZ #27220] References: <20210923071719.315444-1-maskray@google.com> <87v92rnrkg.fsf@oldenburg.str.redhat.com> Date: Thu, 23 Sep 2021 19:40:05 +0200 In-Reply-To: (=?utf-8?B?IkbEgW5nLXJ1w6wgU8OybmciJ3M=?= message of "Thu, 23 Sep 2021 10:34:09 -0700") Message-ID: <87ilyrnqbu.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: 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: Thu, 23 Sep 2021 17:40:25 -0000 * F=C4=81ng-ru=C3=AC S=C3=B2ng: > On Thu, Sep 23, 2021 at 10:13 AM Florian Weimer wrot= e: >> >> * F=C4=81ng-ru=C3=AC S=C3=B2ng: >> >> > For elf/dl-reloc.os on x86-64, I think the nested function version can >> > use *(rbp - offset) to get some arguments. >> > The new version needs more instructions but the cost is small compared >> > with the expensive _dl_lookup_symbol_x. >> >> I have a patch that reduces the number of _dl_lookup_symbol_x calls for >> the self-relocation (bootstrap or not): >> >> [v3,3/3] elf: Rework exception handling in the dynamic loader [BZ #254= 86] >> >> >> It needs rebase on the current tree. >> >> We recently lost the internal _r_debug reference, which is probably a >> bug. Other architectures have some other crud in ld.so. But I think we >> can get the number of symbols used in self-relocation down to zero on >> all architectures fairly easily. >> >> Once we do that, how much of the bootstrap relocation goo is really >> left? >> >> Thanks, >> Florian >> > > If self-relocations means relocations used in rtld.c and > elf/dl-reloc-static-pie.o: > > The new version doesn't cause differences near _dl_lookup_symbol_x call s= ites. > I think the relocation code sequence doesn't change. > > @@ -5757,7 +5789,7 @@ > push 0 > push 1 > call > - 0000000000004ec7: R_X86_64_PLT32 _dl_lookup_symbol= _x-0x4 > + 0000000000004f27: R_X86_64_PLT32 _dl_lookup_symbol= _x-0x4 > : > pop r8 > pop r9 > > The new rtld.os is slightly larger, but I guess that it is just > because GCC inlines one more place. What I meant is that we can toss out a lot of the self-relocation code once we *know* that we don't need to call _dl_lookup_symbol_x because no relocations use symbols. Thanks, Florian