1 | /*
|
---|
2 | * Copyright (c) 2016 Jiri Svoboda
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup libdltest
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /** @file
|
---|
33 | */
|
---|
34 |
|
---|
35 | #include <fibril.h>
|
---|
36 | #include "libdltest.h"
|
---|
37 |
|
---|
38 | /** Private initialized variable */
|
---|
39 | static int private_var = dl_private_var_val;
|
---|
40 | /** Private uninitialized variable */
|
---|
41 | static int private_uvar;
|
---|
42 |
|
---|
43 | /** Public initialized variable */
|
---|
44 | int dl_public_var = dl_public_var_val;
|
---|
45 | /** Public uninitialized variable */
|
---|
46 | int dl_public_uvar;
|
---|
47 |
|
---|
48 | /** Private initialized fibril-local variable */
|
---|
49 | static fibril_local int dl_private_fib_var = dl_private_fib_var_val;
|
---|
50 | /** Private uninitialized fibril-local variable */
|
---|
51 | static fibril_local int dl_private_fib_uvar;
|
---|
52 |
|
---|
53 | /** Public initialized fibril-local variable */
|
---|
54 | fibril_local int dl_public_fib_var = dl_public_fib_var_val;
|
---|
55 | /** Public uninitialized fibril-local variable */
|
---|
56 | fibril_local int dl_public_fib_uvar;
|
---|
57 |
|
---|
58 | /** Return constant value. */
|
---|
59 | int dl_get_constant(void)
|
---|
60 | {
|
---|
61 | return dl_constant;
|
---|
62 | }
|
---|
63 |
|
---|
64 | /** Return constant value by calling another function.
|
---|
65 | *
|
---|
66 | * This can be used to test dynamically linked call (via PLT) even in case
|
---|
67 | * binaries are statically linked.
|
---|
68 | */
|
---|
69 | int dl_get_constant_via_call(void)
|
---|
70 | {
|
---|
71 | return dl_get_constant();
|
---|
72 | }
|
---|
73 |
|
---|
74 | /** Return value of private initialized variable */
|
---|
75 | int dl_get_private_var(void)
|
---|
76 | {
|
---|
77 | return private_var;
|
---|
78 | }
|
---|
79 |
|
---|
80 | /** Return address of private initialized variable */
|
---|
81 | int *dl_get_private_var_addr(void)
|
---|
82 | {
|
---|
83 | return &private_var;
|
---|
84 | }
|
---|
85 |
|
---|
86 | /** Return value of private uninitialized variable */
|
---|
87 | int dl_get_private_uvar(void)
|
---|
88 | {
|
---|
89 | return private_uvar;
|
---|
90 | }
|
---|
91 |
|
---|
92 | /** Return vaddress of private uninitialized variable */
|
---|
93 | int *dl_get_private_uvar_addr(void)
|
---|
94 | {
|
---|
95 | return &private_uvar;
|
---|
96 | }
|
---|
97 |
|
---|
98 | /** Return value of public initialized variable */
|
---|
99 | int dl_get_public_var(void)
|
---|
100 | {
|
---|
101 | return dl_public_var;
|
---|
102 | }
|
---|
103 |
|
---|
104 | /** Return address of public initialized variable */
|
---|
105 | int *dl_get_public_var_addr(void)
|
---|
106 | {
|
---|
107 | return &dl_public_var;
|
---|
108 | }
|
---|
109 |
|
---|
110 | /** Return value of public uninitialized variable */
|
---|
111 | int dl_get_public_uvar(void)
|
---|
112 | {
|
---|
113 | return dl_public_uvar;
|
---|
114 | }
|
---|
115 |
|
---|
116 | /** Return address of public uninitialized variable */
|
---|
117 | int *dl_get_public_uvar_addr(void)
|
---|
118 | {
|
---|
119 | return &dl_public_uvar;
|
---|
120 | }
|
---|
121 |
|
---|
122 | /** Return value of private initialized fibril-local variable */
|
---|
123 | int dl_get_private_fib_var(void)
|
---|
124 | {
|
---|
125 | return dl_private_fib_var;
|
---|
126 | }
|
---|
127 |
|
---|
128 | /** Return address of private initialized fibril-local variable */
|
---|
129 | int *dl_get_private_fib_var_addr(void)
|
---|
130 | {
|
---|
131 | return &dl_private_fib_var;
|
---|
132 | }
|
---|
133 |
|
---|
134 | /** Return value of private uninitialized fibril-local variable */
|
---|
135 | int dl_get_private_fib_uvar(void)
|
---|
136 | {
|
---|
137 | return dl_private_fib_uvar;
|
---|
138 | }
|
---|
139 |
|
---|
140 | /** Return address of private uninitialized fibril-local variable */
|
---|
141 | int *dl_get_private_fib_uvar_addr(void)
|
---|
142 | {
|
---|
143 | return &dl_private_fib_uvar;
|
---|
144 | }
|
---|
145 |
|
---|
146 | /** Return value of public initialized fibril-local variable */
|
---|
147 | int dl_get_public_fib_var(void)
|
---|
148 | {
|
---|
149 | return dl_public_fib_var;
|
---|
150 | }
|
---|
151 |
|
---|
152 | /** Return value of public initialized fibril-local variable */
|
---|
153 | int *dl_get_public_fib_var_addr(void)
|
---|
154 | {
|
---|
155 | return &dl_public_fib_var;
|
---|
156 | }
|
---|
157 |
|
---|
158 | /** Return value of public uninitialized fibril-local variable */
|
---|
159 | int dl_get_public_fib_uvar(void)
|
---|
160 | {
|
---|
161 | return dl_public_fib_uvar;
|
---|
162 | }
|
---|
163 |
|
---|
164 | /** Return value of public uninitialized fibril-local variable */
|
---|
165 | int *dl_get_public_fib_uvar_addr(void)
|
---|
166 | {
|
---|
167 | return &dl_public_fib_uvar;
|
---|
168 | }
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * @}
|
---|
172 | */
|
---|