From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 706663858433; Wed, 3 May 2023 06:05:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 706663858433 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683093915; bh=QDfo98fWw3C+lSEqIJKT89rSvVRVqx2T6Qn3tjAqLv0=; h=From:To:Subject:Date:From; b=QfE/drXurC6Qhcg0ryEqpDwJMO0qBFhmHhLAAdfRcfY3eE+9po5a8d+bXXI/Pwp0Y BttHaPXhmaTAG1WZqDzHrNDH4pMzwGI443ngB/szJn24cD0oVSwOQe/vfdaMDyOKhk EBVax0uvTEij1j0oHN8nDEhVPTrQV4GU2anI8XEA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] Change signature of bfd crc functions X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: e84ca83738a748d8afe53e74b9666e74ae708dcc X-Git-Newrev: df2fc6fbfd8f8188b06a6dd3c8987e8c3135ec58 Message-Id: <20230503060515.706663858433@sourceware.org> Date: Wed, 3 May 2023 06:05:15 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Ddf2fc6fbfd8f= 8188b06a6dd3c8987e8c3135ec58 commit df2fc6fbfd8f8188b06a6dd3c8987e8c3135ec58 Author: Alan Modra Date: Sat Apr 29 10:37:28 2023 +0930 Change signature of bfd crc functions =20 The crc calculated is 32 bits. Replace uses of unsigned long with uint32_t. Also use bfd_byte* for buffers. =20 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): Likewis= e. (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: --- bfd/bfd-in2.h | 6 +++--- bfd/opncls.c | 34 +++++++++++++++++----------------- gdb/auto-load.c | 2 +- gdb/gdb_bfd.c | 2 +- gdb/symfile.c | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) 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); =20 void *bfd_zalloc (bfd *abfd, bfd_size_type wanted); =20 -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); =20 -char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out); +char *bfd_get_debug_link_info (bfd *abfd, uint32_t *crc32_out); =20 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 =20 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); =20 DESCRIPTION Computes a CRC value as used in the .gnu_debuglink section. @@ -1102,12 +1102,12 @@ DESCRIPTION Return the updated CRC32 value. */ =20 -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] =3D + static const uint32_t crc32_table[256] =3D { 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; =20 crc =3D ~crc & 0xffffffff; for (end =3D buf + len; buf < end; ++ buf) @@ -1176,7 +1176,7 @@ bfd_calc_gnu_debuglink_crc32 (unsigned long crc, =20 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. =20 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 =3D (unsigned long *) crc32_out; + uint32_t *crc32 =3D crc32_out; bfd_byte *contents; unsigned int crc_offset; char *name; @@ -1234,7 +1234,7 @@ FUNCTION bfd_get_debug_link_info =20 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); =20 DESCRIPTION Extracts the filename and CRC32 value for any separate debug @@ -1250,7 +1250,7 @@ DESCRIPTION */ =20 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_typ= e *buildid_len, } =20 /* 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. =20 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 =3D 0; + uint32_t file_crc =3D 0; FILE *f; bfd_size_type count; - unsigned long crc; + uint32_t crc; =20 BFD_ASSERT (name); BFD_ASSERT (crc32_p); =20 - crc =3D *(unsigned long *) crc32_p; + crc =3D *(uint32_t *) crc32_p; =20 f =3D _bfd_real_fopen (name, FOPEN_RB); if (f =3D=3D NULL) @@ -1567,7 +1567,7 @@ DESCRIPTION char * bfd_follow_gnu_debuglink (bfd *abfd, const char *dir) { - unsigned long crc32; + uint32_t crc32; =20 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 =3D objfile->separate_debug_objfile_backlink; if (parent !=3D nullptr) { - unsigned long crc32; + uint32_t crc32; gdb::unique_xmalloc_ptr debuglink (bfd_get_debug_link_info (parent->obfd.get (), &crc32)); =20 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 *si= ze) static int get_file_crc (bfd *abfd, unsigned long *file_crc_return) { - unsigned long file_crc =3D 0; + uint32_t file_crc =3D 0; =20 if (bfd_seek (abfd, 0, SEEK_SET) !=3D 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; =20 gdb::unique_xmalloc_ptr debuglink (bfd_get_debug_link_info (objfile->obfd.get (), &crc32));