diff --git a/cc/native_sdk/BUILD b/cc/native_sdk/BUILD index a6bd2afcbc8..a8835f2b27f 100644 --- a/cc/native_sdk/BUILD +++ b/cc/native_sdk/BUILD @@ -36,8 +36,10 @@ cc_library( cc_binary( name = "key_value_lookup", srcs = ["key_value_lookup.cc"], + linkopts = ["-Wl,--version-script,$(location symbols.map.ld)"], linkshared = True, deps = [ + "symbols.map.ld", ":native_sdk", "@com_google_absl//absl/log:check", ], diff --git a/cc/native_sdk/native_sdk.h b/cc/native_sdk/native_sdk.h index 2d88be56193..f98b622a595 100644 --- a/cc/native_sdk/native_sdk.h +++ b/cc/native_sdk/native_sdk.h @@ -26,7 +26,7 @@ // We call oak_main without arguments, and oak_main then calls read_request, // processes the request, and then calls write_response. This makes the API // compatible with Oak Functions. -#define OAK_MAIN void oak_main() +#define OAK_MAIN extern "C" void oak_main() namespace oak::functions::sdk { diff --git a/cc/native_sdk/symbols.map.ld b/cc/native_sdk/symbols.map.ld new file mode 100644 index 00000000000..c67a82a81d7 --- /dev/null +++ b/cc/native_sdk/symbols.map.ld @@ -0,0 +1,7 @@ +{ + global: + register_callbacks; + oak_main; + local: + *; +};