]> git.saurik.com Git - apple/ld64.git/blame - unit-tests/test-cases/relocs-c2/test.c
ld64-409.12.tar.gz
[apple/ld64.git] / unit-tests / test-cases / relocs-c2 / test.c
CommitLineData
a61fdf0a
A
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
25static int foo;
26
27int __attribute__((visibility("hidden"))) foofoo;
28
29static int uninit_static;
30static 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;
35extern int extern_global;
36extern int __attribute__((visibility("hidden"))) extern_hidden;
37
38static int uninit_static_array[4];
39static 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};
44extern int extern_global_array[4];
45
46int test1() { return uninit_static; }
47int test2() { return init_static; }
48int test3() { return uninit_hidden; }
49int test4() { return init_hidden; }
50int test5() { return uninit_global; }
51int test6() { return init_global; }
52int test7() { return extern_global; }
53int test8() { return extern_hidden; }
54
55int test_array1() { return uninit_static_array[2]; }
56int test_array2() { return init_static_array[2]; }
57int test_array3() { return uninit_hidden_array[2]; }
58int test_array4() { return init_hidden_array[2]; }
59int test_array5() { return uninit_global_array[2]; }
60int test_array6() { return init_global_array[2]; }
61int test_array7() { return extern_global_array[2]; }
62
63static int foo2;
64int test9() { return foo2; }
65
66
67int* p_init_global = &init_global;
68void* p_test1 = (void*)&test1;
69unsigned char pad = 2;
70unsigned char pad2 = 3; // this padding throws off alignment on compiler generated anonymous non-lazy pointers...
71
72int func() __attribute__((visibility("hidden")));
73int func() { return foo; }
74
75int func2() { return func() + 1; }
76