public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Vladislav Khmelevsky <och95@yandex.ru>
To: binutils@sourceware.org
Cc: Vladislav Khmelevsky <och95@yandex.ru>
Subject: [PATCH] objdump: Fix relocations objdumping for specific symbol
Date: Sun, 22 Jan 2023 22:07:36 +0400	[thread overview]
Message-ID: <20230122180736.55917-1-och95@yandex.ru> (raw)

If objdump is used with both --disassemble=symbol and --reloc options
skip relocations that are belonging to the addresses below the symbol address.
---
 binutils/objdump.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/binutils/objdump.c b/binutils/objdump.c
index 61a18746fde..155461fc3cd 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -3909,6 +3909,13 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
 		{
 		  do_print = true;
 
+		  /* Skip over the relocs belonging to addresses below the
+		     symbol address.  */
+		  const bfd_vma sym_offset = bfd_asymbol_value (sym) - section->vma;
+		  while (rel_pp < rel_ppend &&
+		   (*rel_pp)->address - rel_offset < sym_offset)
+			  ++rel_pp;
+
 		  if (sym->flags & BSF_FUNCTION)
 		    {
 		      if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
-- 
2.25.1


             reply	other threads:[~2023-01-22 18:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-22 18:07 Vladislav Khmelevsky [this message]
2023-01-23  2:40 ` Alan Modra

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=20230122180736.55917-1-och95@yandex.ru \
    --to=och95@yandex.ru \
    --cc=binutils@sourceware.org \
    /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).