From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yT1uH6jaEmDqdAAAWB0awg (envelope-from ) for ; Thu, 28 Jan 2021 10:39:20 -0500 Received: by simark.ca (Postfix, from userid 112) id 6195F1EF80; Thu, 28 Jan 2021 10:39:20 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0177E1E945 for ; Thu, 28 Jan 2021 10:39:19 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 878793850415; Thu, 28 Jan 2021 15:39:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 878793850415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611848359; bh=BXwdyFtn7DyCvJDbglStzCqCQ6C8vIFw0pr33fnYtRo=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=b3XYP/KCjz5YWNjVNK/XBt5KslU4e560vU+Bz0AxqOdDknDRAr3ylsAscXy4pI4gm j2o0pA4aUOmtcB4BOYARGjAXCXGC2jkvS3+JjV5K3e56t2CWq/tCtBmLTflSZoEY0J EtUQqrpSx/fg/pEeVSZuSk46SCy5wbGYI9gZR5IU= Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) by sourceware.org (Postfix) with ESMTPS id BF9F83850415 for ; Thu, 28 Jan 2021 15:39:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BF9F83850415 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cWQSr0aZhUQ01GwF3S3rPNBfapL1wN2Qn8cGmU14lcQuhSWPLedYBpqxoZArJoajgPBMsXu462/44niTs0IorQ+lWehE/X+w9aFOBqvtn/KN0WNehmW4nwFYTu+74jX1Qf7H//cQ5CNLF6FzaQ+BtMNRQj549T1XihCy/pIq/lQ8gOXKM1zQ9OZyaYNRV6NkSxbRexChaTSBHzeO/fqB0pWIA8IwAQt7qUliHG9BPf1W6YOOh9wjD6Om/HhrVEYPkEWfEwdess5ezWsEh0FhL+QgjKfME4+op2TDHRqNKipSVZqn6ymoFoyftN2Hykdw0mL7vu0By4P1UStdh3oCWA== 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=BXwdyFtn7DyCvJDbglStzCqCQ6C8vIFw0pr33fnYtRo=; b=iUXmhfIxMlKSp2Hl0OaQWUNW04LYXYDJbywsSWsdbzKSDcxrjwcivcA7id7TiK38t8xUJWOtkgUiOozZdXCFtB+08V1c8TysxxmZdCxvhUi/sTSj7paxcYcLgF306y4abLUPQsbTPpiY10uHr5MqvuXHM5HedCZlqNpNvyt2FX4SHH/Ox0zBpFgZOuDF4E6K0/ao1S27JKimE2ktNOUtrY59Hl0LWicar1+zF2vIUwgEzuFGMcVi3ubgx9k56WFT+VdOj2hFvQ+BFjRyQ8wv5LhVa3fY0mKr6n+i+F3i11lMziGs6duVlF3VDsu3F8SvgK48GYyRkJdYfhXyKlKUag== 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 DM5PR12MB1530.namprd12.prod.outlook.com (2603:10b6:4:4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.13; Thu, 28 Jan 2021 15:39:15 +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:39:15 +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 References: <20210120053925.142862-1-simon.marchi@polymtl.ca> <20210120053925.142862-7-simon.marchi@polymtl.ca> Message-ID: <17a5bb39-2268-67ce-f75c-fce75188975b@amd.com> Date: Thu, 28 Jan 2021 15:39:09 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 In-Reply-To: <20210120053925.142862-7-simon.marchi@polymtl.ca> 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: AM4PR0701CA0028.eurprd07.prod.outlook.com (2603:10a6:200:42::38) 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 AM4PR0701CA0028.eurprd07.prod.outlook.com (2603:10a6:200:42::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.7 via Frontend Transport; Thu, 28 Jan 2021 15:39:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c47dd526-d779-4c3d-edff-08d8c3a2ddf5 X-MS-TrafficTypeDiagnostic: DM5PR12MB1530: 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: uZgyow8+JY8OhUrEE4uQnWz7BIgrxQ+hWyO4E2wPUC16CE5gIKFNDsl7fot8TgLTbYsCgwuJq/xj3ampC+aH57yvb7zJmPPnBXYhBevF9h7VIvs0P9mPMCanHvNXzhtw87UuVMSIabHZGScVNVqJpG2nLlumkisqbTX1jkTUR+haNcSra4bjQ2FNHznIk9PuvduImM3Urh8jCrWo00T8X6ev0riL/1RfyVR6ZSNbJC/8J9o+mDmxAoRoTp7ZXFNiJSZmKCn5StsHuObhJNr7mmiFXhiOmXKWNO4vqOud1uERR1US9v4MlgAtXFtQ6IkbQyW6heZgGzYffpYDM3QDthmTInpwYX/Qc3gQYlh6FaUkgiOJ4mEHqeIUpOpQH2bODH/8RjAUYTcYtFEizDy2bxL1BH3fdDNvYeiwKzlt6+Zh4FPzNymn8n8YtU+n4CvyqX3JBohjI1a/AITwXF+nXXfkNBtFO1mkf+MeO1Qi6wAkuS7qIsgZXTZRUMC7F4Kl/68YREYEREBaRT93uuHA342pYkvE6+zIAvryvPNSBX83ZuVf/ApEuvu//WB/xFLciq1nUy5nzYt32r9brS/Fmupc2uop5juug58rdou7D7s= 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)(346002)(396003)(376002)(39860400002)(136003)(366004)(2906002)(66556008)(2616005)(31696002)(316002)(6666004)(478600001)(4326008)(83380400001)(31686004)(52116002)(66946007)(66476007)(6486002)(8936002)(186003)(86362001)(16526019)(5660300002)(36756003)(8676002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?ZGQ4UFdRK1lqRmcxa2wzbDZDYlYzWE94REFUV044VVlPbWZheGRNSjNpMWw2?= =?utf-8?B?RWlhSzdKR0hhNFJod3F3amlkMHlsc21pVjJUNEhORmIrWWY5RWhkamJrNVRv?= =?utf-8?B?RE9RZHlidW8raFptU0FIZ2EzUWlEMWk2dGI5b1pobkVwV0NNLzNzM2NYMTky?= =?utf-8?B?cFNtMENRcGVyVzB6WWI3Z2NURmJnS0laNDJlYU51VitSTVdZRi9ZcUlBQmZT?= =?utf-8?B?MkhnTmJzaC9lbVNKekxyeFhMQVZNRlROdDcwcjdvSTlrbWxsMzAyVTZRMWcv?= =?utf-8?B?Z2lLZVlmVHVrRStUSVFzL2NjYkZ2amtmTm9Hd1JHVnJHaG5sVkV4VVNRd2hN?= =?utf-8?B?Vjh3Tk1WT0twKy9KZjh3YWZ5WXdRRitIKzkva2pRb1VmUU4rWkZhcmJiM1J0?= =?utf-8?B?TVVXbVVnWTNZSDFmTWY2dnpkaHlUS0ppRzFXaVBCdVExZ2xTWCszNkFTVTZ3?= =?utf-8?B?clRYTVRobENoQUMyRW9BUUpsT0ZFbTBXWERBQi92YnluSGc1dXBWZTZhcDRX?= =?utf-8?B?TVk2SDdJcS9hbkdTR1hUdGhWYy8vNWFjWnpWdDN5OWwxaU5xVXJEaWJDaGZp?= =?utf-8?B?VFFBNGNTeEZFUGpXNUlTUVptbFAxcko4ZkNZRXpQSlowMlQrNXhsNkFMUXlN?= =?utf-8?B?MlpCcHV1RmhqbDc1TmZrOU5vOUw3RjhsUkJkb2pMY3cvY09sWDg2NGU4VGFp?= =?utf-8?B?KzFUdDBpc0dtY0IzaVFLekw2cFU5TWRmcE9VR1IyZzF5K2luM2x4Nis4cUp3?= =?utf-8?B?WXFER3A5NTcyci9aOTlNWDk2czU4VWtFa2hXY2lHbmxtNnR1VCtwTjBIQjIr?= =?utf-8?B?RktBVkp4VFBQeG5ZSWtNK1l3alFPcXNxVHpNU0NJSDFCeTVsbCszdklYK004?= =?utf-8?B?ZDRZQjVJcXVyV2V3VHdIZmpXRmovREJjb2haaHJCUXZwUXV0ajdDcXA3a09U?= =?utf-8?B?SVFTbXYvQitZajJyL0JlOVhMS3R5NU9rTGNWcjdBS2czOGFJTlV3MzFROFds?= =?utf-8?B?aXNTUmNyMGxtNFZ1czQ2eFhMMEVRRmUyNU9WMFh0dXNvRy83M1BzTmVlNkZh?= =?utf-8?B?NlRyeDRnRG5jTUZ4N3pZZmdEWktsRjJhajBjTTJ0WTduVE44ZEdoa0NrRWNG?= =?utf-8?B?RExiZ0ZjdTNqaStBQmVlTzUzWDhiRTFkZHdkNGdBU1dvaS9YQmJUN0diMVhZ?= =?utf-8?B?TWcyMmJnOVpnUFE0cVFERWk1YTdGaEdZaE53akVQRTZVMVdLSUozbkRialVF?= =?utf-8?B?SDZyc2ovUVVRVk9veHcya2p1OFZWVHVEdVVyMmJnU3VBVlRPKzFEdHFGRVph?= =?utf-8?B?VnBNTUZjamVWeFVsTDFObm00VTJuek9obEMxQ2tQMUFsekN0RVRYZTlZRC9U?= =?utf-8?B?TU80TXVvSU9xd0NFYXFEZDE0UkRkY2VEcEI2aHhuaVEyckUwalRseTNvMzh0?= =?utf-8?B?d1laSGpGdHF2MmowTWg5WjhrSjBrdHkrdHpGVHZwWXFuTnpqYnZkZXhqODFm?= =?utf-8?Q?LotfBzrbVouer8PIORZ5dAPC86l?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c47dd526-d779-4c3d-edff-08d8c3a2ddf5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2021 15:39:15.2183 (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: EfPULeozGC6obJfyPVGPO/6B9hZRAjgAs76rRWV46od1h1gwhbW2KrxAzh8WSSk8G4OGvUqcJ7pE3Twv9yCAow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1530 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: , From: Zoran Zaric via Gdb-patches Reply-To: Zoran Zaric Cc: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" > 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. > > Change-Id: Ie53ff8251af8c1556f0a83a31aa8572044b79e3d > Are these Gerrit change ID's? They shouldn't be part of the patches right? Zoran