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

Unified Diff: third_party/android_crazy_linker/src/src/crazy_linker_library_view.h

Issue 322433006: Fork of the Android NDK crazy linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a required license header to a cpp module, missing in the original. Created 6 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
Index: third_party/android_crazy_linker/src/src/crazy_linker_library_view.h
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_library_view.h b/third_party/android_crazy_linker/src/src/crazy_linker_library_view.h
new file mode 100644
index 0000000000000000000000000000000000000000..84a46f03ed75a6164cebc570352e04127dbdace6
--- /dev/null
+++ b/third_party/android_crazy_linker/src/src/crazy_linker_library_view.h
@@ -0,0 +1,87 @@
+// 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.
+
+#ifndef CRAZY_LINKER_LIBRARY_VIEW_H
+#define CRAZY_LINKER_LIBRARY_VIEW_H
+
+#include "crazy_linker_error.h"
+#include "crazy_linker_util.h"
+
+namespace crazy {
+
+class SharedLibrary;
+
+// A LibraryView is a reference-counted handle to either a
+// crazy::SharedLibrary object or a library handle returned by the system's
+// dlopen() function.
+//
+// It has a name, which is always a base name, because only one
+// library with a given base name can be loaded in the system.
+class LibraryView {
+ public:
+ enum {
+ TYPE_NONE = 0xbaadbaad,
+ TYPE_SYSTEM = 0x2387cef,
+ TYPE_CRAZY = 0xcdef2387,
+ };
+
+ LibraryView()
+ : type_(TYPE_NONE), crazy_(NULL), system_(NULL), name_(), ref_count_(1) {}
+
+ ~LibraryView();
+
+ bool IsSystem() const { return type_ == TYPE_SYSTEM; }
+
+ bool IsCrazy() const { return type_ == TYPE_CRAZY; }
+
+ void SetSystem(void* system_lib, const char* name) {
+ type_ = TYPE_SYSTEM;
+ system_ = system_lib;
+ name_ = name;
+ }
+
+ void SetCrazy(SharedLibrary* crazy_lib, const char* name) {
+ type_ = TYPE_CRAZY;
+ crazy_ = crazy_lib;
+ name_ = name;
+ }
+
+ const char* GetName() { return name_.c_str(); }
+
+ SharedLibrary* GetCrazy() { return IsCrazy() ? crazy_ : NULL; }
+
+ void* GetSystem() { return IsSystem() ? system_ : NULL; }
+
+ void AddRef() { ref_count_++; }
+
+ // Decrement reference count. Returns true iff it reaches 0.
+ // This never destroys the object.
+ bool SafeDecrementRef() { return (--ref_count_ == 0); }
+
+ // Lookup a symbol from this library.
+ // If this is a crazy library, perform a breadth-first search,
+ // for system libraries, use dlsym() instead.
+ void* LookupSymbol(const char* symbol_name);
+
+ // Retrieve library information.
+ bool GetInfo(size_t* load_address,
+ size_t* load_size,
+ size_t* relro_start,
+ size_t* relro_size,
+ Error* error);
+
+ // Only used for debugging.
+ int ref_count() const { return ref_count_; }
+
+ private:
+ uint32_t type_;
+ SharedLibrary* crazy_;
+ void* system_;
+ String name_;
+ int ref_count_;
+};
+
+} // namespace crazy
+
+#endif // CRAZY_LINKER_LIBRARY_VIEW_H

Powered by Google App Engine
This is Rietveld 408576698