| 101 | } |
| 102 | |
| 103 | static int |
| 104 | check_elf_header(const Elf64_Ehdr *eh) |
| 105 | { |
| 106 | const char *err; |
| 107 | |
| 108 | err = NULL; |
| 109 | |
| 110 | #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN |
| 111 | if (eh->e_ident[EI_DATA] != ELFDATA2LSB) |
| 112 | #else |
| 113 | if (eh->e_ident[EI_DATA] != ELFDATA2MSB) |
| 114 | #endif |
| 115 | err = "not native byte order"; |
| 116 | else if (eh->e_ident[EI_OSABI] != ELFOSABI_NONE) |
| 117 | err = "unexpected OS ABI"; |
| 118 | else if (eh->e_type != ET_REL) |
| 119 | err = "unexpected ELF type"; |
| 120 | else if (eh->e_machine != EM_NONE && eh->e_machine != EM_BPF) |
| 121 | err = "unexpected machine type"; |
| 122 | |
| 123 | if (err != NULL) { |
| 124 | RTE_BPF_LOG(ERR, "%s(): %s\n", __func__, err); |
| 125 | return -EINVAL; |
| 126 | } |
| 127 | |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | /* |
| 132 | * helper function, find executable section by name. |