From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2042.outbound.protection.outlook.com [40.107.21.42]) by sourceware.org (Postfix) with ESMTPS id 76F663856DED for ; Thu, 11 Aug 2022 13:03:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 76F663856DED ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nOWub+yzHCKKuANsZ88kDBwNHL1uas8GXsRSh/FswWnYJomrhpRP9u5n7mXPwFzpGOrCLlhPpdau6GKjF7f+HrVUQMQPzI06nRFFaGxfUA9v1bxMiKr4Ug9d2l/1+iX3lmUEMJSt/Q8W/lusU298U1xvCw3QDF9+zz5EU3eDtozxMj+BrVWpj9p9B0JlpeVeh4iw044dO3zal1NvFVeZSsOvVemV2z/z2ryULe0OZJJ5OPfMK4MlXrYSm/1eYV/M7RtMEqUUDCahs9xYraDNWsT57tuOoIPACmxTwQiGEpZVMu0+2aPMaW/yyc9zgYxxAG9UTRaYmcI6GQH/qOS4yQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5mGvqmElp+y8qObF+xPzXSB1Gy+YCBlG0XrupjYgZC4=; b=j6zZ7AU1f7nBWXqSjEAAw16lEPbRE/nFsfwGWYUHNexXxNFU1jAxXgm8Av6RZsnKnsfqepbdXUZ4wSxas+3RCyAWjmxUhmTmDbJ/EMcWL1s+2TfIZhVWT/47EGrkk4KRJQBZaJakdPhKA8BOEeUCEvCsxAYBnW2EFUIZvXmnysWixqeb9bwKRX6tiSLLbI1VvnXaQfjyqZoWXWJJq+UBdqbrcBohNzorLwpFU5VC/FfSkzEjCCt8ncgkYIqzJ0wrkrJFD14ksBEgKVI/nOoEzIRIiODzsopOkkCjo+/lXpepumN693DfG/osioZ99Hi0GuNN7L+yBkuHNSXlPV0kUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by HE1PR0401MB2331.eurprd04.prod.outlook.com (2603:10a6:3:24::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.22; Thu, 11 Aug 2022 13:02:57 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2d5d:bae0:430f:70ad]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2d5d:bae0:430f:70ad%4]) with mapi id 15.20.5525.010; Thu, 11 Aug 2022 13:02:57 +0000 Message-ID: Date: Thu, 11 Aug 2022 15:02:55 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] Add pdb archive target Content-Language: en-US To: Mark Harmstone References: <20220725234405.19880-1-mark@harmstone.com> Cc: binutils@sourceware.org From: Jan Beulich In-Reply-To: <20220725234405.19880-1-mark@harmstone.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR0P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::15) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c35303f0-b4ef-4e6a-1aeb-08da7b99cfd1 X-MS-TrafficTypeDiagnostic: HE1PR0401MB2331:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MnTP1ArIAqommnjGQYQ9cxu69o9717HVbFqY5f4n9KsVzdShdbw8RNGzapUijqiRopO3q+z2ky3lB7pkDO/1Stjjp9a3lPYXkvEk6LehztvXSJu7rYoYU9dXwVZn9ivETXXUY3c0JcNTfY29ExehQINiUjkpgjQTFQl35CBf18L3Vc4aS/AmVn76/vsp4Xt5NhqeXB+nHijl7Z4qpxb1DFIPDkZrwz9eN7yRI7wM4wcEbqnfr/Envno8fMSVKKlPUu/aTQ2Z+ErPjFBCSlgelIbqmV9Nwv5lGkR/VgFrGjmIFcFfcUgxSQM4RmJRJUh3NApm1Kavpt4jHkaEeur/iXW+IvlkJ0EwGrGoTTscYKdqOIXdNNbSZe4h+Ta/lTlglmA7wWC9D8uaXbeJEBFDwrd9OG8g/WsMx9WVoQdp7KeRDNunEFSHNIr5ftzEybAJBuBw1jUQaRawqA5j6/8tozuFrfEoYAjkRfMR1hrMdizgmeghm1RcGMbhYc/YmqzCS9sW06hT63d0fBWUWSkL66lRhHw3IOOetg/wklyuN1V4v0tnDzXNEeMzGKRuMIMkEA2MwAMlh262o+4g6XdjCIABB8gJyXAHXBh9jKP0rOPTdX/uR+ycagYgmsfJ2rbETl0F02QbikAPcnDGzLSCs4ICr8uvgqDyVf5IRVyHvaca+aI+zM9AVC4vYYQfZk1jtU4zZC+RGSYKjddQc9Ae5Bo5I6WA68UfxSJv09y3PsJj6po7D8YPtTtj4dK9Z0cRhv2lRP95UF/uBXJoZAXXtSwVVVgKbBKezp1OBDHNBxJFICTjDztvv2coLDsqhyY5CPB4gsI+OIrXaqCYcQ3+AOFjMKuIAndyTOgze9YBwq1qAd1bCRch2s3hHoyz9H5X X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6560.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(376002)(366004)(396003)(136003)(346002)(39860400002)(8936002)(5660300002)(6512007)(316002)(45080400002)(86362001)(31696002)(2616005)(30864003)(2906002)(38100700002)(6916009)(31686004)(36756003)(66946007)(66476007)(66556008)(4326008)(8676002)(83380400001)(186003)(478600001)(41300700001)(966005)(6486002)(26005)(6506007)(53546011)(2004002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dzBTcitJY2JyOHk0cCttcFNHN0ZVangvSjB4VVdvcEl4eVZQR3lmWVhiT3VJ?= =?utf-8?B?YTNqQmZWRGRxcHN4U2UyUEo2bTVrZFhJSlZQY0IrQXhqckxLdzNhQjY3eU1U?= =?utf-8?B?dy9kd3JlWUVFM2VyK2hNck9Hck4vOS90SlVwY0JHc3h2R1k3VEFNOWw1dy93?= =?utf-8?B?c0szT29PbmRCZVljblIzazJkY2p2eE5jaHJXUGl0VHU1RGVaa3ArSWxwSy81?= =?utf-8?B?a3dLbFZBR3ljanJKR05JdWhWd1h4dWxaKzBzSWVEaHdwTHI5WFJoSFZOTFAr?= =?utf-8?B?a1l3VHJWSEhJcFdiQVpKTGM2d1ZCYkcvQXhJVmVoUmlnVWU2amNiQ3B4VnJu?= =?utf-8?B?MXo2NU5IWk8rdjRISjU3SkhXQU9icm05YmYwdXMyVVpkU0R4TnZFNTlyU2hH?= =?utf-8?B?TzNlRzdEUnJ1aUUxdjhJelZhdVFjSklvd2k5Q3d6bHQrWG9oT1gvS2UxdUJM?= =?utf-8?B?a01MbzF4cmNFMnBOYmloajVwN3RHdUEwUFluckRjYlh0T3oremY5Slo5aE85?= =?utf-8?B?V2xha3ZzRkhBbG1UUXNUYUNTaHhDZXNFTElvTWk3UUJ6Z2IrR2V3VHk2WS9M?= =?utf-8?B?SkVPVmxoamVHa1lkU2dXQys0VXRDL3pDYUdvQjR6TDluVWZNZXA3VnRBS2Nr?= =?utf-8?B?R1ovSmE2L1NSSWlVTnNuTkZwLzFzc1M2YjQxWVNhY1c5bCt3V2xRNGZjVy9I?= =?utf-8?B?cU9YL3pCUmVwTXNSQTF2R3FuWHIzQ2FGL3A1ZmJLV1JaeS9IdDVSMjdqUUtu?= =?utf-8?B?VmcwZEdVTFZja1hISUNISCt5Y0FLcDgydjN5cWYyWkNNUjkrOFk4emFEcnI5?= =?utf-8?B?VDh1a2VEa2lSTEdYMUpZeU9nTk1zUlZtZjM1S09IYmNwcUhMVmRIeTBUQUN5?= =?utf-8?B?NUNNVzhMOUJ5SkJhQi92ZzkvR01WNnU3REs4dVpENml0cUx2cUp3SUNmb3hR?= =?utf-8?B?VCtuVGhILzIvK3NjamZ5dVdHcXRiOWZlSE5aMzNYSmNUa3pWRENxTGxSUDJj?= =?utf-8?B?QjkyVGR6U3kvNjRma2VaT0VTbzY0OEhZUUE1cm1DUmZGRVBwTFFWbUtLVCtH?= =?utf-8?B?dGlHczdnY3AxVEtBdU9hLzd6SVkzWmU2RTJPN3lOeGdhM1FwZWZjZEVRWVJV?= =?utf-8?B?dW8yRWdQQ3E4aDlpeUNtQStvMHVST1pKdlhJQXNlOUlRYnNVMnp1cFVnM0lv?= =?utf-8?B?Q3ZQZEZUQVZnN0VNRThkcjJlZTk4Ymw1Y0pUT1gyUm5FWnQxU0pUdmwzbUJk?= =?utf-8?B?UVd6VWtDMFBzV3FSZWg2OTlvVE1zTzBUSDJTMXFLU3ZldURTWDlQbzlmMmNZ?= =?utf-8?B?Y0JkT0ZvYitSd3Z5QStRQnl1anBuSWpJL21TVFdqY3FmL3B4eVRpYUlzOWxz?= =?utf-8?B?aGNBaXhNSVlqUE1IZ3VNSEJaZFc0NFdocXNkUk1zUTNmOVg1VmROY0pGaXRL?= =?utf-8?B?a0dMK1EzVDEzb01FZFB1Q2pYOW43OC82M1owblZJOTduU243ajFxMFl3NjJ6?= =?utf-8?B?Y1pDNDlZTk5xUzZGOVIrYmd5Y0dwNnp5bzhFVWhmQ3A2VXVVUms1RzZBOEdN?= =?utf-8?B?YjhoRjVVQWxBaW1FcC9Bb1NRcTYvMTJoMCtaelZWc2o1dGN1T0NXT2NZWXNU?= =?utf-8?B?MEpKalpLQXZJSGVkdzhKVUxjaExCNndjT25UL2RVTGU0YjRHMmhtNCtGVFp5?= =?utf-8?B?eDZTUVBpU1h5anlYVUNqeXNLQWNpTWNwZkx2TlgxdENPbzQvSy9oMXAzUlUv?= =?utf-8?B?Q3JRQjJydk5IdjNOeHVwVUZlMmY1OEJZOEhycm5QZG1hcjNzajN0NlFvSlFz?= =?utf-8?B?cEJZUDM1NEZVQThPYTFHV0hXYTAvSXFaUzVwZEpjOERCV2tRMitUVjVDY0RK?= =?utf-8?B?dStIbW5yTFF3aTdzbTN4SkVkZUtzcEhjVVNjYVNBOXIrUUgwcEVwNWkrUnRm?= =?utf-8?B?c0hLYnhGLzlON0pLRjU0R1FDT2FlNEt4QnZEMEduUDgxeW9sVjc3TjcreWVZ?= =?utf-8?B?SWJnUEJva0RNTHQ1b1dPZFc2bG54MVUrcStCOGl2NjFWUEVEMGxRSk9wRVpm?= =?utf-8?B?ZThUazc4Q0o5OFRiN1F2VTZNN1Q0MWVMZVQ3SVRZUXpCWFU1TjR6Z3RRT3dG?= =?utf-8?Q?MZcYPEIORdkM3BYmK4vRhZKTD?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c35303f0-b4ef-4e6a-1aeb-08da7b99cfd1 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 13:02:57.4865 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xgRGb6coPUrJeTXvdv+VKwroEhVN/1AwxKKvlHCaA7ZQytVICrqMjH4izRQRLiLcJq/sXIO51mGFkmP1bCZuKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0401MB2331 X-Spam-Status: No, score=-3030.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Thu, 11 Aug 2022 13:03:09 -0000 On 26.07.2022 01:44, Mark Harmstone wrote: > This adds support for the "Multi-Stream Format" container format that > MSVC uses for its PDB debugging files, as documented at > https://llvm.org/docs/PDB/MsfFile.html. Looking at binutils/testsuite/binutils-all/pdb*.d I wonder what "support" here means: What is dumped is the binary contents of the file (claimed to be coming from section .data) rather than the inner file structure. Also this looks to cover only one of several flavors/versions, which may want calling out here and which also may influence the naming of certain things throughout the patch. > This is a prerequisite for gdb to be able to read Microsoft's debug > files, and for gcc and ld to generate debugging info that can be read by > Microsoft's tools. Are there plans in any of those three directions? > --- a/bfd/config.bfd > +++ b/bfd/config.bfd > @@ -388,7 +388,7 @@ case "${targ}" in > ;; > arm-wince-pe | arm-*-wince | arm*-*-mingw32ce* | arm*-*-cegcc*) > targ_defvec=arm_pe_wince_le_vec > - targ_selvecs="arm_pe_wince_le_vec arm_pe_wince_be_vec arm_pei_wince_le_vec arm_pei_wince_be_vec" > + targ_selvecs="arm_pe_wince_le_vec arm_pe_wince_be_vec arm_pei_wince_le_vec arm_pei_wince_be_vec pdb_vec" > targ_underscore=no > targ_cflags="-DARM_WINCE -DARM_COFF_BUGFIX" > ;; > @@ -708,7 +708,7 @@ case "${targ}" in > ;; > x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin) > targ_defvec=x86_64_pe_vec > - targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec l1om_elf64_vec k1om_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec" > + targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec l1om_elf64_vec k1om_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec pdb_vec" I'm not sure adding this as a default for -pe and -pep is appropriate; I certainly agree with MingW and Cygwin. Same for ix86's -pe then, whereas I'm unclear about what arm*-*-cegcc* is. > --- a/bfd/configure.ac > +++ b/bfd/configure.ac > @@ -416,7 +416,7 @@ tb= > > elf="elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo > dwarf1.lo dwarf2.lo" > -coffgen="coffgen.lo dwarf2.lo" > +coffgen="coffgen.lo dwarf2.lo pdb.lo" > coff="cofflink.lo $coffgen" > ecoff="ecofflink.lo $coffgen" > xcoff="xcofflink.lo $coffgen" Similarly here - is this really relevant to ecoff and xcoff as well? I'm not even convinced this wants universally tying to coff. > --- /dev/null > +++ b/bfd/pdb.c > @@ -0,0 +1,804 @@ > +/* BFD back-end for PDB Multi-Stream Format archives. > + Copyright (C) 2022 Free Software Foundation, Inc. > + > + This file is part of BFD, the Binary File Descriptor library. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program; if not, write to the Free Software > + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, > + MA 02110-1301, USA. */ > + > +/* This describes the MSF file archive format, which is used for the > + PDB debug info generated by MSVC. See https://llvm.org/docs/PDB/MsfFile.html > + for a full description of the format. */ > + > +#include "sysdep.h" > +#include "bfd.h" > +#include "libbfd.h" > + > +/* "Microsoft C/C++ MSF 7.00\r\n\x1a\x44\x53\0\0\0" */ > +static const uint8_t pdb_magic[] = > +{ 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, > + 0x74, 0x20, 0x43, 0x2f, 0x43, 0x2b, 0x2b, 0x20, > + 0x4d, 0x53, 0x46, 0x20, 0x37, 0x2e, 0x30, 0x30, > + 0x0d, 0x0a, 0x1a, 0x44, 0x53, 0x00, 0x00, 0x00 }; > + > +#define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data)) > + > +static bfd_cleanup > +pdb_archive_p (bfd *abfd) > +{ > + int ret; > + char magic[sizeof (pdb_magic)]; > + > + ret = bfd_bread (magic, sizeof (magic), abfd); > + if (ret != sizeof (magic)) > + { > + bfd_set_error (bfd_error_wrong_format); > + return NULL; > + } > + > + if (memcmp (magic, pdb_magic, sizeof (magic))) > + { > + bfd_set_error (bfd_error_wrong_format); > + return NULL; > + } > + > + return _bfd_no_cleanup; > +} > + > +static bfd * > +pdb_get_elt_at_index (bfd *abfd, symindex sym_index) > +{ > + char int_buf[sizeof (uint32_t)]; > + uint32_t block_size, block_map_addr, block, num_files; > + uint32_t first_dir_block, dir_offset, file_size, block_off, left; > + char name[10]; > + bfd *file; > + char *buf; > + > + /* get block_size */ > + > + if (bfd_seek (abfd, sizeof (pdb_magic), SEEK_SET)) > + return NULL; > + > + if (bfd_bread (int_buf, sizeof (uint32_t), abfd) != sizeof (uint32_t)) > + { > + bfd_set_error (bfd_error_malformed_archive); > + return NULL; > + } > + > + block_size = bfd_getl32 (int_buf); > + > + /* get block_map_addr */ > + > + if (bfd_seek (abfd, 4 * sizeof (uint32_t), SEEK_CUR)) > + return NULL; > + > + if (bfd_bread (int_buf, sizeof (uint32_t), abfd) != sizeof (uint32_t)) > + { > + bfd_set_error (bfd_error_malformed_archive); > + return NULL; > + } > + > + block_map_addr = bfd_getl32 (int_buf); > + > + /* get num_files */ > + > + if (bfd_seek (abfd, block_map_addr * block_size, SEEK_SET)) > + return NULL; > + > + if (bfd_bread (int_buf, sizeof (uint32_t), abfd) != sizeof (uint32_t)) > + { > + bfd_set_error (bfd_error_malformed_archive); > + return NULL; > + } > + > + first_dir_block = bfd_getl32 (int_buf); > + > + if (bfd_seek (abfd, first_dir_block * block_size, SEEK_SET)) > + return NULL; > + > + if (bfd_bread (int_buf, sizeof (uint32_t), abfd) != sizeof (uint32_t)) > + { > + bfd_set_error (bfd_error_malformed_archive); > + return NULL; > + } > + > + num_files = bfd_getl32 (int_buf); > + > + if (sym_index >= num_files) > + { > + bfd_set_error (bfd_error_no_more_archived_files); > + return NULL; > + } > + > + /* read file size */ > + > + dir_offset = sizeof (uint32_t) * (sym_index + 1); > + > + if (dir_offset >= block_size) > + { > + uint32_t block_map_addr_off; > + > + block_map_addr_off = ((dir_offset / block_size) * sizeof (uint32_t)); > + > + if (bfd_seek (abfd, (block_map_addr * block_size) + block_map_addr_off, > + SEEK_SET)) > + return NULL; > + > + if (bfd_bread (int_buf, sizeof (uint32_t), abfd) != sizeof (uint32_t)) > + { > + bfd_set_error (bfd_error_malformed_archive); > + return NULL; > + } > + > + block = bfd_getl32 (int_buf); > + } > + else > + { > + block = first_dir_block; > + } > + > + if (bfd_seek (abfd, (block * block_size) + (dir_offset % block_size), > + SEEK_SET)) > + return NULL; > + > + if (bfd_bread (int_buf, sizeof (uint32_t), abfd) != sizeof (uint32_t)) > + { > + bfd_set_error (bfd_error_malformed_archive); > + return NULL; > + } > + > + file_size = bfd_getl32 (int_buf); > + > + /* create BFD */ > + > + sprintf (name, "%04lx", sym_index); Is there a reason for this 4-or-more digits naming of the file? Would it make sense to use 8 digits (beyond which the index apparently cannot grow)? > --- /dev/null > +++ b/binutils/testsuite/binutils-all/pdb.exp > @@ -0,0 +1,157 @@ > +# Copyright (C) 2022 Free Software Foundation, Inc. > + > +# This file is part of the GNU Binutils. > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program; if not, write to the Free Software > +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. > + > +proc pdb_archive_1 { } { > + global AR > + global OBJDUMP > + global srcdir > + global subdir > + > + set testname "pdb archive 1" > + > + file delete tmpdir/test.pdb > + > + # add short file (less than block size) > + > + set got [binutils_run $AR "cr --target=pdb tmpdir/test.pdb $srcdir/$subdir/pdbfile1"] > + if ![string match "" $got] { > + fail $testname > + return > + } > + > + set got [binutils_run $AR "tv tmpdir/test.pdb"] > + if ![string match "rw-r--r-- 0/0 3 *0000*" $got] { > + fail $testname > + return > + } > + > + set got [binutils_run $OBJDUMP "-s --target=binary tmpdir/test.pdb"] > + set exp [file_contents "$srcdir/$subdir/pdb1.d"] > + if ![string equal $got $exp] { > + fail $testname > + return > + } > + > + set got [binutils_run $AR "x tmpdir/test.pdb 0000 --output=tmpdir"] > + if ![string match "" $got] { > + fail $testname > + return > + } > + > + set got [file_contents tmpdir/0000] > + set exp [file_contents "$srcdir/$subdir/pdbfile1"] > + if ![string equal $got $exp] { > + fail $testname > + return > + } > + > + pass $testname > +} > + > +proc pdb_archive_2 { } { > + global AR > + global OBJDUMP > + global srcdir > + global subdir > + > + set testname "pdb archive 2" > + > + # add empty file > + > + set got [binutils_run $AR "cr --target=pdb tmpdir/test.pdb /dev/null"] > + if ![string match "" $got] { > + fail $testname > + return > + } > + > + set got [binutils_run $AR "tv tmpdir/test.pdb"] > + if ![string match "*\nrw-r--r-- 0/0 0 *0001*" $got] { > + fail $testname > + return > + } > + > + set got [binutils_run $OBJDUMP "-s --target=binary tmpdir/test.pdb"] > + set exp [file_contents "$srcdir/$subdir/pdb2.d"] > + if ![string equal $got $exp] { > + fail $testname > + return > + } > + > + set got [binutils_run $AR "x tmpdir/test.pdb 0001 --output=tmpdir"] > + if ![string match "" $got] { > + fail $testname > + return > + } > + > + set got [file_contents tmpdir/0001] > + if ![string equal $got ""] { > + fail $testname > + return > + } > + > + pass $testname > +} > + > +proc pdb_archive_3 { } { > + global AR > + global OBJDUMP > + global srcdir > + global subdir > + > + set testname "pdb archive 3" > + > + # add long file (greater than block size) > + > + set got [binutils_run $AR "cr --target=pdb tmpdir/test.pdb $srcdir/$subdir/pdbfile2"] > + if ![string match "" $got] { > + fail $testname > + return > + } > + > + set got [binutils_run $AR "tv tmpdir/test.pdb"] > + if ![string match "*\nrw-r--r-- 0/0 1032 *0002*" $got] { > + fail $testname > + return > + } > + > + set got [binutils_run $OBJDUMP "-s --target=binary tmpdir/test.pdb"] > + set exp [file_contents "$srcdir/$subdir/pdb3.d"] > + if ![string equal $got $exp] { > + fail $testname > + return > + } > + > + set got [binutils_run $AR "x tmpdir/test.pdb 0002 --output=tmpdir"] > + if ![string match "" $got] { > + fail $testname > + return > + } > + > + set got [file_contents tmpdir/0002] > + set exp [file_contents "$srcdir/$subdir/pdbfile2"] > + if ![string equal $got $exp] { > + fail $testname > + return > + } > + > + pass $testname > +} > + > +pdb_archive_1 > +pdb_archive_2 > +pdb_archive_3 The three functions look pretty similar. Any chance of folding them into just one, suitably parametrized? Jan