Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4eb4516e authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman
Browse files

powerpc/module32: Use symbolic instructions names.



To increase readability/maintainability, replace hard coded
instructions values by symbolic names.

Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 7f9c929a
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -172,10 +172,12 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,

static inline int entry_matches(struct ppc_plt_entry *entry, Elf32_Addr val)
{
	if (entry->jump[0] == 0x3d800000 + ((val + 0x8000) >> 16)
	    && entry->jump[1] == 0x398c0000 + (val & 0xffff))
		return 1;
	if (entry->jump[0] != (PPC_INST_ADDIS | __PPC_RT(R12) | PPC_HA(val)))
		return 0;
	if (entry->jump[1] != (PPC_INST_ADDI | __PPC_RT(R12) | __PPC_RA(R12) |
			       PPC_LO(val)))
		return 0;
	return 1;
}

/* Set up a trampoline in the PLT to bounce us to the distant function */
@@ -200,10 +202,16 @@ static uint32_t do_plt_call(void *location,
		entry++;
	}

	entry->jump[0] = 0x3d800000+((val+0x8000)>>16); /* lis r12,sym@ha */
	entry->jump[1] = 0x398c0000 + (val&0xffff);     /* addi r12,r12,sym@l*/
	entry->jump[2] = 0x7d8903a6;                    /* mtctr r12 */
	entry->jump[3] = 0x4e800420;			/* bctr */
	/*
	 * lis r12, sym@ha
	 * addi r12, r12, sym@l
	 * mtctr r12
	 * bctr
	 */
	entry->jump[0] = PPC_INST_ADDIS | __PPC_RT(R12) | PPC_HA(val);
	entry->jump[1] = PPC_INST_ADDI | __PPC_RT(R12) | __PPC_RA(R12) | PPC_LO(val);
	entry->jump[2] = PPC_INST_MTCTR | __PPC_RS(R12);
	entry->jump[3] = PPC_INST_BCTR;

	pr_debug("Initialized plt for 0x%x at %p\n", val, entry);
	return (uint32_t)entry;