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

Unified Diff: third_party/crazy_linker/crazy_linker/tests/zoo.cpp

Issue 23542017: This patch adds a new third-party library that implements an ELF dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor update Created 7 years, 3 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/crazy_linker/crazy_linker/tests/test_relro_sharing_two_libs.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/crazy_linker/crazy_linker/tests/zoo.cpp
diff --git a/third_party/crazy_linker/crazy_linker/tests/zoo.cpp b/third_party/crazy_linker/crazy_linker/tests/zoo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cedb213fba6f23de0384b22f3a18e255a8d8304f
--- /dev/null
+++ b/third_party/crazy_linker/crazy_linker/tests/zoo.cpp
@@ -0,0 +1,36 @@
+// Copyright (c) 2013 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/crazy_linker/crazy_linker/tests/test_relro_sharing_two_libs.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698