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

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

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp