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

Side by Side Diff: base/android/linker/crazy_linker/src/crazy_linker_library_view.cpp

Issue 23717023: Android: Add chrome-specific dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename library 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "crazy_linker_library_view.h"
6
7 #include <dlfcn.h>
8 #include "crazy_linker_debug.h"
9 #include "crazy_linker_globals.h"
10 #include "crazy_linker_shared_library.h"
11
12 namespace crazy {
13
14 LibraryView::~LibraryView() {
15 LOG("%s: Destroying %s\n", __FUNCTION__, name_.c_str());
16 if (type_ == TYPE_SYSTEM) {
17 ::dlclose(system_);
18 system_ = NULL;
19 }
20 if (type_ == TYPE_CRAZY) {
21 delete crazy_;
22 crazy_ = NULL;
23 }
24 type_ = TYPE_NONE;
25 }
26
27 void* LibraryView::LookupSymbol(const char* symbol_name) {
28 if (type_ == TYPE_SYSTEM)
29 return ::dlsym(system_, symbol_name);
30
31 if (type_ == TYPE_CRAZY) {
32 LibraryList* lib_list = Globals::GetLibraries();
33 return lib_list->FindSymbolFrom(symbol_name, this);
34 }
35
36 return NULL;
37 }
38
39 bool LibraryView::GetInfo(size_t* load_address,
40 size_t* load_size,
41 size_t* relro_start,
42 size_t* relro_size,
43 int* relro_fd,
44 Error* error) {
45 if (type_ != TYPE_CRAZY) {
46 *error = "No RELRO sharing with system libraries";
47 return false;
48 }
49
50 *load_address = crazy_->base;
51 *load_size = crazy_->size;
52 *relro_start = crazy_->relro_start;
53 *relro_size = crazy_->relro_size;
54 *relro_fd = crazy_->relro_fd;
55 return true;
56 }
57
58 bool LibraryView::EnableSharedRelro(Error* error) {
59 if (type_ != TYPE_CRAZY) {
60 *error = "No RELRO sharing with system libraries";
61 return false;
62 }
63
64 return crazy_->EnableSharedRelro(error);
65 }
66
67 bool LibraryView::UseSharedRelro(size_t relro_start,
68 size_t relro_size,
69 int relro_fd,
70 Error* error) {
71 if (type_ != TYPE_CRAZY) {
72 *error = "No RELRO sharing with system libraries";
73 return false;
74 }
75
76 // If there is no RELRO segment, don't do anything.
77 if (relro_fd < 0 || relro_size == 0)
78 return true;
79
80 return crazy_->UseSharedRelro(relro_start, relro_size, relro_fd, error);
81 }
82
83 } // namespace crazy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698