Skip to content

Commit 0906584

Browse files
rustyrussellantonblanchard
authored andcommitted
powerpc: Handle new ELFv2 module relocations
The new ELF ABI tends to use R_PPC64_REL16_LO and R_PPC64_REL16_HA relocations (PC-relative), so implement them. Signed-off-by: Rusty Russell <[email protected]>
1 parent 4edebbe commit 0906584

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

arch/powerpc/include/uapi/asm/elf.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,13 @@ do { \
295295
#define R_PPC64_TLSLD 108
296296
#define R_PPC64_TOCSAVE 109
297297

298+
#define R_PPC64_REL16 249
299+
#define R_PPC64_REL16_LO 250
300+
#define R_PPC64_REL16_HI 251
301+
#define R_PPC64_REL16_HA 252
302+
298303
/* Keep this the last entry. */
299-
#define R_PPC64_NUM 110
304+
#define R_PPC64_NUM 253
300305

301306
/* There's actually a third entry here, but it's unused */
302307
struct ppc64_opd_entry

arch/powerpc/kernel/module_64.c

+17
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,23 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
491491
*/
492492
break;
493493

494+
case R_PPC64_REL16_HA:
495+
/* Subtract location pointer */
496+
value -= (unsigned long)location;
497+
value = ((value + 0x8000) >> 16);
498+
*((uint16_t *) location)
499+
= (*((uint16_t *) location) & ~0xffff)
500+
| (value & 0xffff);
501+
break;
502+
503+
case R_PPC64_REL16_LO:
504+
/* Subtract location pointer */
505+
value -= (unsigned long)location;
506+
*((uint16_t *) location)
507+
= (*((uint16_t *) location) & ~0xffff)
508+
| (value & 0xffff);
509+
break;
510+
494511
default:
495512
printk("%s: Unknown ADD relocation: %lu\n",
496513
me->name,

0 commit comments

Comments
 (0)