From patchwork Mon Dec 26 12:26:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 36605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp882221wrt; Mon, 26 Dec 2022 04:26:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXt0ZPIQRfqSEnhYXTizggWXqK1yGUhQF/dDXNQTrJ0UYf719gbItHKN669of9Gp/0iAvdAW X-Received: by 2002:a17:907:76cc:b0:842:cd68:4943 with SMTP id kf12-20020a17090776cc00b00842cd684943mr14251126ejc.11.1672057608573; Mon, 26 Dec 2022 04:26:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672057608; cv=none; d=google.com; s=arc-20160816; b=FLya+Z5zxuQbaP1d6BxfAysqztrVH6w8CkGOuOsGKlBEeT6//zDAPAiQVz/mZNVq+E ORwEQFZTWcg9ImX1HBgr80qeouMyjfGDRBdQUL9+wSaoKGeRzkJ2pJqg1CN5LJAgxuxL pyBpoMzUnJjdKi5rAsAg3O2XMCo6DvYoiGKsKBY03DBmDvqPHzYM0ROPOyq0i8QT4Lc/ rn+JdbFKmCg7GBsuN5PWzxUWr2a2gv2itwVmfpk2dC28gJ6on3mkKGTjG0oxvMyta/+6 J2kUjNhOs8WkZrwsBtSkyLifbF97fnjywDFyp+SN6y+duXzf/RmUT/6alWTBc6Bj9FiZ 4afw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=6eKRu5TKgbF+5Tu0AFFF0Y5bzdoDjzGmEogLhVa/QZA=; b=Gq9qqCEwps4daDMV4V9HkvklcF7Yt3Q6b5L+R9FPCPzqT6HMkBdgVo3rzM3sCU6L8p AOoMcbBavQPt2W/S/jXp1XtqsJtTL1QNFUgVyhzAVpHS1GdJXdkYKBHQo/yVkdPjiiC/ bQpAM9N+cl7vkPOXBiQJJfPu1ZQ5OXcyYmH+WfSihZf2EomCE6euSaNG7pKmwturPW7C hDi8Pe2CD03EVIecdi7kyI3XJS+z7riEdMlufbjndkpTqwPMn9F6Q43W91ERQqFshyFJ GrXIiBFkWZ3lRSsxI4u0yqJUbjFHBhUrHJv4HDKCu+pq8qupbd3lphN5G2DtwujHu+g1 2Gxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=uJnPXyvk; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id mp26-20020a1709071b1a00b0083088620f86si8320384ejc.100.2022.12.26.04.26.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 04:26:48 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=uJnPXyvk; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A3333858D35 for ; Mon, 26 Dec 2022 12:26:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A3333858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672057607; bh=6eKRu5TKgbF+5Tu0AFFF0Y5bzdoDjzGmEogLhVa/QZA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uJnPXyvk2Fo8ssJnW+qHNqs5PLtXuVHmn4SroW/bzHgETpgzzBDUMEBrrJLYOdqIb nnWst8LlR85JqEwPYq363SrzIwocBjFym5WmcPKIJrJSbjmD6779HyibPlqCv5Mhtn 2nSy8pDEbVz04uH+b53OhJEHqrCEI0qexiQ3Ud38= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id CAC683858D32 for ; Mon, 26 Dec 2022 12:26:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CAC683858D32 Received: by mail-pg1-x530.google.com with SMTP id s196so7117974pgs.3 for ; Mon, 26 Dec 2022 04:26:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6eKRu5TKgbF+5Tu0AFFF0Y5bzdoDjzGmEogLhVa/QZA=; b=u1OAfu8xL/21pZkNjPn1/5mIlFi9uypUoYnl1S+rcqvM06wKY+SlCCHV8O+gNFm8DV SsjgKpdCkIArPrbWLRanyV7ZPtkW540qr3ydZHo94+fV6TCaw1bsa6fpRzpVGzQ1RvAq G63RmY+yERx9PQ4pmEoUinZnOZBZcN2jSkpXc5sIYpowfGew228UvYCj+S0NfqFbt8mM t5M5iKhHwerVhFOMTuFnz43/Zd6Xc2znx5DqSc9tYJN7sGklC5aXVT1XooIU4KOPItOo J5PmZPGZVpz/u9K3jBRkCiPdMP0Lz+WudlzA9oUPPQ+qfmYR7RG0+sIs2ar3i9lUwZxi +PMw== X-Gm-Message-State: AFqh2kpz1wbsbmz6vg7YIF5DDlTUROnDk+WZco/MonJdZXaj0v5xAE7x lKQnEV0DYPCu20i06bnld/lfsoqGQJ8= X-Received: by 2002:a62:7bcd:0:b0:581:1c64:92bc with SMTP id w196-20020a627bcd000000b005811c6492bcmr3760962pfc.3.1672057598688; Mon, 26 Dec 2022 04:26:38 -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 x29-20020aa79add000000b00580fb018e4bsm2889247pfp.211.2022.12.26.04.26.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 04:26:38 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 2D2301142D1A; Mon, 26 Dec 2022 22:56:36 +1030 (ACDT) Date: Mon, 26 Dec 2022 22:56:36 +1030 To: binutils@sourceware.org Subject: bfd/dwarf2.c: allow use of DWARF5 directory entry 0 Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753279478679082941?= X-GMAIL-MSGID: =?utf-8?q?1753279478679082941?= I think the test for table->files[file].dir being non-zero is wrong for DWARF5 where index zero is allowed and is the current directory of the compilation. Most times this will be covered by the use of table->comp_dir (from DW_AT_comp_dir) in concat_filename but the point of putting the current dir in .debug_line was so the section could stand alone without .debug_info. Also, there is no need to check for table->dirs non-NULL, the table->num_dirs test is sufficient. * dwarf2.c (concat_filename): Correct and simplify tests of directory index. diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 88335cb4fb0..a207665bbfa 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -2044,19 +2044,16 @@ concat_filename (struct line_info_table *table, unsigned int file) char *subdir_name = NULL; char *name; size_t len; - - if (table->files[file].dir - /* PR 17512: file: 0317e960. */ - && table->files[file].dir - <= (table->use_dir_and_file_0 ? table->num_dirs - 1 : table->num_dirs) - /* PR 17512: file: 7f3d2e4b. */ - && table->dirs != NULL) - { - if (table->use_dir_and_file_0) - subdir_name = table->dirs[table->files[file].dir]; - else - subdir_name = table->dirs[table->files[file].dir - 1]; - } + unsigned int dir = table->files[file].dir; + + if (!table->use_dir_and_file_0) + --dir; + /* Wrapping from 0 to -1u above gives the intended result with + the test below of leaving subdir_name NULL for pre-DWARF5 dir + of 0. */ + /* PR 17512: file: 0317e960, file: 7f3d2e4b. */ + if (dir < table->num_dirs) + subdir_name = table->dirs[dir]; if (!subdir_name || !IS_ABSOLUTE_PATH (subdir_name)) dir_name = table->comp_dir;