MCPcopy Create free account
hub / github.com/coreboot/coreboot / rmodule_relocate

Function rmodule_relocate

src/lib/rmodule.c:129–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129static int rmodule_relocate(const struct rmodule *module)
130{
131 size_t num_relocations;
132 const uintptr_t *reloc;
133 uintptr_t adjustment;
134
135 /* Each relocation needs to be adjusted relative to the beginning of
136 * the loaded program. */
137 adjustment = (uintptr_t)rmodule_load_addr(module, 0);
138
139 reloc = module->relocations;
140 num_relocations = rmodule_number_relocations(module);
141
142 printk(BIOS_DEBUG, "Processing %zu relocs. Offset value of 0x%08lx\n",
143 num_relocations, (unsigned long)adjustment);
144
145 while (num_relocations > 0) {
146 uintptr_t *adjust_loc;
147
148 /* If the adjustment location is non-NULL adjust it. */
149 adjust_loc = rmodule_load_addr(module, *reloc);
150 printk(PK_ADJ_LEVEL, "Adjusting %p: 0x%08lx -> 0x%08lx\n",
151 adjust_loc, (unsigned long) *adjust_loc,
152 (unsigned long) (*adjust_loc + adjustment));
153 *adjust_loc += adjustment;
154
155 reloc++;
156 num_relocations--;
157 }
158
159 return 0;
160}
161
162int rmodule_load_alignment(const struct rmodule *module)
163{

Callers 1

rmodule_loadFunction · 0.85

Calls 3

rmodule_load_addrFunction · 0.85
printkFunction · 0.50

Tested by

no test coverage detected