From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id E5B343858024 for ; Tue, 18 Jan 2022 00:56:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E5B343858024 Received: by mail-pg1-x529.google.com with SMTP id 8so12358266pgc.10 for ; Mon, 17 Jan 2022 16:56:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=IlDizcP1pyGKtKBYrOaH0vRPNeKj1/Xl5QwwLq8fqVw=; b=M2Xvs1r6Jh58UJvY6Tsz/B0WXcvoxNiFNDR7OxEGZL12egULwCiFhwm/VoZOdJsrg0 WezI8dHI8oE2lHAG2rGCQNvv+AFQM5wYP9JAVGeeBwYJg9BZZWLmvz6crD1AwkUBKAD8 pSWl6XFL3QTAZkMx8G5cqjVcYtsMhBA/3Pm5snZwzVUsexl1YubRarEXxKMtWEB/mZkN X5A7yyGwjXhprBwSf7MRFAfGm/vGZnrx+c1X9BGJZdBxQOVeQVhRk+520KWl+0eijz7U KOV2mv+4xWe0QBca6tS+6PVrulHN/iql8HXd+Nvw3mM5rhivnSDGrAlbhTKhZW5VbqXw vaMQ== X-Gm-Message-State: AOAM533dniqU2ldp9uJxpPUMtzQYyZerLo5MuxPgm+ImNh+GsPOmN+5F xG10dC0nDwOAjyYFYD75XrmZOtG4g1o= X-Google-Smtp-Source: ABdhPJwdtHglgm4WGxFGzgzQA/Ta8pMJ+TXqAxll0/Wk4o5vOfd0g3AuXTKC3dX81s1iS4kiEpubxw== X-Received: by 2002:a63:87c8:: with SMTP id i191mr14520433pge.465.1642467406609; Mon, 17 Jan 2022 16:56:46 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id v8sm449779pju.51.2022.01.17.16.56.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 16:56:45 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 621FA114031C; Tue, 18 Jan 2022 11:26:43 +1030 (ACDT) Date: Tue, 18 Jan 2022 11:26:43 +1030 From: Alan Modra To: binutils@sourceware.org Subject: PR28029, debuginfod tests Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3038.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2022 00:56:49 -0000 binutils/NEWS says of the change in --process-links semantics: If other debug section display options are also enabled (eg --debug-dump=info) then the contents of matching sections in both the main file and the separate debuginfo file *will* be displayed. This is because in most cases the debug section will only be present in one of the files. Implying that debug info is dumped without --process-links. Indeed that appears to be the case for readelf. This does the same for objdump. PR 28029 * objdump.c (dump_bfd): Do not exit early when !is_mainfile && !processlinks, instead just exclude non-debug output. (dump_dwarf): Add is_mainfile parameter and pass to dump_dwarf_section. (dump_dwarf_section): Only display debug sections when !is_mainfile and !process_links. diff --git a/binutils/objdump.c b/binutils/objdump.c index 372b88d2f4c..08a0fe521d8 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -3942,15 +3942,20 @@ get_build_id (void * data) static void dump_dwarf_section (bfd *abfd, asection *section, - void *arg ATTRIBUTE_UNUSED) + void *arg) { const char *name = bfd_section_name (section); const char *match; int i; + bool is_mainfile = *(bool *) arg; if (*name == 0) return; + if (!is_mainfile && !process_links + && (section->flags & SEC_DEBUGGING) == 0) + return; + if (startswith (name, ".gnu.linkonce.wi.")) match = ".debug_info"; else @@ -3986,7 +3991,7 @@ dump_dwarf_section (bfd *abfd, asection *section, /* Dump the dwarf debugging information. */ static void -dump_dwarf (bfd *abfd) +dump_dwarf (bfd *abfd, bool is_mainfile) { /* The byte_get pointer should have been set at the start of dump_bfd(). */ if (byte_get == NULL) @@ -4012,7 +4017,7 @@ dump_dwarf (bfd *abfd) init_dwarf_regnames_by_bfd_arch_and_mach (bfd_get_arch (abfd), bfd_get_mach (abfd)); - bfd_map_over_sections (abfd, dump_dwarf_section, NULL); + bfd_map_over_sections (abfd, dump_dwarf_section, (void *) &is_mainfile); } /* Read ABFD's stabs section STABSECT_NAME, and return a pointer to @@ -5053,23 +5058,23 @@ dump_bfd (bfd *abfd, bool is_mainfile) bfd_map_over_sections (abfd, adjust_addresses, &has_reloc); } - if (! is_mainfile && ! process_links) - return; - - if (! dump_debugging_tags && ! suppress_bfd_header) - printf (_("\n%s: file format %s\n"), - sanitize_string (bfd_get_filename (abfd)), - abfd->xvec->name); - if (dump_ar_hdrs) - print_arelt_descr (stdout, abfd, true, false); - if (dump_file_header) - dump_bfd_header (abfd); - if (dump_private_headers) - dump_bfd_private_header (abfd); - if (dump_private_options != NULL) - dump_target_specific (abfd); - if (! dump_debugging_tags && ! suppress_bfd_header) - putchar ('\n'); + if (is_mainfile || process_links) + { + if (! dump_debugging_tags && ! suppress_bfd_header) + printf (_("\n%s: file format %s\n"), + sanitize_string (bfd_get_filename (abfd)), + abfd->xvec->name); + if (dump_ar_hdrs) + print_arelt_descr (stdout, abfd, true, false); + if (dump_file_header) + dump_bfd_header (abfd); + if (dump_private_headers) + dump_bfd_private_header (abfd); + if (dump_private_options != NULL) + dump_target_specific (abfd); + if (! dump_debugging_tags && ! suppress_bfd_header) + putchar ('\n'); + } if (dump_symtab || dump_reloc_info @@ -5112,39 +5117,46 @@ dump_bfd (bfd *abfd, bool is_mainfile) } } - if (dump_section_headers) - dump_headers (abfd); + if (is_mainfile || process_links) + { + if (dump_section_headers) + dump_headers (abfd); - if (dump_dynamic_symtab || dump_dynamic_reloc_info - || (disassemble && bfd_get_dynamic_symtab_upper_bound (abfd) > 0)) - dynsyms = slurp_dynamic_symtab (abfd); + if (dump_dynamic_symtab || dump_dynamic_reloc_info + || (disassemble && bfd_get_dynamic_symtab_upper_bound (abfd) > 0)) + dynsyms = slurp_dynamic_symtab (abfd); - if (disassemble) - { - synthcount = bfd_get_synthetic_symtab (abfd, symcount, syms, - dynsymcount, dynsyms, &synthsyms); - if (synthcount < 0) - synthcount = 0; - } + if (disassemble) + { + synthcount = bfd_get_synthetic_symtab (abfd, symcount, syms, + dynsymcount, dynsyms, + &synthsyms); + if (synthcount < 0) + synthcount = 0; + } - if (dump_symtab) - dump_symbols (abfd, false); - if (dump_dynamic_symtab) - dump_symbols (abfd, true); + if (dump_symtab) + dump_symbols (abfd, false); + if (dump_dynamic_symtab) + dump_symbols (abfd, true); + } if (dump_dwarf_section_info) - dump_dwarf (abfd); - if (dump_ctf_section_info) - dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name); - if (dump_stab_section_info) - dump_stabs (abfd); - if (dump_reloc_info && ! disassemble) - dump_relocs (abfd); - if (dump_dynamic_reloc_info && ! disassemble) - dump_dynamic_relocs (abfd); - if (dump_section_contents) - dump_data (abfd); - if (disassemble) - disassemble_data (abfd); + dump_dwarf (abfd, is_mainfile); + if (is_mainfile || process_links) + { + if (dump_ctf_section_info) + dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name); + if (dump_stab_section_info) + dump_stabs (abfd); + if (dump_reloc_info && ! disassemble) + dump_relocs (abfd); + if (dump_dynamic_reloc_info && ! disassemble) + dump_dynamic_relocs (abfd); + if (dump_section_contents) + dump_data (abfd); + if (disassemble) + disassemble_data (abfd); + } if (dump_debugging) { @@ -5169,7 +5181,7 @@ dump_bfd (bfd *abfd, bool is_mainfile) else if (! dump_dwarf_section_info) { dwarf_select_sections_all (); - dump_dwarf (abfd); + dump_dwarf (abfd, is_mainfile); } } -- Alan Modra Australia Development Lab, IBM