Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1153)

Unified Diff: third_party/android_crazy_linker/src/tests/zoo.cpp

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/android_crazy_linker/src/tests/test_util.h ('k') | third_party/android_platform/config.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/android_crazy_linker/src/tests/zoo.cpp
diff --git a/third_party/android_crazy_linker/src/tests/zoo.cpp b/third_party/android_crazy_linker/src/tests/zoo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..280a54cc3ed4ffe436b27cc44ef41f9c0d7c9e59
--- /dev/null
+++ b/third_party/android_crazy_linker/src/tests/zoo.cpp
@@ -0,0 +1,35 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+extern "C" bool Zoo() {
+ printf("%s: Entering\n", __FUNCTION__);
+ void* bar_lib = dlopen("libbar.so", RTLD_NOW);
+ if (!bar_lib) {
+ fprintf(stderr, "Could not libbar.so: %s\n", dlerror());
+ return false;
+ }
+ printf("%s: Opened libbar.so @%p\n", __FUNCTION__, bar_lib);
+
+ void (*bar_func)();
+
+ bar_func = reinterpret_cast<void (*)()>(dlsym(bar_lib, "Bar"));
+ if (!bar_func) {
+ fprintf(stderr, "Could not find 'Bar' symbol in libbar.so\n");
+ return false;
+ }
+ printf("%s: Found 'Bar' symbol at @%p\n", __FUNCTION__, bar_func);
+
+ // Call it.
+ printf("%s: Calling Bar()\n", __FUNCTION__);
+ (*bar_func)();
+
+ printf("%s: Closing libbar.so\n", __FUNCTION__);
+ dlclose(bar_lib);
+
+ printf("%s: Exiting\n", __FUNCTION__);
+ return true;
+}
« no previous file with comments | « third_party/android_crazy_linker/src/tests/test_util.h ('k') | third_party/android_platform/config.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698