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

Function shdr_read

util/cbfstool/elfheaders.c:280–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280static int
281shdr_read(const struct buffer *in, struct parsed_elf *pelf,
282 struct xdr *xdr, int bit64)
283{
284 struct buffer b;
285 Elf64_Shdr *shdr;
286 Elf64_Ehdr *ehdr;
287 int i;
288
289 ehdr = &pelf->ehdr;
290
291 /* cons up an input buffer for the section headers.
292 * Note that the section headers can be anywhere,
293 * per the ELF spec, You'd be surprised how many ELF
294 * readers miss this little detail.
295 */
296 buffer_splice(&b, in, ehdr->e_shoff,
297 (uint32_t)ehdr->e_shentsize * ehdr->e_shnum);
298 if (check_size(in, ehdr->e_shoff, buffer_size(&b), "section headers"))
299 return -1;
300
301 /* gather up all the shdrs. */
302 shdr = calloc(ehdr->e_shnum, sizeof(*shdr));
303 for (i = 0; i < ehdr->e_shnum; i++) {
304 DEBUG("Parsing section %d\n", i);
305 elf_shdr(&b, &shdr[i], ehdr->e_shentsize, xdr, bit64);
306 }
307
308 pelf->shdr = shdr;
309
310 return 0;
311}
312
313static int
314reloc_read(const struct buffer *in, struct parsed_elf *pelf,

Callers 1

parse_elfFunction · 0.85

Calls 5

buffer_spliceFunction · 0.85
check_sizeFunction · 0.85
buffer_sizeFunction · 0.85
elf_shdrFunction · 0.85
callocFunction · 0.50

Tested by

no test coverage detected