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;
}
diff --git a/linker/linker_soinfo.h b/linker/linker_soinfo.h
index dd3817c..1cb727c 100644
--- a/linker/linker_soinfo.h
+++ b/linker/linker_soinfo.h
@@ -63,6 +63,7 @@
// destructor associated with this
// soinfo is executed and this flag is
// unset.
+#define FLAG_PRELINKED 0x00000400 // prelink_image has successfully processed this soinfo
#define FLAG_NEW_SOINFO 0x40000000 // new soinfo format
#define SOINFO_VERSION 5