From: Patrick Palka <patrick@parcs.ath.cx>
To: gdb-patches@sourceware.org
Cc: Patrick Palka <patrick@parcs.ath.cx>
Subject: [PATCH] [COMMITTED] Use libiberty's crc32 implementation in gdbserver
Date: Mon, 28 Dec 2015 16:22:00 -0000 [thread overview]
Message-ID: <1451319725-31817-1-git-send-email-patrick@parcs.ath.cx> (raw)
In-Reply-To: <568122B4.7030502@redhat.com>
Tested on x86_64-pc-linux-gnu native-gdbserver, no new regressions.
gdb/gdbserver/ChangeLog:
* server.c (crc32_table): Delete.
(crc32): Use libiberty's xcrc32 function.
---
gdb/gdbserver/server.c | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index b385afb..0e3ac4e 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -1911,11 +1911,6 @@ handle_qxfer (char *own_buf, int packet_len, int *new_packet_len_p)
return 0;
}
-/* Table used by the crc32 function to calcuate the checksum. */
-
-static unsigned int crc32_table[256] =
-{0, 0};
-
/* Compute 32 bit CRC from inferior memory.
On success, return 32 bit CRC.
@@ -1924,20 +1919,6 @@ static unsigned int crc32_table[256] =
static unsigned long long
crc32 (CORE_ADDR base, int len, unsigned int crc)
{
- if (!crc32_table[1])
- {
- /* Initialize the CRC table and the decoding table. */
- int i, j;
- unsigned int c;
-
- for (i = 0; i < 256; i++)
- {
- for (c = i << 24, j = 8; j > 0; --j)
- c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1);
- crc32_table[i] = c;
- }
- }
-
while (len--)
{
unsigned char byte = 0;
@@ -1946,7 +1927,7 @@ crc32 (CORE_ADDR base, int len, unsigned int crc)
if (read_inferior_memory (base, &byte, 1) != 0)
return (unsigned long long) -1;
- crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ byte) & 255];
+ crc = xcrc32 (&byte, 1, crc);
base++;
}
return (unsigned long long) crc;
--
2.7.0.rc1.98.gacf58d0.dirty
prev parent reply other threads:[~2015-12-28 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-28 4:10 [PATCH] Avoid invoking undefined behavior when initializing CRC table Patrick Palka
2015-12-28 4:15 ` Patrick Palka
2015-12-28 11:53 ` Pedro Alves
2015-12-28 16:22 ` Patrick Palka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1451319725-31817-1-git-send-email-patrick@parcs.ath.cx \
--to=patrick@parcs.ath.cx \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox