From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x530.google.com with SMTP id s196so7117974pgs.3 for ; Mon, 26 Dec 2022 04:26:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=6eKRu5TKgbF+5Tu0AFFF0Y5bzdoDjzGmEogLhVa/QZA=; b=aPoTSvy7QitewmdaW2cOoFHTb/IQXNBux/8HrknjgkrE070HhKj0nrJ8JwGEoc3OVr ACe6XvoLH+bjHGKtCR5HnFHsWxxFvhqWPcsoPrMz5K4nI5pY026oNYGqZxhjMk8hgFKv 0OdINQ9s/L20yh1ojhegRYKMPTnTyn7pOtKa/B8wRyvk1BVXriFOxG7w7iAFYgEj0NHY kmxBNnaoLVcuSeLKSxTfhJb7w04fWxEHaUVf/HS5/A6+fYtz49d48OWHf7Fk90EhFV7r zY/+TCOnjhZxPoHzk449ewn6oLcCC/EuTaP0K1sz35SJFuneLhe8QwVnN6LBm7Bn+FQU c/iQ== 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-Google-Smtp-Source: AMrXdXv9dSW1ZjLk9T6XB7xa2H1czazkvDX0t/aRQO0nI0s+wtNM5yGQ6qfkvFJTPqg4IvqMi0Alfg== 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 From: Alan Modra To: binutils@sourceware.org Subject: bfd/dwarf2.c: allow use of DWARF5 directory entry 0 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 List-Id: 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; -- Alan Modra Australia Development Lab, IBM