From patchwork Wed May 3 06:01:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 89569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1101888vqo; Tue, 2 May 2023 23:01:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7z6qrE4bMnryKTvOnYmuKENdQ0C6mKyWDxiLnXHNVCg8POOOF6qQsIZ+4AbxQczttTE+XM X-Received: by 2002:aa7:d05a:0:b0:506:6bd3:a53a with SMTP id n26-20020aa7d05a000000b005066bd3a53amr11557831edo.0.1683093688483; Tue, 02 May 2023 23:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683093688; cv=none; d=google.com; s=arc-20160816; b=CDuh5fVPB+d87VKr6BZb6zdql01tLc0mFsTf3YSBu3cFnAMjV8/KnrqPgviXGxtDWY eHg5cKzHMuAmpWjc1ulmy8W0N0+uKpo6zoCbWF6UUyWw5KPCAafmKuUK1jsJVjecblPN v5WSStuN36akGjpNyKTCwZWIhJC1g9r63NEUv2x7TguvAOi7JnRnfIQYYwmJT9A3uKH3 qMUVKJd4D3UIIyGhdPACiOgwTLbBmF58Ai1x/9B0wyCKvGUbaNwKZgwnEWJclOQnxG1V xeRt4Jm3TEcThwcmsgjoWyjoiWsE87GOkeLWY643hJ1HPnl/OihD0awWKNKMfkqk38YU 2KGw== 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=q4uhKGsVzuRxFl+eldyOu5diajMrZefo+hag3UR/7g4=; b=UfDGehNxC78/g0Lx2mM3VXabECnXIiO+WckUnIwI3I8KxafmuFE+Iu2QrA0vknqWt2 BEwt926RpF+lk/wh30ukcHnfDNfcPqrAg8UvOmptizfBTjbtB9WKK3RQmTG77YtzsEwH 1aV9NbE7XiJNa4bvg7zgCB4K49moWEdqxy/lipb5hIHYmqhuud9NgvEWNFSWLcfuI409 uX05WDGGQpECHoRIqnTbwe3X2NrWxnhc+8uRFxu3NJtS62F5RP+gE07bISRvskoMyVYr tdMteXscu/8/4tavFOuQz2BXYXEq2LL1y4e+dOuGXyGJrnzIXYvnOKxWIfWpn3L0UvtF gBjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ihntTvDO; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o21-20020a056402039500b0050bc272252esi502961edv.429.2023.05.02.23.01.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 23:01:28 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ihntTvDO; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 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 EFC253857723 for ; Wed, 3 May 2023 06:01:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFC253857723 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683093687; bh=q4uhKGsVzuRxFl+eldyOu5diajMrZefo+hag3UR/7g4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ihntTvDOr6IJ4rPYr1XD+aBWLgzl2H9O/LImZsA5Oxu9Ju5r2zAu305Y0RpQh9fjK Gc4e/P0CNz4bHPhLaCbQ7EKWGeG2iTXrwww4Qzvt1L5YWFMAPAISvvVVStqIOUbtjU 2C/o5nG816y/paSdg4gPJMtEauLf8GaR70OanzOU= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id A550E3858D28; Wed, 3 May 2023 06:01:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A550E3858D28 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5208be24dcbso3218812a12.1; Tue, 02 May 2023 23:01:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683093676; x=1685685676; 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=q4uhKGsVzuRxFl+eldyOu5diajMrZefo+hag3UR/7g4=; b=VeIZ2QdfP94ieOY0M+OIFCn6/iOeXMY0HYt5xCfQqhgPTUpG2jyaTgw1bKiaqt41DP TTAO/PSIQAjpzy1A44RxWURnp3M69p/Fa1e78+76My9eZh1tO9SJ6DktrgCKbwKwuGnf ZqR+JwbtPCVfouPcXn9EaQbsb39yEK9YfEOc8reN4UhVx91LrNkrCcUzYe2vgPR49PUJ jZU/Hu2KSxvtgY6kAoQfzRibhO49sF4m6+X0+aibEabP0/LFH2DtHJw3kpyc4AE/Er0F BSaetEneiH/aZg7NsSEh3j1n94Uq0+PPNtHqr3JEbQANiRwifY25D4gNHjYjIHXIyiBX HNAQ== X-Gm-Message-State: AC+VfDwaSgF0/50q7VLJWr11CeCMHXBOVPW/7JR40Da/BRCLQPGDEEYE b74wS2nlkgNY838iFt7y66N1PGG0yOM= X-Received: by 2002:a05:6a20:e195:b0:f5:68c9:6f83 with SMTP id ks21-20020a056a20e19500b000f568c96f83mr22446002pzb.18.1683093675861; Tue, 02 May 2023 23:01:15 -0700 (PDT) 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 x35-20020a056a0018a300b0063b6cccd5dfsm22831304pfh.195.2023.05.02.23.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 23:01:15 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 6E16F1140B60; Wed, 3 May 2023 15:31:11 +0930 (ACST) Date: Wed, 3 May 2023 15:31:11 +0930 To: binutils@sourceware.org, gdb-patches@sourceware.org Subject: Change signature of bfd crc functions Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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-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?1764851647453578784?= X-GMAIL-MSGID: =?utf-8?q?1764851647453578784?= The crc calculated is 32 bits. Replace uses of unsigned long with uint32_t. Also use bfd_byte* for buffers. bfd/ * opncls.c (bfd_calc_gnu_debuglink_crc32): Use stdint types. (bfd_get_debug_link_info_1, bfd_get_debug_link_info): Likewise. (separate_debug_file_exists, bfd_follow_gnu_debuglink): Likewise. (bfd_fill_in_gnu_debuglink_section): Likewise. * bfd-in2.h: Regenerate. gdb/ * auto-load.c (auto_load_objfile_script): Update type of bfd_get_debug_link_info argument. * symfile.c (find_separate_debug_file_by_debuglink): Likewise. * gdb_bfd.c (get_file_crc): Update type of bfd_calc_gnu_debuglink_crc32 argument. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 1eae010d9ca..d695402b62f 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -516,10 +516,10 @@ void *bfd_alloc (bfd *abfd, bfd_size_type wanted); void *bfd_zalloc (bfd *abfd, bfd_size_type wanted); -unsigned long bfd_calc_gnu_debuglink_crc32 - (unsigned long crc, const unsigned char *buf, bfd_size_type len); +uint32_t bfd_calc_gnu_debuglink_crc32 + (uint32_t crc, const bfd_byte *buf, bfd_size_type len); -char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out); +char *bfd_get_debug_link_info (bfd *abfd, uint32_t *crc32_out); char *bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len, diff --git a/bfd/opncls.c b/bfd/opncls.c index 81e124457e9..eabea414467 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -1091,8 +1091,8 @@ FUNCTION bfd_calc_gnu_debuglink_crc32 SYNOPSIS - unsigned long bfd_calc_gnu_debuglink_crc32 - (unsigned long crc, const unsigned char *buf, bfd_size_type len); + uint32_t bfd_calc_gnu_debuglink_crc32 + (uint32_t crc, const bfd_byte *buf, bfd_size_type len); DESCRIPTION Computes a CRC value as used in the .gnu_debuglink section. @@ -1102,12 +1102,12 @@ DESCRIPTION Return the updated CRC32 value. */ -unsigned long -bfd_calc_gnu_debuglink_crc32 (unsigned long crc, - const unsigned char *buf, +uint32_t +bfd_calc_gnu_debuglink_crc32 (uint32_t crc, + const bfd_byte *buf, bfd_size_type len) { - static const unsigned long crc32_table[256] = + static const uint32_t crc32_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, @@ -1162,7 +1162,7 @@ bfd_calc_gnu_debuglink_crc32 (unsigned long crc, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; - const unsigned char *end; + const bfd_byte *end; crc = ~crc & 0xffffffff; for (end = buf + len; buf < end; ++ buf) @@ -1176,7 +1176,7 @@ bfd_calc_gnu_debuglink_crc32 (unsigned long crc, The @var{crc32_out} parameter is an untyped pointer because this routine is used as a @code{get_func_type} function, but it - is expected to be an unsigned long pointer. + is expected to be a uint32_t pointer. Returns the filename of the associated debug information file, or NULL if there is no such file. If the filename was found @@ -1190,7 +1190,7 @@ static char * bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out) { asection *sect; - unsigned long *crc32 = (unsigned long *) crc32_out; + uint32_t *crc32 = crc32_out; bfd_byte *contents; unsigned int crc_offset; char *name; @@ -1234,7 +1234,7 @@ FUNCTION bfd_get_debug_link_info SYNOPSIS - char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out); + char *bfd_get_debug_link_info (bfd *abfd, uint32_t *crc32_out); DESCRIPTION Extracts the filename and CRC32 value for any separate debug @@ -1250,7 +1250,7 @@ DESCRIPTION */ char * -bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out) +bfd_get_debug_link_info (bfd *abfd, uint32_t *crc32_out) { return bfd_get_debug_link_info_1 (abfd, crc32_out); } @@ -1313,7 +1313,7 @@ bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len, } /* Checks to see if @var{name} is a file and if its contents match - @var{crc32}, which is a pointer to an @code{unsigned long} + @var{crc32}, which is a pointer to a @code{uint32_t} containing a CRC32. The @var{crc32_p} parameter is an untyped pointer because this @@ -1323,15 +1323,15 @@ static bool separate_debug_file_exists (const char *name, void *crc32_p) { unsigned char buffer[8 * 1024]; - unsigned long file_crc = 0; + uint32_t file_crc = 0; FILE *f; bfd_size_type count; - unsigned long crc; + uint32_t crc; BFD_ASSERT (name); BFD_ASSERT (crc32_p); - crc = *(unsigned long *) crc32_p; + crc = *(uint32_t *) crc32_p; f = _bfd_real_fopen (name, FOPEN_RB); if (f == NULL) @@ -1567,7 +1567,7 @@ DESCRIPTION char * bfd_follow_gnu_debuglink (bfd *abfd, const char *dir) { - unsigned long crc32; + uint32_t crc32; return find_separate_debug_file (abfd, dir, true, bfd_get_debug_link_info_1, @@ -1712,7 +1712,7 @@ bfd_fill_in_gnu_debuglink_section (bfd *abfd, const char *filename) { bfd_size_type debuglink_size; - unsigned long crc32; + uint32_t crc32; char * contents; bfd_size_type crc_offset; FILE * handle; diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 40b05fdc634..5267cb4e64d 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -856,7 +856,7 @@ auto_load_objfile_script (struct objfile *objfile, struct objfile *parent = objfile->separate_debug_objfile_backlink; if (parent != nullptr) { - unsigned long crc32; + uint32_t crc32; gdb::unique_xmalloc_ptr debuglink (bfd_get_debug_link_info (parent->obfd.get (), &crc32)); diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index b05c78218ed..17e454eb9fd 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -822,7 +822,7 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size) static int get_file_crc (bfd *abfd, unsigned long *file_crc_return) { - unsigned long file_crc = 0; + uint32_t file_crc = 0; if (bfd_seek (abfd, 0, SEEK_SET) != 0) { diff --git a/gdb/symfile.c b/gdb/symfile.c index 8ae2177b159..d0cb5cb6534 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1536,7 +1536,7 @@ std::string find_separate_debug_file_by_debuglink (struct objfile *objfile, std::vector *warnings_vector) { - unsigned long crc32; + uint32_t crc32; gdb::unique_xmalloc_ptr debuglink (bfd_get_debug_link_info (objfile->obfd.get (), &crc32));