arch/hexagon/kernel/module.c

Source file repositories/reference/linux-study-clean/arch/hexagon/kernel/module.c

File Facts

System
Linux kernel
Corpus path
arch/hexagon/kernel/module.c
Extension
.c
Size
4095 bytes
Lines
150
Domain
Architecture Layer
Bucket
arch/hexagon
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

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;
}

Annotation

Implementation Notes