Prelink each library only once

Previously, during a find_libraries call that loaded a library, a
library was prelinked once for each DT_NEEDED reference to the library.

This CL has a negligible effect on the linker relocation benchmark
(146.9ms -> 146.2ms).

Bug: none
Test: bionic unit tests
Change-Id: I385f312b8acf8d35aa0af9722131fe367b5edd9b
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 54e0703..1069234 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3346,6 +3346,7 @@
 static soinfo_list_t g_empty_list;
 
 bool soinfo::prelink_image() {
+  if (flags_ & FLAG_PRELINKED) return true;
   /* Extract dynamic section */
   ElfW(Word) dynamic_flags = 0;
   phdr_table_get_dynamic_section(phdr, phnum, load_bias, &dynamic, &dynamic_flags);
@@ -3840,6 +3841,8 @@
 
     // Don't call add_dlwarning because a missing DT_SONAME isn't important enough to show in the UI
   }
+
+  flags_ |= FLAG_PRELINKED;
   return true;
 }