| 281 | } |
| 282 | |
| 283 | int |
| 284 | dumpsys_generic(struct dumperinfo *di) |
| 285 | { |
| 286 | static struct kerneldumpheader kdh; |
| 287 | Elf_Ehdr ehdr; |
| 288 | uint64_t dumpsize; |
| 289 | off_t hdrgap; |
| 290 | size_t hdrsz; |
| 291 | int error; |
| 292 | |
| 293 | #if MINIDUMP_PAGE_TRACKING == 1 |
| 294 | if (do_minidump) |
| 295 | return (minidumpsys(di)); |
| 296 | #endif |
| 297 | |
| 298 | bzero(&ehdr, sizeof(ehdr)); |
| 299 | ehdr.e_ident[EI_MAG0] = ELFMAG0; |
| 300 | ehdr.e_ident[EI_MAG1] = ELFMAG1; |
| 301 | ehdr.e_ident[EI_MAG2] = ELFMAG2; |
| 302 | ehdr.e_ident[EI_MAG3] = ELFMAG3; |
| 303 | ehdr.e_ident[EI_CLASS] = ELF_CLASS; |
| 304 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 305 | ehdr.e_ident[EI_DATA] = ELFDATA2LSB; |
| 306 | #else |
| 307 | ehdr.e_ident[EI_DATA] = ELFDATA2MSB; |
| 308 | #endif |
| 309 | ehdr.e_ident[EI_VERSION] = EV_CURRENT; |
| 310 | ehdr.e_ident[EI_OSABI] = ELFOSABI_STANDALONE; /* XXX big picture? */ |
| 311 | ehdr.e_type = ET_CORE; |
| 312 | ehdr.e_machine = EM_VALUE; |
| 313 | ehdr.e_phoff = sizeof(ehdr); |
| 314 | ehdr.e_flags = 0; |
| 315 | ehdr.e_ehsize = sizeof(ehdr); |
| 316 | ehdr.e_phentsize = sizeof(Elf_Phdr); |
| 317 | ehdr.e_shentsize = sizeof(Elf_Shdr); |
| 318 | |
| 319 | dumpsys_pa_init(); |
| 320 | |
| 321 | /* Calculate dump size. */ |
| 322 | dumpsize = 0L; |
| 323 | ehdr.e_phnum = dumpsys_foreach_chunk(cb_size, &dumpsize) + |
| 324 | DUMPSYS_NUM_AUX_HDRS; |
| 325 | hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize; |
| 326 | fileofs = MD_ALIGN(hdrsz); |
| 327 | dumpsize += fileofs; |
| 328 | hdrgap = fileofs - roundup2((off_t)hdrsz, di->blocksize); |
| 329 | |
| 330 | dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_ARCH_VERSION, |
| 331 | dumpsize); |
| 332 | |
| 333 | error = dump_start(di, &kdh); |
| 334 | if (error != 0) |
| 335 | goto fail; |
| 336 | |
| 337 | printf("Dumping %ju MB (%d chunks)\n", (uintmax_t)dumpsize >> 20, |
| 338 | ehdr.e_phnum - DUMPSYS_NUM_AUX_HDRS); |
| 339 | |
| 340 | /* Dump ELF header */ |
no test coverage detected