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

Side by Side Diff: third_party/android_crazy_linker/src/tests/test_load_library.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 (libfoo.so) with the linker.
7 // - Find the address of the "Foo" function in it.
8 // - Call the function.
9 // - Close the library.
10
11 #include <stdio.h>
12 #include <crazy_linker.h>
13
14 #include "test_util.h"
15
16 typedef void (*FunctionPtr)();
17
18 int main() {
19 crazy_context_t* context = crazy_context_create();
20 crazy_library_t* library;
21
22 // DEBUG
23 crazy_context_set_load_address(context, 0x20000000);
24
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));
28 }
29
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");
35 }
36
37 // Call it.
38 (*foo_func)();
39
40 // Close the library.
41 printf("Closing libfoo.so\n");
42 crazy_library_close(library);
43
44 crazy_context_destroy(context);
45
46 return 0;
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698