Commit | Line | Data |
---|---|---|
5a673446 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
5a673446 | 3 | * |
c0c0989a | 4 | * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
5a673446 | 5 | */ |
3227b2b9 MD |
6 | |
7 | #include <stdbool.h> | |
5a673446 MD |
8 | #include "tap.h" |
9 | ||
10 | #define NUM_TESTS 2 | |
11 | ||
3227b2b9 MD |
12 | int testint __attribute__((weak, visibility("hidden"))); |
13 | void *testptr __attribute__((weak, visibility("hidden"))); | |
14 | struct { | |
15 | char a[24]; | |
16 | } testsym_24_bytes __attribute__((weak, visibility("hidden"))); | |
17 | ||
18 | void *testfct_int(void); | |
19 | void *testfct_ptr(void); | |
20 | void *testfct_24_bytes(void); | |
21 | ||
22 | void *testlibfct1_int(void); | |
23 | void *testlibfct1_ptr(void); | |
24 | void *testlibfct1_24_bytes(void); | |
25 | ||
26 | void *testlibfct2_int(void); | |
27 | void *testlibfct2_ptr(void); | |
28 | void *testlibfct2_24_bytes(void); | |
29 | ||
30 | enum { | |
31 | MATCH_PROGRAM_INT, | |
32 | MATCH_PROGRAM_PTR, | |
33 | MATCH_PROGRAM_24_BYTES, | |
34 | MATCH_LIB_INT, | |
35 | MATCH_LIB_PTR, | |
36 | MATCH_LIB_24_BYTES, | |
37 | NR_MATCH, | |
38 | }; | |
5a673446 | 39 | |
3227b2b9 | 40 | static bool match_matrix[NR_MATCH]; |
5a673446 MD |
41 | |
42 | int main() | |
43 | { | |
44 | plan_tests(NUM_TESTS); | |
3227b2b9 MD |
45 | |
46 | if (testfct_int() == &testint) | |
47 | match_matrix[MATCH_PROGRAM_INT] = true; | |
48 | if (testfct_ptr() == &testptr) | |
49 | match_matrix[MATCH_PROGRAM_PTR] = true; | |
50 | if (testfct_24_bytes() == &testsym_24_bytes) | |
51 | match_matrix[MATCH_PROGRAM_24_BYTES] = true; | |
52 | ||
53 | if (testlibfct1_int() == testlibfct2_int()) | |
54 | match_matrix[MATCH_LIB_INT] = true; | |
55 | if (testlibfct1_ptr() == testlibfct2_ptr()) | |
56 | match_matrix[MATCH_LIB_PTR] = true; | |
57 | if (testlibfct1_24_bytes() == testlibfct2_24_bytes()) | |
58 | match_matrix[MATCH_LIB_24_BYTES] = true; | |
59 | ||
60 | diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (4 bytes integer object)", | |
61 | match_matrix[MATCH_PROGRAM_INT] ? "match" : "MISMATCH"); | |
62 | diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (pointer object)", | |
63 | match_matrix[MATCH_PROGRAM_PTR] ? "match" : "MISMATCH"); | |
64 | diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (24 bytes structure object)", | |
65 | match_matrix[MATCH_PROGRAM_24_BYTES] ? "match" : "MISMATCH"); | |
66 | ||
67 | diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (4 bytes integer object)", | |
68 | match_matrix[MATCH_LIB_INT] ? "match" : "MISMATCH"); | |
69 | diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (pointer object)", | |
70 | match_matrix[MATCH_LIB_PTR] ? "match" : "MISMATCH"); | |
71 | diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (24 bytes structure object)", | |
72 | match_matrix[MATCH_LIB_24_BYTES] ? "match" : "MISMATCH"); | |
73 | ||
c62783e7 MD |
74 | ok(match_matrix[MATCH_PROGRAM_INT] == match_matrix[MATCH_PROGRAM_PTR], |
75 | "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within main program"); | |
76 | ok(match_matrix[MATCH_LIB_INT] == match_matrix[MATCH_LIB_PTR], | |
77 | "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within shared library"); | |
bf746e7d MJ |
78 | |
79 | return exit_status(); | |
5a673446 | 80 | } |