Revert "Omit calls to set composing region when pasting image."
[chromium-blink-merge.git] / third_party / android_crazy_linker / src / tests / test_load_library_depends.cpp
blob9c2504eced81aac61e2a4cd61fb68fdd0c992b48
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 (libbar.so) with the linker, which depends on
7 // another library (libfoo.so)
8 // - Find the address of the "Bar" function in libbar.so.
9 // - Call the Bar() function, which ends up calling Foo() in libfoo.so
10 // - Close the library.
12 #include <stdio.h>
13 #include <crazy_linker.h>
15 #include "test_util.h"
17 typedef void (*FunctionPtr)();
19 int main() {
20 crazy_context_t* context = crazy_context_create();
21 crazy_library_t* library;
23 // DEBUG
24 crazy_context_set_load_address(context, 0x20000000);
26 // Load libbar.so
27 if (!crazy_library_open(&library, "libbar.so", context)) {
28 Panic("Could not open library: %s\n", crazy_context_get_error(context));
31 // Find the "Bar" symbol.
32 FunctionPtr bar_func;
33 if (!crazy_library_find_symbol(
34 library, "Bar", reinterpret_cast<void**>(&bar_func))) {
35 Panic("Could not find 'Bar' in libbar.so\n");
38 // Call it.
39 (*bar_func)();
41 // Find the "Foo" symbol from libbar.so
42 FunctionPtr foo_func;
43 if (!crazy_library_find_symbol(
44 library, "Foo", reinterpret_cast<void**>(&foo_func))) {
45 Panic("Could not find 'Foo' from libbar.so\n");
48 // Close the library.
49 printf("Closing libbar.so\n");
50 crazy_library_close(library);
52 crazy_context_destroy(context);
54 return 0;