1 /*
2 * Copyright (C) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "functionalext.h"
16 #include "relocs_tests.h"
17
RelocTests_dyn_relocs()18 static void RelocTests_dyn_relocs() {
19 EXPECT_EQ(__func__, 5, relative_test());
20 EXPECT_EQ(__func__, 2, glob_dat_test());
21 EXPECT_EQ(__func__, 1, jump_slot_test());
22 }
23
RelocTests_abs_relocs()24 static void RelocTests_abs_relocs() { EXPECT_EQ(__func__, 3, abs64_test()); }
25
RelocTests_plt_relocs()26 static void RelocTests_plt_relocs() {
27 EXPECT_EQ(__func__, 1, jump26_test());
28 EXPECT_EQ(__func__, 1, call26_test());
29 EXPECT_EQ(__func__, 1, condbr19_test());
30 EXPECT_EQ(__func__, 1, tstbr14_test());
31 }
32
RelocTests_got_relocs()33 static void RelocTests_got_relocs() {
34 EXPECT_EQ(__func__, 1, ld64_got_lo12_nc_test());
35 EXPECT_EQ(__func__, 1, ld64_gotpage_lo15_test());
36 }
37
RelocTests_pc_relative_relocs()38 static void RelocTests_pc_relative_relocs() {
39 EXPECT_EQ(__func__, 1, adr_prel_pg_hi21_test());
40 EXPECT_EQ(__func__, 1, adr_prel_pg_hi21_nc_test());
41 EXPECT_EQ(__func__, 1, adr_prel_lo21_test());
42 EXPECT_EQ(__func__, 1, ld_prel_lo19_test());
43 }
44
RelocTests_null_relocs()45 static void RelocTests_null_relocs() { EXPECT_EQ(__func__, 0, none_test()); }
46
RelocTests_tlsdesc_relocs()47 static void RelocTests_tlsdesc_relocs() { EXPECT_EQ(__func__, 2, tlsdesc_test()); }
48
RelocTests_tls_dyn_relocs()49 static void RelocTests_tls_dyn_relocs() { EXPECT_EQ(__func__, 2, tls_tprel64_test()); }
50
RelocTests_tlsie_relocs()51 static void RelocTests_tlsie_relocs() { EXPECT_EQ(__func__, 2, tlsie_adr_ld64_test()); }
52
main(int argc,char ** argv)53 int main(int argc, char **argv) {
54 RelocTests_dyn_relocs();
55 RelocTests_abs_relocs();
56 RelocTests_plt_relocs();
57 RelocTests_got_relocs();
58 RelocTests_pc_relative_relocs();
59 RelocTests_null_relocs();
60 RelocTests_tlsdesc_relocs();
61 RelocTests_tls_dyn_relocs();
62 RelocTests_tlsie_relocs();
63 return t_status;
64 }
65