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

Function elf_writer_add_section

util/cbfstool/elfheaders.c:830–849  ·  view source on GitHub ↗

* Add a section to the ELF file. Section type, flags, and memsize are * maintained from the passed in Elf64_Shdr. The buffer represents the * content of the section while the name is the name of section itself. * Returns < 0 on error, 0 on success. */

Source from the content-addressed store, hash-verified

828 * Returns < 0 on error, 0 on success.
829 */
830int elf_writer_add_section(struct elf_writer *ew, const Elf64_Shdr *shdr,
831 struct buffer *contents, const char *name)
832{
833 struct elf_writer_section *newsh;
834
835 if (ew->num_secs == MAX_SECTIONS)
836 return -1;
837
838 newsh = &ew->sections[ew->num_secs];
839 ew->num_secs++;
840
841 memcpy(&newsh->shdr, shdr, sizeof(newsh->shdr));
842 newsh->shdr.sh_offset = 0;
843
844 newsh->name = name;
845 if (contents != NULL)
846 buffer_clone(&newsh->content, contents);
847
848 return 0;
849}
850
851static void ehdr_write(struct elf_writer *ew, struct buffer *m)
852{

Callers 8

add_sectionFunction · 0.85
rmodule_stage_to_elfFunction · 0.85
cbfs_stage_make_elfFunction · 0.85
cbfs_payload_make_elfFunction · 0.85
strtab_initFunction · 0.85
symtab_initFunction · 0.85
elf_writer_initFunction · 0.85
rel_sectionFunction · 0.85

Calls 2

buffer_cloneFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected