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

Function find_program_segment

util/cbfstool/rmodule.c:252–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252static int find_program_segment(struct rmod_context *ctx)
253{
254 int i;
255 int nsegments;
256 struct parsed_elf *pelf;
257 Elf64_Phdr *phdr = NULL;
258
259 pelf = &ctx->pelf;
260
261 /* There should only be a single loadable segment. */
262 nsegments = 0;
263 for (i = 0; i < pelf->ehdr.e_phnum; i++) {
264 if (pelf->phdr[i].p_type != PT_LOAD)
265 continue;
266 if (!phdr)
267 phdr = &pelf->phdr[i];
268 nsegments++;
269 }
270
271 if (nsegments == 0) {
272 ERROR("No loadable segment found.\n");
273 return -1;
274 }
275
276 INFO("Segment at 0x%0llx, file size 0x%0llx, mem size 0x%0llx.\n",
277 (long long)phdr->p_vaddr, (long long)phdr->p_filesz,
278 (long long)phdr->p_memsz);
279
280 ctx->phdr = phdr;
281 ctx->nsegments = nsegments;
282
283 return 0;
284}
285
286static int
287filter_relocation_sections(struct rmod_context *ctx)

Callers 1

rmodule_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected