| 727 | } |
| 728 | |
| 729 | static void symtab_init(struct elf_writer *ew, size_t max_entries) |
| 730 | { |
| 731 | struct buffer b; |
| 732 | Elf64_Shdr shdr; |
| 733 | |
| 734 | memset(&shdr, 0, sizeof(shdr)); |
| 735 | shdr.sh_type = SHT_SYMTAB; |
| 736 | |
| 737 | if (ew->bit64) { |
| 738 | shdr.sh_entsize = sizeof(Elf64_Sym); |
| 739 | shdr.sh_addralign = sizeof(Elf64_Addr); |
| 740 | } else { |
| 741 | shdr.sh_entsize = sizeof(Elf32_Sym); |
| 742 | shdr.sh_addralign = sizeof(Elf32_Addr); |
| 743 | } |
| 744 | |
| 745 | shdr.sh_size = shdr.sh_entsize * max_entries; |
| 746 | |
| 747 | ew->symtab.syms = calloc(max_entries, sizeof(Elf64_Sym)); |
| 748 | ew->symtab.num_entries = 1; |
| 749 | ew->symtab.max_entries = max_entries; |
| 750 | |
| 751 | buffer_init(&b, NULL, ew->symtab.syms, shdr.sh_size); |
| 752 | |
| 753 | elf_writer_add_section(ew, &shdr, &b, ".symtab"); |
| 754 | ew->symtab_sec = last_section(ew); |
| 755 | } |
| 756 | |
| 757 | struct elf_writer *elf_writer_init(const Elf64_Ehdr *ehdr) |
| 758 | { |
no test coverage detected