// SPDX-License-Identifier: GPL-2.0-only /* * Kernel module loader for Hexagon * * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
*/
/* * module_frob_arch_sections - tweak got/plt sections. * @hdr - pointer to elf header * @sechdrs - pointer to elf load section headers * @secstrings - symbol names * @mod - pointer to module
*/ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, char *secstrings, struct module *mod)
{ unsignedint i; int found = 0;
/* Look for .plt and/or .got.plt and/or .init.plt sections */ for (i = 0; i < hdr->e_shnum; i++) {
DEBUGP("Section %d is %s\n", i,
secstrings + sechdrs[i].sh_name); if (strcmp(secstrings + sechdrs[i].sh_name, ".plt") == 0)
found = i+1; if (strcmp(secstrings + sechdrs[i].sh_name, ".got.plt") == 0)
found = i+1; if (strcmp(secstrings + sechdrs[i].sh_name, ".rela.plt") == 0)
found = i+1;
}
/* At this time, we don't support modules comiled with -shared */ if (found) {
printk(KERN_WARNING "Module '%s' contains unexpected .plt/.got sections.\n",
mod->name); /* return -ENOEXEC; */
}
switch (ELF32_R_TYPE(rela[i].r_info)) { case R_HEXAGON_B22_PCREL: { int dist = (int)(value - (uint32_t)location); if ((dist < -0x00800000) ||
(dist >= 0x00800000)) {
printk(KERN_ERR "%s: %s: %08x=%08x-%08x %s\n",
module->name, "R_HEXAGON_B22_PCREL reloc out of range",
dist, value, (uint32_t)location,
sym->st_name ?
&strtab[sym->st_name] : "(anonymous)"); return -ENOEXEC;
}
DEBUGP("B22_PCREL contents: %08X.\n", *location);
*location &= ~0x01ff3fff;
*location |= 0x00003fff & dist;
*location |= 0x01ff0000 & (dist<<2);
DEBUGP("Contents after reloc: %08x\n", *location); break;
} case R_HEXAGON_HI16:
value = (value>>16) & 0xffff;
fallthrough; case R_HEXAGON_LO16:
*location &= ~0x00c03fff;
*location |= value & 0x3fff;
*location |= (value & 0xc000) << 8; break; case R_HEXAGON_32:
*location = value; break; case R_HEXAGON_32_PCREL:
*location = value - (uint32_t)location; break; case R_HEXAGON_PLT_B22_PCREL: case R_HEXAGON_GOTOFF_LO16: case R_HEXAGON_GOTOFF_HI16:
printk(KERN_ERR "%s: GOT/PLT relocations unsupported\n",
module->name); return -ENOEXEC; default:
printk(KERN_ERR "%s: unknown relocation: %u\n",
module->name,
ELF32_R_TYPE(rela[i].r_info)); return -ENOEXEC;
}
} return 0;
}
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.26Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.