summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 00:24:50 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 00:24:50 +0000
commit62652e21448df2b0e49aca6c69c3d65896188810 (patch)
treeeedf2a796443ea6c3f0862e176509dd7ab3894f2
parent94de3e05dbde532c58791bac7f15266d896d3663 (diff)
downloadchromium_src-62652e21448df2b0e49aca6c69c3d65896188810.zip
chromium_src-62652e21448df2b0e49aca6c69c3d65896188810.tar.gz
chromium_src-62652e21448df2b0e49aca6c69c3d65896188810.tar.bz2
Add dynamic library stubs for XPC in //sandbox/mac.
BUG=382931 R=mark@chromium.org,brettw@chromium.org Review URL: https://codereview.chromium.org/331693003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277589 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--sandbox/mac/BUILD.gn28
-rw-r--r--sandbox/mac/sandbox_mac.gypi39
-rw-r--r--sandbox/mac/xpc.h40
-rw-r--r--sandbox/mac/xpc_private_stubs.sig17
-rw-r--r--sandbox/mac/xpc_stubs.sig16
-rw-r--r--sandbox/mac/xpc_stubs_header.fragment27
6 files changed, 167 insertions, 0 deletions
diff --git a/sandbox/mac/BUILD.gn b/sandbox/mac/BUILD.gn
index 9298837..e615197 100644
--- a/sandbox/mac/BUILD.gn
+++ b/sandbox/mac/BUILD.gn
@@ -14,6 +14,7 @@ component("sandbox") {
"os_compatibility.h",
"policy.cc",
"policy.h",
+ "xpc.h",
]
defines = [ "SANDBOX_IMPLEMENTATION" ]
@@ -21,9 +22,36 @@ component("sandbox") {
deps = [
"//base",
+ ":generate_stubs",
]
}
+generate_stubs_script = "//tools/generate_stubs/generate_stubs.py"
+generate_stubs_header = "xpc_stubs_header.fragment"
+generate_stubs_sig_public = "xpc_stubs.sig"
+generate_stubs_sig_private = "xpc_private_stubs.sig"
+generate_stubs_project = "sandbox/mac"
+generate_stubs_output_stem = "xpc_stubs"
+
+action("generate_stubs") {
+ script = generate_stubs_script
+ sources = [ generate_stubs_sig_public, generate_stubs_sig_private ]
+ source_prereqs = [ generate_stubs_header ]
+ outputs = [
+ "$target_gen_dir/$generate_stubs_output_stem.cc",
+ "$target_gen_dir/$generate_stubs_output_stem.h",
+ ]
+ args = [
+ "-i", rebase_path(target_gen_dir, root_build_dir),
+ "-o", rebase_path(target_gen_dir, root_build_dir),
+ "-t", "posix_stubs",
+ "-e", rebase_path(generate_stubs_header, root_build_dir),
+ "-s", generate_stubs_output_stem,
+ "-p", generate_stubs_project,
+ ]
+ args += rebase_path(sources, root_build_dir)
+}
+
test("sandbox_mac_unittests") {
sources = [
"bootstrap_sandbox_unittest.mm",
diff --git a/sandbox/mac/sandbox_mac.gypi b/sandbox/mac/sandbox_mac.gypi
index cccfdda..bf9e29d 100644
--- a/sandbox/mac/sandbox_mac.gypi
+++ b/sandbox/mac/sandbox_mac.gypi
@@ -18,12 +18,14 @@
'os_compatibility.h',
'policy.cc',
'policy.h',
+ 'xpc.h',
],
'dependencies': [
'../base/base.gyp:base',
],
'include_dirs': [
'..',
+ '<(SHARED_INTERMEDIATE_DIR)',
],
'defines': [
'SANDBOX_IMPLEMENTATION',
@@ -33,6 +35,43 @@
'$(SDKROOT)/usr/lib/libbsm.dylib',
],
},
+ 'actions': [
+ {
+ 'variables': {
+ 'generate_stubs_script': '../tools/generate_stubs/generate_stubs.py',
+ 'generate_stubs_header_path': 'xpc_stubs_header.fragment',
+ 'generate_stubs_sig_public_path': 'xpc_stubs.sig',
+ 'generate_stubs_sig_private_path': 'xpc_private_stubs.sig',
+ 'generate_stubs_project': 'sandbox/mac',
+ 'generate_stubs_output_stem': 'xpc_stubs',
+ },
+ 'action_name': 'generate_stubs',
+ 'inputs': [
+ '<(generate_stubs_script)',
+ '<(generate_stubs_header_path)',
+ '<(generate_stubs_sig_public_path)',
+ '<(generate_stubs_sig_private_path)',
+ ],
+ 'outputs': [
+ '<(INTERMEDIATE_DIR)/<(generate_stubs_output_stem).cc',
+ '<(INTERMEDIATE_DIR)/<(generate_stubs_project)/<(generate_stubs_output_stem).h',
+ ],
+ 'action': [
+ 'python',
+ '<(generate_stubs_script)',
+ '-i', '<(INTERMEDIATE_DIR)',
+ '-o', '<(SHARED_INTERMEDIATE_DIR)/<(generate_stubs_project)',
+ '-t', 'posix_stubs',
+ '-e', '<(generate_stubs_header_path)',
+ '-s', '<(generate_stubs_output_stem)',
+ '-p', '<(generate_stubs_project)',
+ '<(generate_stubs_sig_public_path)',
+ '<(generate_stubs_sig_private_path)',
+ ],
+ 'process_outputs_as_sources': 1,
+ 'message': 'Generating XPC stubs for 10.6 compatability.',
+ },
+ ],
},
{
'target_name': 'sandbox_mac_unittests',
diff --git a/sandbox/mac/xpc.h b/sandbox/mac/xpc.h
new file mode 100644
index 0000000..1cbe9ca
--- /dev/null
+++ b/sandbox/mac/xpc.h
@@ -0,0 +1,40 @@
+// Copyright 2014 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.
+
+// This file provides forward declarations for XPC symbols that are not
+// present in the 10.6 SDK. It uses generate_stubs to produce code to
+// dynamically load the libxpc.dylib library and set up a stub table, with
+// the same names as the real XPC functions.
+
+#ifndef SANDBOX_MAC_XPC_H_
+#define SANDBOX_MAC_XPC_H_
+
+#include <mach/mach.h>
+
+// C++ library loader.
+#include "sandbox/mac/xpc_stubs.h"
+
+// Declares XPC object types. This includes <xpc/xpc.h> if available.
+#include "sandbox/mac/xpc_stubs_header.fragment"
+
+#if !defined(MAC_OS_X_VERSION_10_7) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+
+extern "C" {
+// Signatures for XPC public functions that are loaded by xpc_stubs.h.
+#include "sandbox/mac/xpc_stubs.sig"
+// Signatures for private XPC functions.
+#include "sandbox/mac/xpc_private_stubs.sig"
+} // extern "C"
+
+#else
+
+// Signatures for private XPC functions.
+extern "C" {
+#include "sandbox/mac/xpc_private_stubs.sig"
+} // extern "C"
+
+#endif
+
+#endif // SANDBOX_MAC_XPC_H_
diff --git a/sandbox/mac/xpc_private_stubs.sig b/sandbox/mac/xpc_private_stubs.sig
new file mode 100644
index 0000000..33db194
--- /dev/null
+++ b/sandbox/mac/xpc_private_stubs.sig
@@ -0,0 +1,17 @@
+// Copyright 2014 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.
+
+// This file contains declarations of private XPC functions. This file is
+// used for both forward declarations of private symbols and to use with
+// tools/generate_stubs for creating a dynamic library loader.
+
+// Dictionary manipulation.
+void xpc_dictionary_set_mach_send(xpc_object_t dict, const char* name, mach_port_t port);
+
+// Pipe methods.
+xpc_pipe_t xpc_pipe_create_from_port(mach_port_t port, int flags);
+int xpc_pipe_receive(mach_port_t port, xpc_object_t* message);
+int xpc_pipe_routine(xpc_pipe_t pipe, xpc_object_t request, xpc_object_t* reply);
+int xpc_pipe_routine_reply(xpc_object_t reply);
+int xpc_pipe_routine_forward(xpc_pipe_t forward_to, xpc_object_t request);
diff --git a/sandbox/mac/xpc_stubs.sig b/sandbox/mac/xpc_stubs.sig
new file mode 100644
index 0000000..5020ffd
--- /dev/null
+++ b/sandbox/mac/xpc_stubs.sig
@@ -0,0 +1,16 @@
+// Copyright 2014 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.
+
+// This file contains declarations of public XPC functions used in the sandbox.
+// This file is used with tools/generate_stubs for creating a dynamic library
+// loader.
+
+// XPC object management.
+void xpc_release(xpc_object_t object);
+
+// Dictionary manipulation.
+const char* xpc_dictionary_get_string(xpc_object_t dictionary, const char* key);
+uint64_t xpc_dictionary_get_uint64(xpc_object_t dictionary, const char* key);
+void xpc_dictionary_set_int64(xpc_object_t dictionary, const char* key, int64_t value);
+xpc_object_t xpc_dictionary_create_reply(xpc_object_t request);
diff --git a/sandbox/mac/xpc_stubs_header.fragment b/sandbox/mac/xpc_stubs_header.fragment
new file mode 100644
index 0000000..a29907e
--- /dev/null
+++ b/sandbox/mac/xpc_stubs_header.fragment
@@ -0,0 +1,27 @@
+// Copyright 2014 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 SANDBOX_MAC_XPC_STUBS_HEADER_FRAGMENT_
+#define SANDBOX_MAC_XPC_STUBS_HEADER_FRAGMENT_
+
+// Declare or include public types.
+#if !defined(MAC_OS_X_VERSION_10_7) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+
+extern "C" {
+typedef void* xpc_object_t;
+} // extern "C"
+
+#else
+
+#include <xpc/xpc.h>
+
+#endif
+
+// Declare private types.
+extern "C" {
+typedef struct _xpc_pipe_s* xpc_pipe_t;
+} // extern "C"
+
+#endif // SANDBOX_MAC_XPC_STUBS_HEADER_FRAGMENT_