Fix objdump --reloc for specific symbol
authorVladislav Khmelevsky <och95@yandex.ru>
Sun, 22 Jan 2023 18:07:36 +0000 (22:07 +0400)
committerAlan Modra <amodra@gmail.com>
Mon, 23 Jan 2023 02:21:10 +0000 (12:51 +1030)
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.

binutils/objdump.c

index ee2f577cc3e979b4dd073016baee8532af705653..9e76684c0718992cdd639b50925db2a6393624b2 100644 (file)
@@ -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