1 #include <stdio.h>
2
3 #include "protected-data-1.h"
4
5 int protected_data_1b = 3;
6
7 int
8 main (void)
9 {
10 int res = 0;
11
12 /* Check if we get the same address for the protected data symbol. */
13 if (&protected_data_1a != protected_data_1a_p ())
14 {
15 puts ("'protected_data_1a' in main and shared library doesn't have same address");
16 res = 1;
17 }
18
19 protected_data_1a = -1;
20 if (check_protected_data_1a (-1))
21 {
22 puts ("'protected_data_1a' in main and shared library doesn't have same value");
23 res = 1;
24 }
25
26 set_protected_data_1a (-3);
27 if (protected_data_1a != -3)
28 {
29 puts ("'protected_data_1a' in main and shared library doesn't have same value");
30 res = 1;
31 }
32
33 /* Check if we get the different addresses for the protected data
34 symbol. */
35 if (&protected_data_1b == protected_data_1b_p ())
36 {
37 puts ("'protected_data_1b' in main and shared library has same address");
38 res = 1;
39 }
40
41 protected_data_1b = -10;
42 if (check_protected_data_1b (2))
43 {
44 puts ("'protected_data_1b' in main and shared library has same address");
45 res = 1;
46 }
47
48 set_protected_data_1b (-30);
49 if (protected_data_1b != -10)
50 {
51 puts ("'protected_data_1b' in main and shared library has same address");
52 res = 1;
53 }
54
55 if (!res)
56 puts ("PASS");
57
58 return res;
59 }