*loc = sym->st_value + rela[i].r_addend;
switch (ELF32_R_TYPE(rela[i].r_info)) { case R_CRIS_32: *loc = sym->st_value + rela[i].r_addend; break; case R_CRIS_32_PCREL: *loc = sym->st_value - (unsigned)loc + rela[i].r_addend - 4; break; default: printk(KERN_ERR "module %s: Unknown relocation: %u\n", me->name, ELF32_R_TYPE(rela[i].r_info)); return -ENOEXEC; }
int apply_relocate_add(Elf32_Shdr *sechdrs,		       const char *strtab,		       unsigned int symindex,		       unsigned int relsec,		       struct module *me){  	unsigned int i;	Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr;	DEBUGP ("Applying relocate section %u to %u\n", relsec,		sechdrs[relsec].sh_info);	for (i = 0; i < sechdrs[relsec].sh_size / sizeof (*rela); i++) {		/* This is where to make the change */		uint32_t *loc			= ((void *)sechdrs[sechdrs[relsec].sh_info].sh_addr			   + rela[i].r_offset);		/* This is the symbol it is referring to.  Note that all		   undefined symbols have been resolved.  */		Elf32_Sym *sym			= ((Elf32_Sym *)sechdrs[symindex].sh_addr			   + ELF32_R_SYM (rela[i].r_info));		*loc = sym->st_value + rela[i].r_addend;	}	return 0;}