aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2015-11-02 13:21:44 -0500
committerPatrick Palka <patrick@parcs.ath.cx>2015-12-28 11:17:57 -0500
commit65da7f144f53f8af57ff8d4e337ceda49daacc21 (patch)
treed69f4b34bf42fdafcbdc6f8a0a0c5f3be1bcb03f
parentc622ccedda0134f95751bf14d1daa6fce2365d45 (diff)
downloadgdb-65da7f144f53f8af57ff8d4e337ceda49daacc21.zip
gdb-65da7f144f53f8af57ff8d4e337ceda49daacc21.tar.gz
gdb-65da7f144f53f8af57ff8d4e337ceda49daacc21.tar.bz2
Use libiberty's crc32 implementation in gdbserver
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.
-rw-r--r--gdb/gdbserver/ChangeLog5
-rw-r--r--gdb/gdbserver/server.c21
2 files changed, 6 insertions, 20 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index dd19262..cbc7763 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-28 Patrick Palka <patrick@parcs.ath.cx>
+
+ * server.c (crc32_table): Delete.
+ (crc32): Use libiberty's xcrc32 function.
+
2015-12-22 Joel Brobecker <brobecker@adacore.com>
* lynx-low.c (lynx_delete_thread_callback): New function.
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;