All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Namhyung Kim" <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 5/5] perf symbol: Ensure dso__set_is_64_bit() for libbfd
Date: Sun, 18 Oct 2026 16:44:26 +0000	[thread overview]
Message-ID: <sashiko-outbox-176289@kernel.org> (raw)
In-Reply-To: <20261018163741.850434-5-namhyung@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf symbol: bfd_get_arch_size() always returns -1 in dso__load_bfd_symbols()
--

commit 6d3220ac244766831d73c524c0b8f5184af28a7b
Author: Namhyung Kim <namhyung@kernel.org>

perf symbol: Ensure dso__set_is_64_bit() for libbfd

This commit calls dso__set_is_64_bit() using bfd_get_arch_size() when
loading symbols via libbfd in dso__load_bfd_symbols().

> diff --git a/tools/perf/util/libbfd.c b/tools/perf/util/libbfd.c
> index a4dcb406c79e9..9cc6216ce3adb 100644
> --- a/tools/perf/util/libbfd.c
> +++ b/tools/perf/util/libbfd.c
> @@ -462,6 +462,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
>  	symbols__fixup_end(dso__symbols(dso), false);
>  	symbols__fixup_duplicate(dso__symbols(dso));
>  	dso__set_adjust_symbols(dso, true);
> +	dso__set_is_64_bit(dso, bfd_get_arch_size(abfd) == 64);

[Severity: Medium]
Will bfd_get_arch_size(abfd) always return -1 here?

Earlier in tools/perf/util/libbfd.c:dso__load_bfd_symbols(), ELF binaries
are rejected before reaching this point:

	if (bfd_get_flavour(abfd) == bfd_target_elf_flavour)
		goto out_close;

In GNU binutils libbfd, bfd_get_arch_size() only checks ELF targets and
returns -1 for any other BFD flavour:

	if (abfd->xvec->flavour == bfd_target_elf_flavour)
		return get_elf_backend_data (abfd)->s->arch_size;
	return -1;

Because abfd is guaranteed to be non-ELF here (such as a 64-bit PE/COFF
binary), bfd_get_arch_size(abfd) == 64 always evaluates to false and
unconditionally sets dso->is_64_bit to false.

Should this use bfd_arch_bits_per_address(abfd) == 64 instead so that the
address size is queried across all BFD flavours?

>  
>  	err = dso__has_symbols(dso);
>  out_free:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261018163741.850434-1-namhyung@kernel.org?part=5

  reply	other threads:[~2026-10-18 16:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-18 16:37 [PATCH v1 1/5] perf test: Fix a memory leak in PE file parsing test Namhyung Kim
2026-10-18 16:37 ` [PATCH v1 2/5] perf test: Make sure maps to have a machine Namhyung Kim
2026-10-18 16:43   ` sashiko-bot
2026-10-18 20:33   ` Ian Rogers
2026-10-19  5:36     ` Namhyung Kim
2026-10-18 16:37 ` [PATCH v1 3/5] perf tools: Remove NULL check for maps__machine() Namhyung Kim
2026-10-18 16:42   ` sashiko-bot
2026-10-18 16:37 ` [PATCH v1 4/5] perf symbol: Check result when reading section headers Namhyung Kim
2026-10-18 16:40   ` sashiko-bot
2026-10-18 16:37 ` [PATCH v1 5/5] perf symbol: Ensure dso__set_is_64_bit() for libbfd Namhyung Kim
2026-10-18 16:44   ` sashiko-bot [this message]
2026-10-19  5:38     ` Namhyung Kim
2026-10-18 16:40 ` [PATCH v1 1/5] perf test: Fix a memory leak in PE file parsing test sashiko-bot

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=sashiko-outbox-176289@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.