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

Side by Side Diff: third_party/android_crazy_linker/src/tests/test_load_library_depends.cpp

Issue 322433006: Fork of the Android NDK crazy linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a required license header to a cpp module, missing in the original. Created 6 years, 6 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
(Empty)
1 // Copyright (c) 2013 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.
4
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.
11
12 #include <stdio.h>
13 #include <crazy_linker.h>
14
15 #include "test_util.h"
16
17 typedef void (*FunctionPtr)();
18
19 int main() {
20 crazy_context_t* context = crazy_context_create();
21 crazy_library_t* library;
22
23 // DEBUG
24 crazy_context_set_load_address(context, 0x20000000);
25
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));
29 }
30
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");
36 }
37
38 // Call it.
39 (*bar_func)();
40
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");
46 }
47
48 // Close the library.
49 printf("Closing libbar.so\n");
50 crazy_library_close(library);
51
52 crazy_context_destroy(context);
53
54 return 0;
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698