Lines Matching +full:no +full:- +full:cast
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
61 #define ELF_ALIGN(a) ((((a) + align - 1) / align) * align)
69 #define SIZE_UNKNOWN CAST(off_t, -1)
74 if (ms->flags & MAGIC_MIME) in toomany()
76 if (file_printf(ms, ", too many %s (%u)", name, num) == -1) in toomany()
77 return -1; in toomany()
151 ? CAST(void *, &sh32) \
152 : CAST(void *, &sh64))
156 #define xsh_size CAST(size_t, (clazz == ELFCLASS32 \
159 #define xsh_offset CAST(off_t, (clazz == ELFCLASS32 \
170 ? CAST(void *, &ph32) \
171 : CAST(void *, &ph64))
178 #define xph_offset CAST(off_t, (clazz == ELFCLASS32 \
181 #define xph_align CAST(size_t, (clazz == ELFCLASS32 \
182 ? CAST(off_t, (ph32.p_align ? \
184 : CAST(off_t, (ph64.p_align ? \
186 #define xph_vaddr CAST(size_t, (clazz == ELFCLASS32 \
187 ? CAST(off_t, (ph32.p_vaddr ? \
189 : CAST(off_t, (ph64.p_vaddr ? \
191 #define xph_filesz CAST(size_t, (clazz == ELFCLASS32 \
194 #define xph_memsz CAST(size_t, ((clazz == ELFCLASS32 \
198 ? CAST(void *, &nh32) \
199 : CAST(void *, &nh64))
214 ? CAST(void *, &dh32) \
215 : CAST(void *, &dh64))
227 ? CAST(void *, &cap32) \
228 : CAST(void *, &cap64))
240 ? CAST(void *, &auxv32) \
241 : CAST(void *, &auxv64))
285 136, /* SunOS 5.x, 64-bit (command line) */
286 120, /* SunOS 5.x, 64-bit (short name) */
291 16, /* FreeBSD, 64-bit */
303 * contents for a 16-character string containing only printable
304 * characters - if found, that string should be the name of the program
305 * that dropped core. Note: right after that 16-character string is,
306 * at least in SunOS 5.x (and possibly other SVR4-flavored systems) and
308 * SVR4-flavored systems, and Linux) containing the start of the
320 * but that's also rather OS-dependent, in ways that are harder to
364 if (ms->flags & MAGIC_MIME) in dophn_core()
368 if (file_printf(ms, ", no program header") == -1) in dophn_core()
369 return -1; in dophn_core()
373 if (file_printf(ms, ", corrupted program header size") == -1) in dophn_core()
374 return -1; in dophn_core()
381 for ( ; num; num--) { in dophn_core()
383 CAST(ssize_t, xph_sizeof)) { in dophn_core()
386 (intmax_t)off) == -1) in dophn_core()
387 return -1; in dophn_core()
406 if ((bufsize = pread(fd, nbuf, len, offs)) == -1) { in dophn_core()
408 (intmax_t)offs) == -1) in dophn_core()
409 return -1; in dophn_core()
414 if (offset >= CAST(size_t, bufsize)) in dophn_core()
416 offset = donote(ms, nbuf, offset, CAST(size_t, bufsize), in dophn_core()
435 if (file_printf(ms, ", for NetBSD") == -1) in do_note_netbsd_version()
436 return -1; in do_note_netbsd_version()
439 * basically content-free. Newer versions of NetBSD have fixed in do_note_netbsd_version()
446 * r = release ["",A-Z,Z[A-Z] but numeric] in do_note_netbsd_version()
455 if (file_printf(ms, " %u.%u", ver_maj, ver_min) == -1) in do_note_netbsd_version()
456 return -1; in do_note_netbsd_version()
462 if (file_printf(ms, ".%u", ver_patch) == -1) in do_note_netbsd_version()
463 return -1; in do_note_netbsd_version()
466 if (file_printf(ms, "Z") == -1) in do_note_netbsd_version()
467 return -1; in do_note_netbsd_version()
468 ver_rel -= 26; in do_note_netbsd_version()
470 if (file_printf(ms, "%c", 'A' + ver_rel - 1) == -1) in do_note_netbsd_version()
471 return -1; in do_note_netbsd_version()
484 if (file_printf(ms, ", for FreeBSD") == -1) in do_note_freebsd_version()
485 return -1; in do_note_freebsd_version()
501 * M000xx (pre-M.0) in do_note_freebsd_version()
506 * i = minor version increment (491000 -> 4.10) in do_note_freebsd_version()
514 if (file_printf(ms, " 4.6.2") == -1) in do_note_freebsd_version()
515 return -1; in do_note_freebsd_version()
518 desc / 10000 % 10) == -1) in do_note_freebsd_version()
519 return -1; in do_note_freebsd_version()
521 if (file_printf(ms, ".%d", desc / 1000 % 10) == -1) in do_note_freebsd_version()
522 return -1; in do_note_freebsd_version()
524 if (file_printf(ms, " (%d)", desc) == -1) in do_note_freebsd_version()
525 return -1; in do_note_freebsd_version()
528 desc / 10000 % 10 + desc / 1000 % 10) == -1) in do_note_freebsd_version()
529 return -1; in do_note_freebsd_version()
531 if (file_printf(ms, " (%d)", desc) == -1) in do_note_freebsd_version()
532 return -1; in do_note_freebsd_version()
534 if (file_printf(ms, ".%d", desc / 10 % 10) == -1) in do_note_freebsd_version()
535 return -1; in do_note_freebsd_version()
539 desc / 1000 % 100) == -1) in do_note_freebsd_version()
540 return -1; in do_note_freebsd_version()
543 if (file_printf(ms, " (%d)", desc) == -1) in do_note_freebsd_version()
544 return -1; in do_note_freebsd_version()
546 if (file_printf(ms, ".%d", desc / 10 % 10) == -1) in do_note_freebsd_version()
547 return -1; in do_note_freebsd_version()
579 if (file_printf(ms, ", BuildID[%s]=", btype) == -1) in do_bid_note()
580 return -1; in do_bid_note()
583 if (file_printf(ms, "%02x", desc[i]) == -1) in do_bid_note()
584 return -1; in do_bid_note()
592 RCAST(const char *, &nbuf[doff]))) == -1) in do_bid_note()
593 return -1; in do_bid_note()
610 nbuf[doff + 1]) == -1) in do_os_note()
611 return -1; in do_os_note()
621 if (file_printf(ms, ", for GNU/") == -1) in do_os_note()
622 return -1; in do_os_note()
625 if (file_printf(ms, "Linux") == -1) in do_os_note()
626 return -1; in do_os_note()
629 if (file_printf(ms, "Hurd") == -1) in do_os_note()
630 return -1; in do_os_note()
633 if (file_printf(ms, "Solaris") == -1) in do_os_note()
634 return -1; in do_os_note()
637 if (file_printf(ms, "kFreeBSD") == -1) in do_os_note()
638 return -1; in do_os_note()
641 if (file_printf(ms, "kNetBSD") == -1) in do_os_note()
642 return -1; in do_os_note()
645 if (file_printf(ms, "<unknown>") == -1) in do_os_note()
646 return -1; in do_os_note()
649 elf_getu32(swap, desc[2]), elf_getu32(swap, desc[3])) == -1) in do_os_note()
650 return -1; in do_os_note()
657 if (do_note_netbsd_version(ms, swap, &nbuf[doff]) == -1) in do_os_note()
658 return -1; in do_os_note()
667 == -1) in do_os_note()
668 return -1; in do_os_note()
676 if (file_printf(ms, ", for OpenBSD") == -1) in do_os_note()
677 return -1; in do_os_note()
686 if (file_printf(ms, ", for DragonFly") == -1) in do_os_note()
687 return -1; in do_os_note()
691 desc / 10000 % 10, desc % 10000) == -1) in do_os_note()
692 return -1; in do_os_note()
709 "-mprotect", in do_pax_note()
711 "-segvguard", in do_pax_note()
713 "-ASLR", in do_pax_note()
723 if (desc && file_printf(ms, ", PaX: ") == -1) in do_pax_note()
724 return -1; in do_pax_note()
727 if (((1 << CAST(int, i)) & desc) == 0) in do_pax_note()
730 pax[i]) == -1) in do_pax_note()
731 return -1; in do_pax_note()
747 int os_style = -1; in do_core_note()
756 * contain a *null-terminated* [emphasis mine] in do_core_note()
771 if ((namesz >= 11 && strncmp(name, "NetBSD-CORE", 11) in do_core_note()
776 if (os_style != -1 && (*flags & FLAGS_DID_CORE_STYLE) == 0) { in do_core_note()
777 if (file_printf(ms, ", %s-style", os_style_names[os_style]) in do_core_note()
778 == -1) in do_core_note()
779 return -1; in do_core_note()
796 elf_getu32(swap, CAST(uint32_t, pi.cpi_pid)), in do_core_note()
800 elf_getu32(swap, CAST(uint32_t, pi.cpi_siglwp)), in do_core_note()
802 elf_getu32(swap, pi.cpi_sigcode)) == -1) in do_core_note()
803 return -1; in do_core_note()
819 argoff) == -1) in do_core_note()
820 return -1; in do_core_note()
825 doff + pidoff)))) == -1) in do_core_note()
826 return -1; in do_core_note()
902 size_t no; in do_core_note() local
907 * pr_fname == pr_psargs - 16 && in do_core_note()
908 * non-nul-terminated fname (qemu) in do_core_note()
911 prpsoffsets(i) - 16 && j == 16) in do_core_note()
913 for (no = doff + prpsoffsets(k); in do_core_note()
914 no < doff + prpsoffsets(i); no++) in do_core_note()
916 && isprint(nbuf[no]); in do_core_note()
921 cname = CAST(unsigned char *, in do_core_note()
930 while (cp > cname && isspace(cp[-1])) in do_core_note()
931 cp--; in do_core_note()
934 CAST(size_t, cp - cname), in do_core_note()
935 RCAST(char *, cname))) == -1) in do_core_note()
936 return -1; in do_core_note()
961 for ( ; num; num--) { in get_offset_from_virtaddr()
963 CAST(ssize_t, xph_sizeof)) { in get_offset_from_virtaddr()
966 (intmax_t)off) == -1) in get_offset_from_virtaddr()
967 return -1; in get_offset_from_virtaddr()
979 return xph_offset + (virtaddr - xph_vaddr); in get_offset_from_virtaddr()
998 (buflen = pread(fd, buf, CAST(size_t, buflen), offset)) <= 0) { in get_string_on_virtaddr()
1004 buf[buflen - 1] = '\0'; in get_string_on_virtaddr()
1007 * non-printable character before the '\0' or just '\0'. */ in get_string_on_virtaddr()
1008 for (bptr = buf; *bptr && isprint(CAST(unsigned char, *bptr)); bptr++) in get_string_on_virtaddr()
1013 return bptr - buf; in get_string_on_virtaddr()
1111 if (file_printf(ms, ", %s: '%s'", tag, buf) == -1) in do_auxv_note()
1112 return -1; in do_auxv_note()
1115 CAST(int, xauxv_val)) == -1) in do_auxv_note()
1116 return -1; in do_auxv_note()
1131 unsigned char *dbuf = CAST(unsigned char *, vbuf); in dodynamic()
1147 ms->mode |= 0111; in dodynamic()
1149 ms->mode &= ~0111; in dodynamic()
1171 unsigned char *nbuf = CAST(unsigned char *, vbuf); in donote()
1175 --*notecount; in donote()
1202 CAST(unsigned long, namesz)); in donote()
1208 CAST(unsigned long, descsz)); in donote()
1286 if (file_printf(ms, ", note=%u", xnh_type) == -1) in donote()
1294 descw = CAST(int, descsz); in donote()
1370 if (ms->flags & MAGIC_MIME) in doshn()
1374 if (file_printf(ms, ", no section header") == -1) in doshn()
1375 return -1; in doshn()
1379 if (file_printf(ms, ", corrupted section header size") == -1) in doshn()
1380 return -1; in doshn()
1385 offs = CAST(off_t, (off + size * strtab)); in doshn()
1386 if (pread(fd, xsh_addr, xsh_sizeof, offs) < CAST(ssize_t, xsh_sizeof)) { in doshn()
1388 (intmax_t)offs) == -1) in doshn()
1389 return -1; in doshn()
1396 (intmax_t)name_off) == -1) in doshn()
1397 return -1; in doshn()
1401 for ( ; num; num--) { in doshn()
1404 if ((namesize = pread(fd, name, sizeof(name) - 1, offs)) in doshn()
1405 == -1) { in doshn()
1408 (intmax_t)offs) == -1) in doshn()
1409 return -1; in doshn()
1419 CAST(ssize_t, xsh_sizeof)) { in doshn()
1421 (intmax_t)off) == -1) in doshn()
1422 return -1; in doshn()
1447 if (CAST(uintmax_t, (xsh_size + xsh_offset)) > in doshn()
1448 CAST(uintmax_t, fsize)) { in doshn()
1453 CAST(uintmax_t, xsh_offset), in doshn()
1454 CAST(uintmax_t, xsh_size), in doshn()
1455 CAST(uintmax_t, fsize)) == -1) in doshn()
1456 return -1; in doshn()
1459 if (xsh_size > ms->elf_shsize_max) { in doshn()
1462 ms->elf_shsize_max); in doshn()
1463 return -1; in doshn()
1468 return -1; in doshn()
1472 CAST(ssize_t, xsh_size)) { in doshn()
1476 (intmax_t)offs) == -1) in doshn()
1477 return -1; in doshn()
1483 if (noff >= CAST(off_t, xsh_size)) in doshn()
1485 noff = donote(ms, nbuf, CAST(size_t, noff), in doshn()
1508 == CAST(off_t, -1)) { in doshn()
1510 return -1; in doshn()
1519 CAST(off_t, xsh_size)) in doshn()
1521 if (read(fd, cbuf, CAST(size_t, xcap_sizeof)) != in doshn()
1522 CAST(ssize_t, xcap_sizeof)) { in doshn()
1524 return -1; in doshn()
1536 == -1) in doshn()
1537 return -1; in doshn()
1548 == -1) in doshn()
1549 return -1; in doshn()
1571 CAST(unsigned long long, xcap_tag), in doshn()
1572 CAST(unsigned long long, xcap_val)) in doshn()
1573 == -1) in doshn()
1574 return -1; in doshn()
1588 if (file_printf(ms, ", with debug_info") == -1) in doshn()
1589 return -1; in doshn()
1591 if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1) in doshn()
1592 return -1; in doshn()
1610 if (file_printf(ms, ", uses") == -1) in doshn()
1611 return -1; in doshn()
1613 while (cdp->cd_name) { in doshn()
1614 if (cap_hw1 & cdp->cd_mask) { in doshn()
1616 " %s", cdp->cd_name) == -1) in doshn()
1617 return -1; in doshn()
1618 cap_hw1 &= ~cdp->cd_mask; in doshn()
1626 CAST(unsigned long long, cap_hw1)) == -1) in doshn()
1627 return -1; in doshn()
1631 CAST(unsigned long long, cap_hw1)) == -1) in doshn()
1632 return -1; in doshn()
1640 : ", not known to use frame pointer") == -1) in doshn()
1641 return -1; in doshn()
1648 CAST(unsigned long long, cap_sf1)) == -1) in doshn()
1649 return -1; in doshn()
1676 if (file_printf(ms, ", no program header") == -1) in dophn_exec()
1677 return -1; in dophn_exec()
1681 if (file_printf(ms, ", corrupted program header size") == -1) in dophn_exec()
1682 return -1; in dophn_exec()
1687 for ( ; num; num--) { in dophn_exec()
1690 CAST(ssize_t, xph_sizeof)) { in dophn_exec()
1693 (intmax_t)off) == -1) in dophn_exec()
1694 return -1; in dophn_exec()
1714 CAST(unsigned long, align)) == -1) in dophn_exec()
1715 return -1; in dophn_exec()
1736 if (bufsize == -1) { in dophn_exec()
1739 (intmax_t)offs) == -1) in dophn_exec()
1740 return -1; in dophn_exec()
1751 ms->mode &= ~0111; in dophn_exec()
1753 if (offset >= CAST(size_t, bufsize)) in dophn_exec()
1756 CAST(size_t, bufsize), clazz, swap, in dophn_exec()
1761 if (ms->flags & MAGIC_MIME) in dophn_exec()
1767 if (ms->flags & MAGIC_MIME) in dophn_exec()
1770 nbuf[bufsize - 1] = '\0'; in dophn_exec()
1771 memcpy(interp, nbuf, CAST(size_t, bufsize)); in dophn_exec()
1776 if (ms->flags & MAGIC_MIME) in dophn_exec()
1784 if (offset >= CAST(size_t, bufsize)) in dophn_exec()
1787 CAST(size_t, bufsize), clazz, swap, align, in dophn_exec()
1794 if (ms->flags & MAGIC_MIME) in dophn_exec()
1799 if (ms->flags & MAGIC_MIME) in dophn_exec()
1803 linking_style = "static-pie"; in dophn_exec()
1809 if (file_printf(ms, ", %s linked", linking_style) == -1) in dophn_exec()
1810 return -1; in dophn_exec()
1813 ibuf, sizeof(ibuf), interp, sizeof(interp))) == -1) in dophn_exec()
1814 return -1; in dophn_exec()
1822 int fd = b->fd; in file_tryelf()
1823 const unsigned char *buf = CAST(const unsigned char *, b->fbuf); in file_tryelf()
1824 size_t nbytes = b->flen; in file_tryelf()
1839 if (ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)) in file_tryelf()
1857 if((lseek(fd, CAST(off_t, 0), SEEK_SET) == CAST(off_t, -1)) in file_tryelf()
1861 if (fd == -1) { in file_tryelf()
1863 return -1; in file_tryelf()
1866 stp = &b->st; in file_tryelf()
1868 * b->st.st_size != 0 if previous fstat() succeeded, in file_tryelf()
1871 if (b->st.st_size == 0) { in file_tryelf()
1873 if (fstat(fd, &st) == -1) { in file_tryelf()
1875 return -1; in file_tryelf()
1878 if (S_ISREG(stp->st_mode) || stp->st_size != 0) in file_tryelf()
1879 fsize = stp->st_size; in file_tryelf()
1899 if (file_printf(ms, ", unknown class %d", clazz) == -1) in file_tryelf()
1900 return -1; in file_tryelf()