| 468 | } |
| 469 | |
| 470 | static int |
| 471 | add_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 | |
| 497 | static int |
| 498 | write_elf(const struct rmod_context *ctx, const struct buffer *in, |
no test coverage detected