Merge "libc: Rename fortify error functions."
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 80dc624..c53d52f 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -1492,18 +1492,19 @@
         return false;
     }
 
-    /* if this is the main executable, then load all of the preloads now */
+    // If this is the main executable, then load all of the libraries from LD_PRELOAD now.
     if (si->flags & FLAG_EXE) {
         memset(gLdPreloads, 0, sizeof(gLdPreloads));
+        size_t preload_count = 0;
         for (size_t i = 0; gLdPreloadNames[i] != NULL; i++) {
             soinfo* lsi = find_library(gLdPreloadNames[i]);
-            if (lsi == NULL) {
-                strlcpy(tmp_err_buf, linker_get_error_buffer(), sizeof(tmp_err_buf));
-                DL_ERR("could not load library \"%s\" needed by \"%s\"; caused by %s",
-                       gLdPreloadNames[i], si->name, tmp_err_buf);
-                return false;
+            if (lsi != NULL) {
+                gLdPreloads[preload_count++] = lsi;
+            } else {
+                // As with glibc, failure to load an LD_PRELOAD library is just a warning.
+                DL_WARN("could not load library \"%s\" from LD_PRELOAD for \"%s\"; caused by %s",
+                        gLdPreloadNames[i], si->name, linker_get_error_buffer());
             }
-            gLdPreloads[i] = lsi;
         }
     }
 
diff --git a/linker/linker.h b/linker/linker.h
index 61d623a..200a682 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -43,7 +43,16 @@
       __libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \
       /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
       DEBUG("%s\n", linker_get_error_buffer()); \
-    } while(0)
+    } while (false)
+
+#define DL_WARN(fmt, x...) \
+    do { \
+      __libc_format_log(ANDROID_LOG_WARN, "linker", fmt, ##x); \
+      __libc_format_fd(2, "WARNING: linker: "); \
+      __libc_format_fd(2, fmt, ##x); \
+      __libc_format_fd(2, "\n"); \
+    } while (false)
+
 
 // Returns the address of the page containing address 'x'.
 #define PAGE_START(x)  ((x) & PAGE_MASK)
diff --git a/tests/property_benchmark.cpp b/tests/property_benchmark.cpp
index dbd11ad..2c8e2a1 100644
--- a/tests/property_benchmark.cpp
+++ b/tests/property_benchmark.cpp
@@ -62,10 +62,10 @@
             delete names[i];
             delete values[i];
         }
-        delete names;
-        delete name_lens;
-        delete values;
-        delete value_lens;
+        delete[] names;
+        delete[] name_lens;
+        delete[] values;
+        delete[] value_lens;
         free(pa);
     }
 public:
@@ -87,12 +87,12 @@
     LocalPropertyTestState pa(nprops);
     char value[PROP_VALUE_MAX];
 
+    srandom(iters * nprops);
+
     StartBenchmarkTiming();
 
     for (int i = 0; i < iters; i++) {
-        for (int j = 0; j < nprops; j++) {
-            __system_property_get(pa.names[j], value);
-        }
+        __system_property_get(pa.names[random() % nprops], value);
     }
     StopBenchmarkTiming();
 }
@@ -104,12 +104,12 @@
 
     LocalPropertyTestState pa(nprops);
 
+    srandom(iters * nprops);
+
     StartBenchmarkTiming();
 
     for (int i = 0; i < iters; i++) {
-        for (int j = 0; j < nprops; j++) {
-            __system_property_find(pa.names[j]);
-        }
+        __system_property_find(pa.names[random() % nprops]);
     }
     StopBenchmarkTiming();
 }