@@ -169,8 +169,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
169
169
170
170
offset = __mem_to_opcode_arm (* (u32 * )loc );
171
171
offset = (offset & 0x00ffffff ) << 2 ;
172
- if (offset & 0x02000000 )
173
- offset -= 0x04000000 ;
172
+ offset = sign_extend32 (offset , 25 );
174
173
175
174
offset += sym -> st_value - loc ;
176
175
@@ -236,7 +235,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
236
235
case R_ARM_MOVT_PREL :
237
236
offset = tmp = __mem_to_opcode_arm (* (u32 * )loc );
238
237
offset = ((offset & 0xf0000 ) >> 4 ) | (offset & 0xfff );
239
- offset = (offset ^ 0x8000 ) - 0x8000 ;
238
+ offset = sign_extend32 (offset , 15 ) ;
240
239
241
240
offset += sym -> st_value ;
242
241
if (ELF32_R_TYPE (rel -> r_info ) == R_ARM_MOVT_PREL ||
@@ -344,8 +343,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
344
343
((~(j2 ^ sign ) & 1 ) << 22 ) |
345
344
((upper & 0x03ff ) << 12 ) |
346
345
((lower & 0x07ff ) << 1 );
347
- if (offset & 0x01000000 )
348
- offset -= 0x02000000 ;
346
+ offset = sign_extend32 (offset , 24 );
349
347
offset += sym -> st_value - loc ;
350
348
351
349
/*
@@ -401,7 +399,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
401
399
offset = ((upper & 0x000f ) << 12 ) |
402
400
((upper & 0x0400 ) << 1 ) |
403
401
((lower & 0x7000 ) >> 4 ) | (lower & 0x00ff );
404
- offset = (offset ^ 0x8000 ) - 0x8000 ;
402
+ offset = sign_extend32 (offset , 15 ) ;
405
403
offset += sym -> st_value ;
406
404
407
405
if (ELF32_R_TYPE (rel -> r_info ) == R_ARM_THM_MOVT_PREL ||
0 commit comments