* 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. */
| 828 | * Returns < 0 on error, 0 on success. |
| 829 | */ |
| 830 | int 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 | |
| 851 | static void ehdr_write(struct elf_writer *ew, struct buffer *m) |
| 852 | { |
no test coverage detected