@@ -37,7 +37,7 @@ static int apply_r_riscv_64_rela(struct module *me, u32 *location, Elf_Addr v)
37
37
static int apply_r_riscv_branch_rela (struct module * me , u32 * location ,
38
38
Elf_Addr v )
39
39
{
40
- s64 offset = (void * )v - (void * )location ;
40
+ ptrdiff_t offset = (void * )v - (void * )location ;
41
41
u32 imm12 = (offset & 0x1000 ) << (31 - 12 );
42
42
u32 imm11 = (offset & 0x800 ) >> (11 - 7 );
43
43
u32 imm10_5 = (offset & 0x7e0 ) << (30 - 10 );
@@ -50,7 +50,7 @@ static int apply_r_riscv_branch_rela(struct module *me, u32 *location,
50
50
static int apply_r_riscv_jal_rela (struct module * me , u32 * location ,
51
51
Elf_Addr v )
52
52
{
53
- s64 offset = (void * )v - (void * )location ;
53
+ ptrdiff_t offset = (void * )v - (void * )location ;
54
54
u32 imm20 = (offset & 0x100000 ) << (31 - 20 );
55
55
u32 imm19_12 = (offset & 0xff000 );
56
56
u32 imm11 = (offset & 0x800 ) << (20 - 11 );
@@ -63,7 +63,7 @@ static int apply_r_riscv_jal_rela(struct module *me, u32 *location,
63
63
static int apply_r_riscv_rcv_branch_rela (struct module * me , u32 * location ,
64
64
Elf_Addr v )
65
65
{
66
- s64 offset = (void * )v - (void * )location ;
66
+ ptrdiff_t offset = (void * )v - (void * )location ;
67
67
u16 imm8 = (offset & 0x100 ) << (12 - 8 );
68
68
u16 imm7_6 = (offset & 0xc0 ) >> (6 - 5 );
69
69
u16 imm5 = (offset & 0x20 ) >> (5 - 2 );
@@ -78,7 +78,7 @@ static int apply_r_riscv_rcv_branch_rela(struct module *me, u32 *location,
78
78
static int apply_r_riscv_rvc_jump_rela (struct module * me , u32 * location ,
79
79
Elf_Addr v )
80
80
{
81
- s64 offset = (void * )v - (void * )location ;
81
+ ptrdiff_t offset = (void * )v - (void * )location ;
82
82
u16 imm11 = (offset & 0x800 ) << (12 - 11 );
83
83
u16 imm10 = (offset & 0x400 ) >> (10 - 8 );
84
84
u16 imm9_8 = (offset & 0x300 ) << (12 - 11 );
@@ -96,7 +96,7 @@ static int apply_r_riscv_rvc_jump_rela(struct module *me, u32 *location,
96
96
static int apply_r_riscv_pcrel_hi20_rela (struct module * me , u32 * location ,
97
97
Elf_Addr v )
98
98
{
99
- s64 offset = (void * )v - (void * )location ;
99
+ ptrdiff_t offset = (void * )v - (void * )location ;
100
100
s32 hi20 ;
101
101
102
102
if (offset != (s32 )offset ) {
@@ -178,7 +178,7 @@ static int apply_r_riscv_lo12_s_rela(struct module *me, u32 *location,
178
178
static int apply_r_riscv_got_hi20_rela (struct module * me , u32 * location ,
179
179
Elf_Addr v )
180
180
{
181
- s64 offset = (void * )v - (void * )location ;
181
+ ptrdiff_t offset = (void * )v - (void * )location ;
182
182
s32 hi20 ;
183
183
184
184
/* Always emit the got entry */
@@ -200,7 +200,7 @@ static int apply_r_riscv_got_hi20_rela(struct module *me, u32 *location,
200
200
static int apply_r_riscv_call_plt_rela (struct module * me , u32 * location ,
201
201
Elf_Addr v )
202
202
{
203
- s64 offset = (void * )v - (void * )location ;
203
+ ptrdiff_t offset = (void * )v - (void * )location ;
204
204
s32 fill_v = offset ;
205
205
u32 hi20 , lo12 ;
206
206
@@ -227,7 +227,7 @@ static int apply_r_riscv_call_plt_rela(struct module *me, u32 *location,
227
227
static int apply_r_riscv_call_rela (struct module * me , u32 * location ,
228
228
Elf_Addr v )
229
229
{
230
- s64 offset = (void * )v - (void * )location ;
230
+ ptrdiff_t offset = (void * )v - (void * )location ;
231
231
s32 fill_v = offset ;
232
232
u32 hi20 , lo12 ;
233
233
@@ -347,7 +347,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
347
347
unsigned int j ;
348
348
349
349
for (j = 0 ; j < sechdrs [relsec ].sh_size / sizeof (* rel ); j ++ ) {
350
- u64 hi20_loc =
350
+ unsigned long hi20_loc =
351
351
sechdrs [sechdrs [relsec ].sh_info ].sh_addr
352
352
+ rel [j ].r_offset ;
353
353
u32 hi20_type = ELF_RISCV_R_TYPE (rel [j ].r_info );
@@ -360,12 +360,12 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
360
360
Elf_Sym * hi20_sym =
361
361
(Elf_Sym * )sechdrs [symindex ].sh_addr
362
362
+ ELF_RISCV_R_SYM (rel [j ].r_info );
363
- u64 hi20_sym_val =
363
+ unsigned long hi20_sym_val =
364
364
hi20_sym -> st_value
365
365
+ rel [j ].r_addend ;
366
366
367
367
/* Calculate lo12 */
368
- u64 offset = hi20_sym_val - hi20_loc ;
368
+ size_t offset = hi20_sym_val - hi20_loc ;
369
369
if (IS_ENABLED (CONFIG_MODULE_SECTIONS )
370
370
&& hi20_type == R_RISCV_GOT_HI20 ) {
371
371
offset = module_emit_got_entry (
0 commit comments