Skip to content

Commit f553aa1

Browse files
committed
csky: fixup relocation error with 807 & 860
810 doesn't support jsri instruction and csky-as will leave jsri + nop for relocation. Module-probe need replace them with lrw + jsr. Signed-off-by: Guo Ren <ren_guo@c-sky.com> Cc: Hui Kai <huikai@acoinfo.com>
1 parent 8a5aaf9 commit f553aa1

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

‎arch/csky/kernel/module.c‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <linux/spinlock.h>
1313
#include <asm/pgtable.h>
1414

15-
#if defined(__CSKYABIV2__)
15+
#ifdef CONFIG_CPU_CK810
1616
#define IS_BSR32(hi16, lo16) (((hi16) & 0xFC00) == 0xE000)
1717
#define IS_JSRI32(hi16, lo16) ((hi16) == 0xEAE0)
1818

@@ -25,6 +25,26 @@
2525
*(uint16_t *)(addr) = 0xE8Fa; \
2626
*((uint16_t *)(addr) + 1) = 0x0000; \
2727
} while (0)
28+
29+
static 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
44+
static void inline jsri_2_lrw_jsr(uint32_t *location)
45+
{
46+
return;
47+
}
2848
#endif
2949

3050
int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
@@ -35,9 +55,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
3555
Elf32_Sym *sym;
3656
uint32_t *location;
3757
short *temp;
38-
#if defined(__CSKYABIV2__)
39-
uint16_t *location_tmp;
40-
#endif
4158

4259
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
4360
/* This is where to make the change */
@@ -59,18 +76,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
5976
case R_CSKY_PCRELJSR_IMM11BY2:
6077
break;
6178
case R_CSKY_PCRELJSR_IMM26BY2:
62-
#if defined(__CSKYABIV2__)
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
79+
jsri_2_lrw_jsr(location);
7480
break;
7581
case R_CSKY_ADDR_HI16:
7682
temp = ((short *)location) + 1;

0 commit comments

Comments
 (0)