コード例 #1
0
ファイル: rmodule.c プロジェクト: AdriDlu/coreboot
static int rmodule_relocate(const struct rmodule *module)
{
	size_t num_relocations;
	const uintptr_t *reloc;
	uintptr_t adjustment;

	/* Each relocation needs to be adjusted relative to the beginning of
	 * the loaded program. */
	adjustment = (uintptr_t)rmodule_load_addr(module, 0);

	reloc = module->relocations;
	num_relocations = rmodule_number_relocations(module);

	printk(BIOS_DEBUG, "Processing %zu relocs. Offset value of 0x%08lx\n",
	       num_relocations, (unsigned long)adjustment);

	while (num_relocations > 0) {
		uintptr_t *adjust_loc;

		/* If the adjustment location is non-NULL adjust it. */
		adjust_loc = rmodule_load_addr(module, *reloc);
		printk(PK_ADJ_LEVEL, "Adjusting %p: 0x%08lx -> 0x%08lx\n",
		       adjust_loc, (unsigned long) *adjust_loc,
		       (unsigned long) (*adjust_loc + adjustment));
			*adjust_loc += adjustment;

		reloc++;
		num_relocations--;
	}

	return 0;
}
コード例 #2
0
ファイル: rmodule.c プロジェクト: DarkDefender/coreboot
void *rmodule_entry(const struct rmodule *module)
{
	if (!rmodule_is_loaded(module))
		return NULL;

	return rmodule_load_addr(module, module->header->module_entry_point);
}
コード例 #3
0
ファイル: rmodule.c プロジェクト: DarkDefender/coreboot
static void rmodule_clear_bss(struct rmodule *module)
{
	char *begin;
	int size;

	begin = rmodule_load_addr(module, module->header->bss_begin);
	size = module->header->bss_end - module->header->bss_begin;
	memset(begin, 0, size);
}
コード例 #4
0
ファイル: rmodule.c プロジェクト: DarkDefender/coreboot
void *rmodule_parameters(const struct rmodule *module)
{
	if (!rmodule_is_loaded(module))
		return NULL;

	/* Indicate if there are no parameters. */
	if (module->header->parameters_begin == module->header->parameters_end)
		return NULL;

	return rmodule_load_addr(module, module->header->parameters_begin);
}
コード例 #5
0
ファイル: rmodule.c プロジェクト: DarkDefender/coreboot
static inline u32 *rmodule_adjustment_location(const struct rmodule *module,
                                               const void *reloc)
{
	int reloc_offset;

	/* Don't relocate header field entries -- only program relocations. */
	reloc_offset = rmodule_reloc_offset(reloc);
	if (reloc_offset < module->header->module_link_start_address)
		return NULL;

	return rmodule_load_addr(module, reloc_offset);
}
コード例 #6
0
ファイル: rmodule.c プロジェクト: DarkDefender/coreboot
static int rmodule_relocate(const struct rmodule *module)
{
	int num_relocations;
	const void *reloc;
	u32 adjustment;

	/* Each relocation needs to be adjusted relative to the beginning of
	 * the loaded program. */
	adjustment = (u32)rmodule_load_addr(module, 0);

	reloc = module->relocations;
	num_relocations = rmodule_number_relocations(module);

	printk(BIOS_DEBUG, "Processing %d relocs with adjust value of 0x%08x\n",
	       num_relocations, adjustment);

	while (num_relocations > 0) {
		u32 *adjust_loc;

		if (!rmodule_reloc_valid(reloc))
			return -1;

		/* If the adjustment location is non-NULL adjust it. */
		adjust_loc = rmodule_adjustment_location(module, reloc);
		if (adjust_loc != NULL) {
			printk(PK_ADJ_LEVEL, "Adjusting %p: 0x%08x -> 0x%08x\n",
			       adjust_loc, *adjust_loc,
			       *adjust_loc + adjustment);
			*adjust_loc += adjustment;
		}

		reloc = remodule_next_reloc(reloc);
		num_relocations--;
	}

	return 0;
}