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