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 ESMTPS id EB01D3858402 for ; Thu, 11 Nov 2021 17:39:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EB01D3858402 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-589-eZmvQcf7NLyMLijAJfsReA-1; Thu, 11 Nov 2021 12:39:51 -0500 X-MC-Unique: eZmvQcf7NLyMLijAJfsReA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8389B9F92B; Thu, 11 Nov 2021 17:39:50 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B26619C59; Thu, 11 Nov 2021 17:39:43 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org, John Mellor-Crummey , Ben Woodard Subject: Re: [PATCH v5 18/22] elf: Issue la_symbind() for bind-now (BZ #23734) References: <20211109183347.2943786-1-adhemerval.zanella@linaro.org> <20211109183347.2943786-19-adhemerval.zanella@linaro.org> Date: Thu, 11 Nov 2021 18:39:41 +0100 In-Reply-To: <20211109183347.2943786-19-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Tue, 9 Nov 2021 15:33:43 -0300") Message-ID: <87czn6wq02.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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, 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, 11 Nov 2021 17:39:56 -0000 * Adhemerval Zanella: > The audit callback is not called for binaries built with -Wl,-z,now or > when LD_BIND_NOW=1 is used. The PLT tracking callbacks are still not > issue for such case, since this will would change the expected program > semantic (where no PTL is expected) and also yield performance > implications (such as for BZ#15533). > > To handle powerpc64 ELFv1 function descriptor, _dl_audit_symbind() > requires to know whether bind-now is used so the symbol value is > updated to function text segment instead of the ODP (for lazy binding > this is done by PPC64_LOAD_FUNCPTR on _dl_runtime_resolve). Typo: OPD (I think) This needs updates to sysdeps/hppa/dl-lookupcfg.h and sysdeps/ia64/dl-lookupcfg.h as well. Presently these two targets fail to build. > diff --git a/elf/dl-audit.c b/elf/dl-audit.c > index c3569cb357..4540d93913 100644 > --- a/elf/dl-audit.c > +++ b/elf/dl-audit.c > @@ -190,7 +190,7 @@ rtld_hidden_def (_dl_audit_symbind_alt) > void > _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, > const ElfW(Sym) *defsym, DL_FIXUP_VALUE_TYPE *value, > - lookup_t result) > + lookup_t result, bool bindnow) > { > reloc_result->bound = result; > /* Compute index of the symbol entry in the symbol table of the DSO with the > @@ -238,7 +238,8 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, > if (new_value != (uintptr_t) sym.st_value) > { > flags |= LA_SYMB_ALTVALUE; > - sym.st_value = new_value; > + sym.st_value = bindnow > + ? DL_FIXUP_BINDNOW_ADDR_VALUE (new_value) : new_value; > } > } I think if PLT enter/exit hooks are not available, we should set LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT in flags before calling the symbind callback. I find DL_FIXUP_BINDNOW_ADDR_VALUE very confusing. Why is it safe to extract just the code address from the function descriptor? In the future, I want to call symbind for all symbol bindings. Basically, I want to remove > + if (ELFW(R_TYPE) (r->r_info) == ELF_MACHINE_JMP_SLOT eventually, and add symbind callbacks for dlsym lookups. Hopefully we can make these changes compatible. Thanks, Florian