aboutsummaryrefslogtreecommitdiffstats
path: root/arch/csky/kernel/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/csky/kernel/module.c')
-rw-r--r--arch/csky/kernel/module.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/arch/csky/kernel/module.c b/arch/csky/kernel/module.c
index 65abab0c7a47..b5ad7d9de18c 100644
--- a/arch/csky/kernel/module.c
+++ b/arch/csky/kernel/module.c
@@ -12,7 +12,7 @@
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <asm/pgtable.h> 13#include <asm/pgtable.h>
14 14
15#if defined(__CSKYABIV2__) 15#ifdef CONFIG_CPU_CK810
16#define IS_BSR32(hi16, lo16) (((hi16) & 0xFC00) == 0xE000) 16#define IS_BSR32(hi16, lo16) (((hi16) & 0xFC00) == 0xE000)
17#define IS_JSRI32(hi16, lo16) ((hi16) == 0xEAE0) 17#define IS_JSRI32(hi16, lo16) ((hi16) == 0xEAE0)
18 18
@@ -25,6 +25,26 @@
25 *(uint16_t *)(addr) = 0xE8Fa; \ 25 *(uint16_t *)(addr) = 0xE8Fa; \
26 *((uint16_t *)(addr) + 1) = 0x0000; \ 26 *((uint16_t *)(addr) + 1) = 0x0000; \
27} while (0) 27} while (0)
28
29static void jsri_2_lrw_jsr(uint32_t *location)
30{
31 uint16_t *location_tmp = (uint16_t *)location;
32
33 if (IS_BSR32(*location_tmp, *(location_tmp + 1)))
34 return;
35
36 if (IS_JSRI32(*location_tmp, *(location_tmp + 1))) {
37 /* jsri 0x... --> lrw r26, 0x... */
38 CHANGE_JSRI_TO_LRW(location);
39 /* lsli r0, r0 --> jsr r26 */
40 SET_JSR32_R26(location + 1);
41 }
42}
43#else
44static void inline jsri_2_lrw_jsr(uint32_t *location)
45{
46 return;
47}
28#endif 48#endif
29 49
30int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, 50int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
@@ -35,9 +55,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
35 Elf32_Sym *sym; 55 Elf32_Sym *sym;
36 uint32_t *location; 56 uint32_t *location;
37 short *temp; 57 short *temp;
38#if defined(__CSKYABIV2__)
39 uint16_t *location_tmp;
40#endif
41 58
42 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { 59 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
43 /* This is where to make the change */ 60 /* This is where to make the change */
@@ -59,18 +76,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
59 case R_CSKY_PCRELJSR_IMM11BY2: 76 case R_CSKY_PCRELJSR_IMM11BY2:
60 break; 77 break;
61 case R_CSKY_PCRELJSR_IMM26BY2: 78 case R_CSKY_PCRELJSR_IMM26BY2:
62#if defined(__CSKYABIV2__) 79 jsri_2_lrw_jsr(location);
63 location_tmp = (uint16_t *)location;
64 if (IS_BSR32(*location_tmp, *(location_tmp + 1)))
65 break;
66
67 if (IS_JSRI32(*location_tmp, *(location_tmp + 1))) {
68 /* jsri 0x... --> lrw r26, 0x... */
69 CHANGE_JSRI_TO_LRW(location);
70 /* lsli r0, r0 --> jsr r26 */
71 SET_JSR32_R26(location + 1);
72 }
73#endif
74 break; 80 break;
75 case R_CSKY_ADDR_HI16: 81 case R_CSKY_ADDR_HI16:
76 temp = ((short *)location) + 1; 82 temp = ((short *)location) + 1;