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

Function strtab_read

util/cbfstool/elfheaders.c:386–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386static int strtab_read(const struct buffer *in, struct parsed_elf *pelf)
387{
388 Elf64_Ehdr *ehdr;
389 Elf64_Word i;
390
391 ehdr = &pelf->ehdr;
392
393 if (ehdr->e_shstrndx >= ehdr->e_shnum) {
394 ERROR("Section header string table index out of range: %d\n",
395 ehdr->e_shstrndx);
396 return -1;
397 }
398
399 /* For each section of type SHT_STRTAB create a symtab buffer. */
400 pelf->strtabs = calloc(ehdr->e_shnum, sizeof(struct buffer *));
401
402 for (i = 0; i < ehdr->e_shnum; i++) {
403 struct buffer *b;
404 Elf64_Shdr *shdr = &pelf->shdr[i];
405
406 if (shdr->sh_type != SHT_STRTAB)
407 continue;
408
409 b = calloc(1, sizeof(*b));
410 buffer_splice(b, in, shdr->sh_offset, shdr->sh_size);
411 if (check_size(in, shdr->sh_offset, buffer_size(b), "strtab")) {
412 ERROR("STRTAB section not within bounds: %d\n", i);
413 free(b);
414 return -1;
415 }
416 pelf->strtabs[i] = b;
417 }
418
419 return 0;
420}
421
422static int
423symtab_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
callocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected