Check if strtab exists before using it

Bug: http://b/21696087
Change-Id: I1e22d5fd6fe2faead332249493123c9a085081e9
(cherry picked from commit 624b8f17a1ce9b968f11e73231733442a07ac001)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 5aabacc..bdd3ecd 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2857,17 +2857,6 @@
     }
   }
 
-  // second pass - parse entries relying on strtab
-  for (ElfW(Dyn)* d = dynamic; d->d_tag != DT_NULL; ++d) {
-    if (d->d_tag == DT_SONAME) {
-      soname_ = get_string(d->d_un.d_val);
-#if defined(__work_around_b_19059885__)
-      strlcpy(old_name_, soname_, sizeof(old_name_));
-#endif
-      break;
-    }
-  }
-
   DEBUG("si->base = %p, si->strtab = %p, si->symtab = %p",
         reinterpret_cast<void*>(base), strtab_, symtab_);
 
@@ -2890,6 +2879,17 @@
     return false;
   }
 
+  // second pass - parse entries relying on strtab
+  for (ElfW(Dyn)* d = dynamic; d->d_tag != DT_NULL; ++d) {
+    if (d->d_tag == DT_SONAME) {
+      soname_ = get_string(d->d_un.d_val);
+#if defined(__work_around_b_19059885__)
+      strlcpy(old_name_, soname_, sizeof(old_name_));
+#endif
+      break;
+    }
+  }
+
   // Before M release linker was using basename in place of soname.
   // In the case when dt_soname is absent some apps stop working
   // because they can't find dt_needed library by soname.