arch/mips/tools/elf-entry.c

Source file repositories/reference/linux-study-clean/arch/mips/tools/elf-entry.c

File Facts

System
Linux kernel
Corpus path
arch/mips/tools/elf-entry.c
Extension
.c
Size
2059 bytes
Lines
104
Domain
Architecture Layer
Bucket
arch/mips
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 (hdr.ehdr32.e_ident[EI_DATA]) {
		case ELFDATA2LSB:
			entry = le32toh(hdr.ehdr32.e_entry);
			break;
		case ELFDATA2MSB:
			entry = be32toh(hdr.ehdr32.e_entry);
			break;
		default:
			fclose(file);
			die("Invalid ELF encoding\n");
		}

		/* Sign extend to form a canonical address */
		entry = (int64_t)(int32_t)entry;
		break;

	case ELFCLASS64:
		switch (hdr.ehdr32.e_ident[EI_DATA]) {
		case ELFDATA2LSB:
			entry = le64toh(hdr.ehdr64.e_entry);
			break;
		case ELFDATA2MSB:
			entry = be64toh(hdr.ehdr64.e_entry);
			break;
		default:
			fclose(file);
			die("Invalid ELF encoding\n");
		}
		break;

	default:
		fclose(file);
		die("Invalid ELF class\n");
	}

	printf("0x%016" PRIx64 "\n", entry);
	fclose(file);
	return EXIT_SUCCESS;
}

Annotation

Implementation Notes