]> git.saurik.com Git - apple/ld64.git/blob - FireOpal/unit-tests/test-cases/relocs-c2/test.c
ld64-85.2.1.tar.gz
[apple/ld64.git] / FireOpal / unit-tests / test-cases / relocs-c2 / test.c
1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
2 *
3 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25 static int foo;
26
27 int __attribute__((visibility("hidden"))) foofoo;
28
29 static int uninit_static;
30 static int init_static = 1;
31 int __attribute__((visibility("hidden"))) uninit_hidden;
32 int __attribute__((visibility("hidden"))) init_hidden = 1;
33 int uninit_global;
34 int init_global = 1;
35 extern int extern_global;
36 extern int __attribute__((visibility("hidden"))) extern_hidden;
37
38 static int uninit_static_array[4];
39 static int init_static_array[4] = {1,2,3,4};
40 int __attribute__((visibility("hidden"))) uninit_hidden_array[4];
41 int __attribute__((visibility("hidden"))) init_hidden_array[4] = {1,2,3,4};
42 int uninit_global_array[4];
43 int init_global_array[4] = {1,2,3,4};
44 extern int extern_global_array[4];
45
46 int test1() { return uninit_static; }
47 int test2() { return init_static; }
48 int test3() { return uninit_hidden; }
49 int test4() { return init_hidden; }
50 int test5() { return uninit_global; }
51 int test6() { return init_global; }
52 int test7() { return extern_global; }
53 int test8() { return extern_hidden; }
54
55 int test_array1() { return uninit_static_array[2]; }
56 int test_array2() { return init_static_array[2]; }
57 int test_array3() { return uninit_hidden_array[2]; }
58 int test_array4() { return init_hidden_array[2]; }
59 int test_array5() { return uninit_global_array[2]; }
60 int test_array6() { return init_global_array[2]; }
61 int test_array7() { return extern_global_array[2]; }
62
63 static int foo2;
64 int test9() { return foo2; }
65
66
67 int* p_init_global = &init_global;
68 void* p_test1 = (void*)&test1;
69 unsigned char pad = 2;
70 unsigned char pad2 = 3; // this padding throws off alignment on compiler generated anonymous non-lazy pointers...
71
72 int func() __attribute__((visibility("hidden")));
73 int func() { return foo; }
74
75 int func2() { return func() + 1; }
76