public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Lv Ying <lvying.system.thoughts@gmail.com>
Cc: libc-alpha@sourceware.org,  lvying6@huawei.com
Subject: Re: [RFC] elf: fine-grained output LD_DEBUG log when symbol lookup error
Date: Mon, 08 Aug 2022 15:19:16 +0200	[thread overview]
Message-ID: <875yj2ootn.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20220807120003.313131-1-lvying.system.thoughts@gmail.com> (Lv Ying's message of "Sun, 7 Aug 2022 05:00:03 -0700")

* 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


  reply	other threads:[~2022-08-08 13:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-07 12:00 Lv Ying
2022-08-08 13:19 ` Florian Weimer [this message]
2022-08-17  3:51   ` Lv Ying
2022-08-17  5:56     ` Florian Weimer
2022-08-19 16:23       ` Lv Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yj2ootn.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=lvying.system.thoughts@gmail.com \
    --cc=lvying6@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).