| 278 | } |
| 279 | |
| 280 | static int |
| 281 | shdr_read(const struct buffer *in, struct parsed_elf *pelf, |
| 282 | struct xdr *xdr, int bit64) |
| 283 | { |
| 284 | struct buffer b; |
| 285 | Elf64_Shdr *shdr; |
| 286 | Elf64_Ehdr *ehdr; |
| 287 | int i; |
| 288 | |
| 289 | ehdr = &pelf->ehdr; |
| 290 | |
| 291 | /* cons up an input buffer for the section headers. |
| 292 | * Note that the section headers can be anywhere, |
| 293 | * per the ELF spec, You'd be surprised how many ELF |
| 294 | * readers miss this little detail. |
| 295 | */ |
| 296 | buffer_splice(&b, in, ehdr->e_shoff, |
| 297 | (uint32_t)ehdr->e_shentsize * ehdr->e_shnum); |
| 298 | if (check_size(in, ehdr->e_shoff, buffer_size(&b), "section headers")) |
| 299 | return -1; |
| 300 | |
| 301 | /* gather up all the shdrs. */ |
| 302 | shdr = calloc(ehdr->e_shnum, sizeof(*shdr)); |
| 303 | for (i = 0; i < ehdr->e_shnum; i++) { |
| 304 | DEBUG("Parsing section %d\n", i); |
| 305 | elf_shdr(&b, &shdr[i], ehdr->e_shentsize, xdr, bit64); |
| 306 | } |
| 307 | |
| 308 | pelf->shdr = shdr; |
| 309 | |
| 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | static int |
| 314 | reloc_read(const struct buffer *in, struct parsed_elf *pelf, |
no test coverage detected