[binutils-gdb] Fix objdump --reloc for specific symbol

Alan Modra amodra@sourceware.org
Mon Jan 23 02:39:55 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7e538762c2c1f2e5c4be31b9ec7d99cc4fbabf7f

commit 7e538762c2c1f2e5c4be31b9ec7d99cc4fbabf7f
Author: Vladislav Khmelevsky <och95@yandex.ru>
Date:   Sun Jan 22 22:07:36 2023 +0400

    Fix objdump --reloc for specific symbol
    
    If objdump is used with both --disassemble=symbol and --reloc options
    skip relocations that have addresses before the symbol, so that they
    are not displayed.

Diff:
---
 binutils/objdump.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/binutils/objdump.c b/binutils/objdump.c
index ee2f577cc3e..9e76684c071 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -3910,6 +3910,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


More information about the Binutils-cvs mailing list