~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/kernel/reloc_test_core.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) 2017 Linaro, Ltd. <ard.biesheuvel@linaro.org>
  4  */
  5 
  6 #include <linux/module.h>
  7 
  8 int sym64_rel;
  9 
 10 #define SYM64_ABS_VAL           0xffff880000cccccc
 11 #define SYM32_ABS_VAL           0xf800cccc
 12 #define SYM16_ABS_VAL           0xf8cc
 13 
 14 #define __SET_ABS(name, val)    asm(".globl " #name "; .set "#name ", " #val)
 15 #define SET_ABS(name, val)      __SET_ABS(name, val)
 16 
 17 SET_ABS(sym64_abs, SYM64_ABS_VAL);
 18 SET_ABS(sym32_abs, SYM32_ABS_VAL);
 19 SET_ABS(sym16_abs, SYM16_ABS_VAL);
 20 
 21 asmlinkage u64 absolute_data64(void);
 22 asmlinkage u64 absolute_data32(void);
 23 asmlinkage u64 absolute_data16(void);
 24 asmlinkage u64 signed_movw(void);
 25 asmlinkage u64 unsigned_movw(void);
 26 asmlinkage u64 relative_adrp(void);
 27 asmlinkage u64 relative_adrp_far(void);
 28 asmlinkage u64 relative_adr(void);
 29 asmlinkage u64 relative_data64(void);
 30 asmlinkage u64 relative_data32(void);
 31 asmlinkage u64 relative_data16(void);
 32 
 33 static struct {
 34         char    name[32];
 35         u64     (*f)(void);
 36         u64     expect;
 37 } const funcs[] = {
 38         { "R_AARCH64_ABS64",            absolute_data64, UL(SYM64_ABS_VAL) },
 39         { "R_AARCH64_ABS32",            absolute_data32, UL(SYM32_ABS_VAL) },
 40         { "R_AARCH64_ABS16",            absolute_data16, UL(SYM16_ABS_VAL) },
 41         { "R_AARCH64_MOVW_SABS_Gn",     signed_movw, UL(SYM64_ABS_VAL) },
 42         { "R_AARCH64_MOVW_UABS_Gn",     unsigned_movw, UL(SYM64_ABS_VAL) },
 43         { "R_AARCH64_ADR_PREL_PG_HI21", relative_adrp, (u64)&sym64_rel },
 44         { "R_AARCH64_ADR_PREL_PG_HI21", relative_adrp_far, (u64)&memstart_addr },
 45         { "R_AARCH64_ADR_PREL_LO21",    relative_adr, (u64)&sym64_rel },
 46         { "R_AARCH64_PREL64",           relative_data64, (u64)&sym64_rel },
 47         { "R_AARCH64_PREL32",           relative_data32, (u64)&sym64_rel },
 48         { "R_AARCH64_PREL16",           relative_data16, (u64)&sym64_rel },
 49 };
 50 
 51 static int __init reloc_test_init(void)
 52 {
 53         int i;
 54 
 55         pr_info("Relocation test:\n");
 56         pr_info("-------------------------------------------------------\n");
 57 
 58         for (i = 0; i < ARRAY_SIZE(funcs); i++) {
 59                 u64 ret = funcs[i].f();
 60 
 61                 pr_info("%-31s 0x%016llx %s\n", funcs[i].name, ret,
 62                         ret == funcs[i].expect ? "pass" : "fail");
 63                 if (ret != funcs[i].expect)
 64                         pr_err("Relocation failed, expected 0x%016llx, not 0x%016llx\n",
 65                                funcs[i].expect, ret);
 66         }
 67         return 0;
 68 }
 69 
 70 static void __exit reloc_test_exit(void)
 71 {
 72 }
 73 
 74 module_init(reloc_test_init);
 75 module_exit(reloc_test_exit);
 76 
 77 MODULE_DESCRIPTION("Relocation testing module");
 78 MODULE_LICENSE("GPL v2");
 79 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php