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.133.124]) by sourceware.org (Postfix) with ESMTPS id 2752C3858CDB for ; Mon, 8 Aug 2022 13:19:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2752C3858CDB 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-602-cIoTm_3wOoCGUEVRn4azew-1; Mon, 08 Aug 2022 09:19:21 -0400 X-MC-Unique: cIoTm_3wOoCGUEVRn4azew-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1772E806019; Mon, 8 Aug 2022 13:19:19 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6634C2026D4C; Mon, 8 Aug 2022 13:19:18 +0000 (UTC) From: Florian Weimer To: Lv Ying Cc: libc-alpha@sourceware.org, lvying6@huawei.com Subject: Re: [RFC] elf: fine-grained output LD_DEBUG log when symbol lookup error References: <20220807120003.313131-1-lvying.system.thoughts@gmail.com> Date: Mon, 08 Aug 2022 15:19:16 +0200 In-Reply-To: <20220807120003.313131-1-lvying.system.thoughts@gmail.com> (Lv Ying's message of "Sun, 7 Aug 2022 05:00:03 -0700") Message-ID: <875yj2ootn.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.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Mon, 08 Aug 2022 13:19:24 -0000 * Lv Ying: > When LD_DEBUG environment variable is set except "unused" value, symbol lookup error > in _dl_lookup_symbol_x will output unrelated debugging information which mess up the > "files" "libs" "reloc" log. > > "undefined symbol" debugging information should only output when LD_DEBUG="symbols|all". > --- > elf/dl-lookup.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c > index 4c86dc694e..6085c6c90c 100644 > --- a/elf/dl-lookup.c > +++ b/elf/dl-lookup.c > @@ -781,7 +781,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, > if (__glibc_unlikely (current_value.s == NULL)) > { > if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK) > - && !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED)) > + && (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS)) > { > /* We could find no value for a strong reference. */ > const char *reference_name = undef_map ? undef_map->l_name : ""; The current code looks like this: if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK) && !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED)) { /* We could find no value for a strong reference. */ const char *reference_name = undef_map ? undef_map->l_name : ""; const char *versionstr = version ? ", version " : ""; const char *versionname = (version && version->name ? version->name : ""); struct dl_exception exception; /* XXX We cannot translate the message. */ _dl_exception_create_format (&exception, DSO_FILENAME (reference_name), "undefined symbol: %s%s%s", undef_name, versionstr, versionname); _dl_signal_cexception (0, &exception, N_("symbol lookup error")); _dl_exception_free (&exception); } I think in general, we want to signal an exception here, and we can't mask that except in debug mode because it does not result in the right behavior. Do you have a reproducer that shows what you want to fix? Thanks, Florian