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

Side by Side Diff: base/native_library_mac.mm

Issue 2277863002: Enable loading native libraries with RTLD_DEEPBIND (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/native_library.h" 5 #include "base/native_library.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <mach-o/getsect.h> 8 #include <mach-o/getsect.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 21 matching lines...) Expand all
32 reinterpret_cast<const struct mach_header_64*>(info.dli_fbase), 32 reinterpret_cast<const struct mach_header_64*>(info.dli_fbase),
33 SEG_DATA, "__objc_imageinfo"); 33 SEG_DATA, "__objc_imageinfo");
34 return section ? OBJC_PRESENT : OBJC_NOT_PRESENT; 34 return section ? OBJC_PRESENT : OBJC_NOT_PRESENT;
35 } 35 }
36 36
37 std::string NativeLibraryLoadError::ToString() const { 37 std::string NativeLibraryLoadError::ToString() const {
38 return message; 38 return message;
39 } 39 }
40 40
41 // static 41 // static
42 NativeLibrary LoadNativeLibrary(const FilePath& library_path, 42 NativeLibrary LoadNativeLibraryWithOptions(const FilePath& library_path,
43 NativeLibraryLoadError* error) { 43 const NativeLibraryOptions& options,
44 NativeLibraryLoadError* error) {
44 // dlopen() etc. open the file off disk. 45 // dlopen() etc. open the file off disk.
Primiano Tucci (use gerrit) 2016/08/24 22:14:09 I think here you want to CHECK that you don't have
Ken Rockot(use gerrit already) 2016/08/24 23:23:57 I would prefer we silently ignore the option since
Primiano Tucci (use gerrit) 2016/08/25 10:20:44 Silently changing ignoring a requested behavior fe
Ken Rockot(use gerrit already) 2016/08/25 15:52:12 If we were actually going to make the feature unav
Primiano Tucci (use gerrit) 2016/08/25 16:14:33 Oh hold on, I think we might be saying the same th
45 if (library_path.Extension() == "dylib" || !DirectoryExists(library_path)) { 46 if (library_path.Extension() == "dylib" || !DirectoryExists(library_path)) {
46 void* dylib = dlopen(library_path.value().c_str(), RTLD_LAZY); 47 void* dylib = dlopen(library_path.value().c_str(), RTLD_LAZY);
47 if (!dylib) { 48 if (!dylib) {
48 if (error) 49 if (error)
49 error->message = dlerror(); 50 error->message = dlerror();
50 return nullptr; 51 return nullptr;
51 } 52 }
52 NativeLibrary native_lib = new NativeLibraryStruct(); 53 NativeLibrary native_lib = new NativeLibraryStruct();
53 native_lib->type = DYNAMIC_LIB; 54 native_lib->type = DYNAMIC_LIB;
54 native_lib->dylib = dylib; 55 native_lib->dylib = dylib;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return function_pointer; 118 return function_pointer;
118 } 119 }
119 120
120 // static 121 // static
121 std::string GetNativeLibraryName(StringPiece name) { 122 std::string GetNativeLibraryName(StringPiece name) {
122 DCHECK(IsStringASCII(name)); 123 DCHECK(IsStringASCII(name));
123 return "lib" + name.as_string() + ".dylib"; 124 return "lib" + name.as_string() + ".dylib";
124 } 125 }
125 126
126 } // namespace base 127 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698