Fix relocation to look for symbols in local group

  The local group is a sequence of libraries in default (breadth-first)
  order. It allows RTLD_LOCALLY loaded library to correctly relocate
  symbols within its group (see test-cases).

  Local group lookup is performed after main executable and ld_preloads.

Bug: 2643900
Bug: 15432753
Bug: 18186310

(cherry picked from commit cfa97f172dc1b10d650fefbb6ccffd88ce72a5fb)

Change-Id: I5fa8c673f929e4652c738912c7ae078d7ec286d2
diff --git a/linker/linker.h b/linker/linker.h
index ebb4793..222aca1 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -207,7 +207,7 @@
   void CallDestructors();
   void CallPreInitConstructors();
   bool PrelinkImage();
-  bool LinkImage(const android_dlextinfo* extinfo);
+  bool LinkImage(const soinfo_list_t& local_group, const android_dlextinfo* extinfo);
 
   void add_child(soinfo* child);
   void remove_all_links();
@@ -234,9 +234,9 @@
   void CallArray(const char* array_name, linker_function_t* functions, size_t count, bool reverse);
   void CallFunction(const char* function_name, linker_function_t function);
 #if defined(USE_RELA)
-  int Relocate(ElfW(Rela)* rela, unsigned count);
+  int Relocate(ElfW(Rela)* rela, unsigned count, const soinfo_list_t& local_group);
 #else
-  int Relocate(ElfW(Rel)* rel, unsigned count);
+  int Relocate(ElfW(Rel)* rel, unsigned count, const soinfo_list_t& local_group);
 #endif
 
  private: