From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2078.outbound.protection.outlook.com [40.107.243.78]) by sourceware.org (Postfix) with ESMTPS id 175CC39AC853 for ; Thu, 28 Jan 2021 15:54:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 175CC39AC853 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aWUnL8vyh8P9XcoYDLMRihyhjYetC3tekjuiAF82KbYJkJoQ4NNdd0vt6HlaTMLmlpBRWe0K5z5gF7PCaV6axp9bBigq+fK4bHdw2uiHzOEGiqzQ6RtE+lqRBHJee62oLNhPpPTiZ0bZODnjcgW0ZyeeGftLQiNaRvWeLDdJkpRn4jrAtpJvsLzFML9tmMnnOyHvTBEbaRHx3JPVbUg7hRTEOAq1Cz98Gla662aD/Fhd6dOFe5BqxbrSk/JCbdGXV9N51P7VPBYdY6dWABOuSeglh/WuL4BgFNHUDc4sj1k+nwpA0T6+S8FymqgY5GXZo1NuZFRO08kqrpO+qB7tjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0Idv22hgH1OOaQXXRRWITzMuRUIK/Q088bYmSkrMJtg=; b=c5lKmHXUpYoUI+jv0rUiRZ/6Zd2Z+1G2my5usyvhLKp0idy0i0Bu6VmOiGwTp7kqVAdGSdUpM5gajzoHR52E84kRGvMcAMq3CPqWSCwRvg/uOs+nnZM//Hr8gmv46Mw1md9tya9GO0TqQSU/UVsdGsbhOe8mY5cUV1jWIi4U6m+vFq9l8ReP56iS2l5TlUMrlhbohtS2Uu2thb0Z2eEd8RbFN65AMOiJf74LqVyO1poMmd3qdgFfc1w7UuYiVeBGS8CN/2xZzri44cS5BjhtHiwRKj1S8J0PhQvY93Z+zBL19/pFAPHKdi5gzaOu/wdVELYUqu377CHtkn6HVx/uYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none Received: from DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) by DM6PR12MB4283.namprd12.prod.outlook.com (2603:10b6:5:211::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16; Thu, 28 Jan 2021 15:54:34 +0000 Received: from DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44]) by DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44%3]) with mapi id 15.20.3763.019; Thu, 28 Jan 2021 15:54:33 +0000 Subject: Re: [PATCH 06/13] gdb/dwarf: read correct rnglist/loclist header in read_{rng,loc}list_index To: Simon Marchi , gdb-patches@sourceware.org Cc: Simon Marchi References: <20210120053925.142862-1-simon.marchi@polymtl.ca> <20210120053925.142862-7-simon.marchi@polymtl.ca> <17a5bb39-2268-67ce-f75c-fce75188975b@amd.com> From: Zoran Zaric Message-ID: Date: Thu, 28 Jan 2021 15:54:28 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [2a00:23c7:5a85:6801:cf:c92a:a445:6f68] X-ClientProxiedBy: AM3PR05CA0146.eurprd05.prod.outlook.com (2603:10a6:207:3::24) To DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2a00:23c7:5a85:6801:cf:c92a:a445:6f68] (2a00:23c7:5a85:6801:cf:c92a:a445:6f68) by AM3PR05CA0146.eurprd05.prod.outlook.com (2603:10a6:207:3::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16 via Frontend Transport; Thu, 28 Jan 2021 15:54:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0fea8667-5b5b-4211-0e73-08d8c3a5019f X-MS-TrafficTypeDiagnostic: DM6PR12MB4283: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UZroHzVYaGnzkSmilehcXwR/MJJW/dtVCW33D55JBdS+wuuJAn9s7bD9tHpwmuykjVFZjIQnUCEYvyQbyMCHDO8OqsIfGt8CZoXrVBZo7UReWsDNoXn6hjrSjujkSQUdJRWii2mMutpBV1/GjpzbPNzs/viRlcKoShNBFMkoHgkvahRNsO4M9kwfuZwBPXEeP29yW+tpbvOmlMC22v9f6DrdhqcnMo6w5bVilYpIge5Yqqgy9Xwnj/bCVe9zARrAnucqiQ/GT+9DYvIoSizrpGXlOBsKYnYeb7W+3LrPQdq0w+bqq2B2vo/tA/Areue195I7zQtN06HVRJcpaUuUAWeZNpIVGaApWI6NHLYLhj9X0AmvjgQy9Jy1BgA8N2uvWdlVkgM8ldDIU9FMEkfxFsnca7O9AUpJsnI6Kom9Yqjavl6itl3AKynC7XaI+BpJBjfZOY7oE4eT4C9Uywv5Y6Gej4byhT1na+j7AsbeDbdTtFfqdbIaeoLvV8SgasPzgY4qGziMiRRwMXiXm7FH1JMCqXFZneImR1Wsvx3KFVu4/Mj9t94TMYg1fBhCkeGqG0in+16dr+7zRd7dADBR05tHoL3N1HFP/Nw9mxfj0rA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB2762.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(376002)(39860400002)(396003)(346002)(8676002)(36756003)(316002)(4326008)(6486002)(186003)(52116002)(2906002)(16526019)(2616005)(6666004)(8936002)(5660300002)(86362001)(478600001)(66476007)(66556008)(66946007)(83380400001)(31696002)(31686004)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?WHlyV2dHZmZCL0luS3NJQjJSdTVtbTZ6MDgrbW8xaUV1aWluc3kwMGF1WFFG?= =?utf-8?B?UHQ1aHNvOSs5THJtV3QvNThjdzhINFVDelpWdU1VbnZyWmxkTmQ1RTZRTkg4?= =?utf-8?B?VUp0SFFLOWlSSnNOQWlTcHNxUnl0MHRsUXY5aUhLcXJLVVBWZUxXTFVtakQ0?= =?utf-8?B?c3hQOCtPRC9keHlVRVNUcm9keFJXc2RzOUpWajZ0OWZyUGgwTkZNQlBKSzBa?= =?utf-8?B?NzRZNUhpYU4waVFZckdtY2paWW9UVElmS3BYRnVvUzQ5UkJwUnEwV1lmWnM5?= =?utf-8?B?Z3dPMENsSDlWQTJDbDdJRW50TEREaGtlVFJhZFV6TG9MeC8vaXlCUEprNGFz?= =?utf-8?B?c3R1R1RoeEFGN2VzWUdySEJjeDJxUHc1TUpVOE1rUFdaRUJldU5NZmhtNXF1?= =?utf-8?B?WEJzSlRtSkdwRm1Obld5UU5vWkdzb25MTnlsWldIL1R0dlpFb2Jqb0dCZVQ1?= =?utf-8?B?WmpQT2hiYUdzTjhzTzFJZHBQU3NxeVIveVUxZE41bEZ0WHRKWkJ6bWt1RzVy?= =?utf-8?B?b3ZSRmVJUWNrUXZXWHZxUlFOaUdWalBoNFlYeHJUd2Q4WWxKanRSNnMyQnhv?= =?utf-8?B?LzdrVUo3eFBYMUl4YnZ2RUcvZkt4NU9ycGJHQmdlbHR6ODVLVVZpbGhKZnVs?= =?utf-8?B?VmJpZ05EbkVnVmxvdkhUTTlrQUlycXpuOTh5akprekZCZmNwWU9VWjN4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change-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2021 15:54:33.8525 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: U5LiLduAqG6P5pgjkQMuzX1GKSWQiOzasVsHYVnwkLrU3EsLLmZjTYc1ZdsHvwg6buzF2wzLQh4VKNFQSz1Vzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4283 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2021 15:54:36 -0000 > On 2021-01-28 10:39 a.m., Zoran Zaric wrote:>> From: Simon Marchi >>> >>> When loading the binary from PR 26813 in GDB, we get: >>> >>> DW_FORM_rnglistx index pointing outside of .debug_rnglists offset array [in module /home/simark/build/binutils-gdb/gdb/MagicPurse] >>> >>> ... and the symbols fail to load. >>> >>> In read_rnglist_index and read_loclist_index, we read the header >>> (documented in sections 7.28 and 7.29 of DWARF 5) of the CU's >>> contribution to the .debug_rnglists / .debug_loclists sections to >>> validate that the index we want to read makes sense. However, we always >>> read the header at the beginning of the section, rather than the header >>> for the contribution from which we want to read the index. >>> >>> To illustrate, here's what the binary from PR 26813 contains. There are >>> two compile units: >>> >>> 0x0000000c: DW_TAG_compile_unit 1 >>> DW_AT_ranges [DW_FORM_rnglistx]: 0x0 >>> DW_AT_rnglists_base [DW_FORM_sec_offset]: 0xC >>> >>> 0x00003ec9: DW_TAG_compile_unit 2 >>> DW_AT_ranges [DW_FORM_rnglistx]: 0xB >>> DW_AT_rnglists_base [DW_FORM_sec_offset]: 0x85 >>> >>> The layout of the .debug_rnglists is the following: >>> >>> [0x00, 0x0B]: header for CU 1's contribution >>> [0x0C, 0x0F]: list of offsets for CU 1 (1 element) >>> [0x10, 0x78]: range lists data for CU 1 >>> >>> [0x79, 0x84]: header for CU 2's contribution >>> [0x85, 0xB4]: list of offsets for CU 2 (12 elements) >>> [0xB5, 0xBD7]: range lists data for CU 2 >>> >>> The DW_AT_rnglists_base attrbute points to the beginning of the list of >>> offsets for that CU, relative to the start of the .debug_rnglists >>> section. That's right after the header for that contribution. >>> >>> When we try to read the DW_AT_ranges attribute for CU 2, >>> read_rnglist_index reads the header for CU 1 instead of the one for CU >>> 2. Since there's only one element in CU 1's offset list, it believes >>> (wrongfully) that the index 0xB is out of range. >>> >>> Fix it by reading the header just before where DW_AT_rnglists_base >>> points to. With this patch, I am able to load GDB built with clang-11 >>> and -gdwarf-5 in itself, with and without -readnow. >>> >> >> I came to the same conclusion, the issue was probably never noticed because the tested compilers only ever generated one rangelist entry. >> >> Even LLVM didn't seem to generate it before version 11, or at least I haven't noticed the issue when I was previously testing the DWARF 5 support. > > Indeed, and I think it was only used on the compilation unit's DIE? I think you are right. >>> Change-Id: Ie53ff8251af8c1556f0a83a31aa8572044b79e3d >>> >> >> Are these Gerrit change ID's? They shouldn't be part of the patches right? >> >> Zoran > > I do use Gerrit personally to track the patches I work on, their > versions, which ones have been merged and which ones haven't. When I > push the patches upstream and then sync my Gerrit instance's master > branch, it automatically sees which patches have been merged in the > master branch and closes the corresponding reviews. So keeping the > Gerrit Change-Id really helps me, and I don't think it bothers anyone, > so I leave them there. > > Simon > Makes sense. I didn't notice change ID's on some other reviews so I wasn't sure what is the policy about those. Zoran