From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2124) id 6811F3847700; Wed, 3 Apr 2024 10:17:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6811F3847700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712139450; bh=4tOFru9J4n4yXCdsjKFk9cbCnGOiKxImW1ZP64T8z8s=; h=From:To:Subject:Date:From; b=FHA+lV5Wzmn/m/uf9bmnm0VTc36y44WDX4fOEBLxRtywz+Y993NK3sWAmWRlsR1+M KyfEKk5xI1K75mckLGq7kFxeHnIpESJ+0lnvKqc8psG8t2++Id5v187tRe487MZtAb aNFw2ylzl2dQ1NjGNV0x0oTm3CBSIqawVJBua9tY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Clifton To: binutils-cvs@sourceware.org Subject: [binutils-gdb] Extend objdump's --show-all-symbols option so that it also shows the extra symbols referenced by an X-Act-Checkin: binutils-gdb X-Git-Author: Nick Clifton X-Git-Refname: refs/heads/master X-Git-Oldrev: b1c4af2086db25da1acf546b28df5b6fe8198cd6 X-Git-Newrev: 28b24770bb7b8dc0c79121bdaa64303d17693669 Message-Id: <20240403101730.6811F3847700@sourceware.org> Date: Wed, 3 Apr 2024 10:17:30 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D28b24770bb7b= 8dc0c79121bdaa64303d17693669 commit 28b24770bb7b8dc0c79121bdaa64303d17693669 Author: Nick Clifton Date: Wed Apr 3 11:16:23 2024 +0100 Extend objdump's --show-all-symbols option so that it also shows the ex= tra symbols referenced by an instruction. Diff: --- binutils/objdump.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/binutils/objdump.c b/binutils/objdump.c index 68da543e905..6396174d50f 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -1652,6 +1652,42 @@ objdump_print_addr_with_sym (bfd *abfd, asection *se= c, asymbol *sym, (long int)(sec->filepos + (vma - sec->vma))); } =20 +/* Displays all symbols in the sorted symbol table starting at PLACE + which match the address VMA. Assumes that show_all_symbols =3D=3D true= . */ + +static void +display_extra_syms (long place, + bfd_vma vma, + struct disassemble_info *inf) +{ + struct objdump_disasm_info *aux =3D (struct objdump_disasm_info *) inf->= application_data; + + if (place =3D=3D 0) + return; + + bool first =3D true; + + for (; place < sorted_symcount; place++) + { + asymbol *sym =3D sorted_syms[place]; + =20 + if (bfd_asymbol_value (sym) !=3D vma) + break; + + if (! inf->symbol_is_valid (sym, inf)) + continue; + + if (first && ! do_wide) + inf->fprintf_styled_func (inf->stream, dis_style_immediate, ",\n\t<"); + else =20 + inf->fprintf_styled_func (inf->stream, dis_style_immediate, ", <"); + + objdump_print_symname (aux->abfd, inf, sym); + inf->fprintf_styled_func (inf->stream, dis_style_immediate, ">"); + first =3D false; + } +} + =20 /* Print an address (VMA), symbolically if possible. If SKIP_ZEROES is TRUE, don't output leading zeroes. */ =20 @@ -1663,6 +1699,7 @@ objdump_print_addr (bfd_vma vma, struct objdump_disasm_info *aux; asymbol *sym =3D NULL; bool skip_find =3D false; + long place =3D 0; =20 aux =3D (struct objdump_disasm_info *) inf->application_data; =20 @@ -1696,10 +1733,34 @@ objdump_print_addr (bfd_vma vma, } =20 if (!skip_find) - sym =3D find_symbol_for_address (vma, inf, NULL); + sym =3D find_symbol_for_address (vma, inf, &place); =20 objdump_print_addr_with_sym (aux->abfd, inf->section, sym, vma, inf, skip_zeroes); + + /* If requested, display any extra symbols at this address. */ + if (sym =3D=3D NULL || ! show_all_symbols) + return; + + if (place) + display_extra_syms (place + 1, vma, inf); + =20 + /* If we found an absolute symbol in the reloc (ie: "*ABS*+0x....") + and there is a valid symbol at the address contained in the absolute = symbol + then display any extra symbols that match this address. This helps + particularly with relocations for PLT entries. */ + if (startswith (sym->name, BFD_ABS_SECTION_NAME "+")) + { + bfd_vma addr =3D strtoul (sym->name + strlen (BFD_ABS_SECTION_NAME "= +"), NULL, 0); + + if (addr && addr !=3D vma) + { + sym =3D find_symbol_for_address (addr, inf, &place); + + if (sym) + display_extra_syms (place, addr, inf); + } + } } =20 /* Print VMA to INFO. This function is passed to the disassembler