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

Function add_section

util/cbfstool/rmodule.c:470–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470static int
471add_section(struct elf_writer *ew, struct buffer *data, const char *name,
472 Elf64_Addr addr, Elf64_Word size)
473{
474 Elf64_Shdr shdr;
475 int ret;
476
477 memset(&shdr, 0, sizeof(shdr));
478 if (data != NULL) {
479 shdr.sh_type = SHT_PROGBITS;
480 shdr.sh_flags = SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR;
481 } else {
482 shdr.sh_type = SHT_NOBITS;
483 shdr.sh_flags = SHF_ALLOC;
484 }
485 shdr.sh_addr = addr;
486 shdr.sh_offset = addr;
487 shdr.sh_size = size;
488
489 ret = elf_writer_add_section(ew, &shdr, data, name);
490
491 if (ret)
492 ERROR("Could not add '%s' section.\n", name);
493
494 return ret;
495}
496
497static int
498write_elf(const struct rmod_context *ctx, const struct buffer *in,

Callers 1

write_elfFunction · 0.85

Calls 2

elf_writer_add_sectionFunction · 0.85
memsetFunction · 0.50

Tested by

no test coverage detected