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

Unified Diff: third_party/crazy_linker/crazy_linker/tests/foo_with_static_constructor.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
Index: third_party/crazy_linker/crazy_linker/tests/foo_with_static_constructor.cpp
diff --git a/third_party/crazy_linker/crazy_linker/tests/foo_with_static_constructor.cpp b/third_party/crazy_linker/crazy_linker/tests/foo_with_static_constructor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..50ed01601a3d87a0005ab540b7cbba9d62ce6f2f
--- /dev/null
+++ b/third_party/crazy_linker/crazy_linker/tests/foo_with_static_constructor.cpp
@@ -0,0 +1,39 @@
+// This source file must contain a static destructor to check that
+// the crazy linker can resolve weak symbols from the C library,
+// like __aeabi_atexit(), which are not normally returned by
+// a call to dlsym().
+
+#include <stdlib.h>
+
+extern "C" void __aeabi_atexit(void*);
+
+class A {
+ public:
+ A() {
+ x_ = rand();
+ const char* env = getenv("TEST_VAR");
+ if (!env || strcmp(env, "INIT"))
+ putenv("TEST_VAR=LOAD_ERROR");
+ else
+ putenv("TEST_VAR=LOADED");
+ }
+
+ ~A() {
+ const char* env = getenv("TEST_VAR");
+ if (!env || strcmp(env, "LOADED"))
+ putenv("TEST_VAR=UNLOAD_ERROR");
+ else
+ putenv("TEST_VAR=UNLOADED");
+ }
+
+ int Get() const { return x_; }
+
+ private:
+ int x_;
+};
+
+A s_a;
+
+extern "C" int Foo() {
+ return s_a.Get();
+}

Powered by Google App Engine
This is Rietveld 408576698