diff --git a/ld/ldlang.c b/ld/ldlang.c
index 38e36c6fb16a7499e49edcd6eb7de3c781160188..fee100435a1e8d5fe4fcbc618a8b36acc11b8cfd 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -423,15 +423,15 @@ static struct md5_memory_entry
   md5_digest digest;
   char * str; // owned
   struct md5_memory_entry * next;
-} * md5_memory = NULL;
+} * md5_memory[1 << 12] = { };
 
 static bfd_boolean md5_collisions = FALSE;
 
 static void
 check_md5_memory (const char * str, const md5_digest * digest)
 {
-  struct md5_memory_entry ** next_ptr = &md5_memory;
-  for (struct md5_memory_entry * entry = md5_memory; entry != NULL; entry = entry->next)
+  struct md5_memory_entry ** next_ptr = &md5_memory[digest->data[0] % (sizeof(md5_memory)/sizeof(*md5_memory))];
+  for (struct md5_memory_entry * entry = *next_ptr; entry != NULL; entry = entry->next)
     {
       next_ptr = &entry->next;
       if (memcmp ((const void *) digest, (const void *) &entry->digest, 128/8) == 0)