From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 789F93858D35 for ; Wed, 29 Sep 2021 02:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 789F93858D35 Received: by mail-pg1-x531.google.com with SMTP id 66so733750pgc.9 for ; Tue, 28 Sep 2021 19:37:15 -0700 (PDT) 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=rd49JIGSddDqQbWfJ6Y+wbXYDBfwES/llFsi3MmgugA=; b=wrSFK/gEOPLlplEmEY6/FmY93VCmZj0spuf9mAH0l4V48XSwDga3kJRN3Sxz7szVFi uhBPs3oSp5S+W8M3vHbKLjINHELDq7DZam720zPSiKT8pFgntF1th16PuxR86ldcjZIy 4Zv9KIB9ZMvPuCORmI0V011mUeNLEHVvXsykZVocakhq9nlkdcUXlqFMTw7Y3HLl+rjg P8IhuwvzhVsCWS4DNnwtb9UNIvcoUoGwpcAb3XckwBgUITfu3x8hwa/P/9v5h4ExCWFj BRIQXUWPcCtVcZMOOoTVCS/GGow5RF7oAGuytqIkDZnTGSu0sv1JVbLosJZ1w4Me9KwX 6LrA== X-Gm-Message-State: AOAM533mJk5V7Znh1YL/7Bgi6bA1n3corHK3BFodV6HopGPYR52zDLuo /2+JHFJC5KKFjUNwtXtFWP3BtcDAC9M= X-Google-Smtp-Source: ABdhPJxbV1xtvTLBwTFALcnDJykO/DNctlMwYhjBZytDWrXogeYa3xv8MoUhgbG/J/sT/NLOrvRRSA== X-Received: by 2002:aa7:9f03:0:b0:447:dd09:6dda with SMTP id g3-20020aa79f03000000b00447dd096ddamr8418535pfr.36.1632883034168; Tue, 28 Sep 2021 19:37:14 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:7624:8ad2:56f0:70e2]) by smtp.gmail.com with ESMTPSA id q18sm436255pfj.46.2021.09.28.19.37.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 19:37:13 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id BA0C7114005C; Wed, 29 Sep 2021 12:07:10 +0930 (ACST) Date: Wed, 29 Sep 2021 12:07:10 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR27202, readelf -wL doesn't work on ".loc 0" Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3038.0 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: Wed, 29 Sep 2021 02:37:16 -0000 For DWARF revision 4 and earlier, display_debug_lines_decoded populates the file_table array with entries read from .debug_line after the directory table. file_table[0] contains the first entry. DWARF rev 4 line number programs index this entry as file number one. DWARF revision 5 changes .debug_line format quite extensively, and in particular gives file number zero a meaning. PR 27202 * dwarf.c (display_debug_lines_decoded): Correct indexing used for DWARF5 files. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 213b5d17877..6e10281a6ed 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -5297,15 +5297,17 @@ display_debug_lines_decoded (struct dwarf_section * section, state_machine_regs.file = uladv; { - unsigned file = state_machine_regs.file - 1; + unsigned file = state_machine_regs.file; unsigned dir; + if (linfo.li_version < 5) + --file; if (file_table == NULL || n_files == 0) printf (_("\n [Use file table entry %d]\n"), file); /* PR 20439 */ else if (file >= n_files) { - warn (_("file index %u > number of files %u\n"), file + 1, n_files); + warn (_("file index %u > number of files %u\n"), file, n_files); printf (_("\n "), file); } else if ((dir = file_table[file].directory_index) == 0) @@ -5414,7 +5416,10 @@ display_debug_lines_decoded (struct dwarf_section * section, if (file_table) { - unsigned indx = state_machine_regs.file - 1; + unsigned indx = state_machine_regs.file; + + if (linfo.li_version < 5) + --indx; /* PR 20439 */ if (indx >= n_files) { -- Alan Modra Australia Development Lab, IBM