Revert "Omit calls to set composing region when pasting image."
[chromium-blink-merge.git] / third_party / android_crazy_linker / src / tests / test_load_library.cpp
blob7f7bd7397b78bcbff16a429efebb5488fe9d1967
1 // Copyright 2014 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.
5 // A crazy linker test to:
6 // - Load a library (libfoo.so) with the linker.
7 // - Find the address of the "Foo" function in it.
8 // - Call the function.
9 // - Close the library.
11 #include <stdio.h>
12 #include <crazy_linker.h>
14 #include "test_util.h"
16 typedef void (*FunctionPtr)();
18 int main() {
19 crazy_context_t* context = crazy_context_create();
20 crazy_library_t* library;
22 // DEBUG
23 crazy_context_set_load_address(context, 0x20000000);
25 // Load libfoo.so
26 if (!crazy_library_open(&library, "libfoo.so", context)) {
27 Panic("Could not open library: %s\n", crazy_context_get_error(context));
30 // Find the "Foo" symbol.
31 FunctionPtr foo_func;
32 if (!crazy_library_find_symbol(
33 library, "Foo", reinterpret_cast<void**>(&foo_func))) {
34 Panic("Could not find 'Foo' in libfoo.so\n");
37 // Call it.
38 (*foo_func)();
40 // Close the library.
41 printf("Closing libfoo.so\n");
42 crazy_library_close(library);
44 crazy_context_destroy(context);
46 return 0;