Lines Matching +full:stream +full:- +full:match +full:- +full:mask

1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
18 * 4. Neither the name of the author nor the names of any co-contributors
133 if (MAXRECSIZE - recpos < size) in record_buf()
159 * A string is stored as 1-byte length plus data, no padding
209 #define TYPE_MASK 0x200 /* Specifies a mask to follow */
247 * byte order. The two fields both must match.
250 * M uint32_t Mask of which fields to test. Fields that
254 * Z string pnp string must match this
258 * Strings and int32_t's start on a 32-bit boundary and are padded with 0
280 err(1, "Could not open new memory stream"); in parse_pnp_list()
288 if (colon - walker > sizeof(type)) in parse_pnp_list()
290 strncpy(type, walker, colon - walker); in parse_pnp_list()
291 type[colon - walker] = '\0'; in parse_pnp_list()
293 if (semi - colon >= sizeof(key)) in parse_pnp_list()
295 strncpy(key, colon + 1, semi - colon - 1); in parse_pnp_list()
296 key[semi - colon - 1] = '\0'; in parse_pnp_list()
320 elt->pe_key = (char *)(elt + 1); in parse_pnp_list()
321 elt->pe_offset = off; in parse_pnp_list()
323 elt->pe_kind = TYPE_U8; in parse_pnp_list()
325 elt->pe_kind = TYPE_V8; in parse_pnp_list()
327 elt->pe_kind = TYPE_G16; in parse_pnp_list()
329 elt->pe_kind = TYPE_L16; in parse_pnp_list()
331 elt->pe_kind = TYPE_M16; in parse_pnp_list()
333 elt->pe_kind = TYPE_U16; in parse_pnp_list()
335 elt->pe_kind = TYPE_V16; in parse_pnp_list()
337 elt->pe_kind = TYPE_U32; in parse_pnp_list()
339 elt->pe_kind = TYPE_V32; in parse_pnp_list()
341 elt->pe_kind = TYPE_W32; in parse_pnp_list()
343 elt->pe_kind = TYPE_D; in parse_pnp_list()
344 else if (strcmp(type, "Z") == 0) /* char * to match */ in parse_pnp_list()
345 elt->pe_kind = TYPE_Z; in parse_pnp_list()
346 else if (strcmp(type, "P") == 0) /* Pointer -- ignored */ in parse_pnp_list()
347 elt->pe_kind = TYPE_P; in parse_pnp_list()
349 elt->pe_kind = TYPE_E; in parse_pnp_list()
351 elt->pe_kind = TYPE_T; in parse_pnp_list()
359 if (elt->pe_kind & TYPE_INT) { in parse_pnp_list()
360 elt->pe_offset = roundup2(elt->pe_offset, elt->pe_kind & TYPE_SZ_MASK); in parse_pnp_list()
361 off = elt->pe_offset + (elt->pe_kind & TYPE_SZ_MASK); in parse_pnp_list()
362 } else if (elt->pe_kind == TYPE_E) { in parse_pnp_list()
364 elt->pe_offset = roundup2(elt->pe_offset, sizeof(uint32_t)); in parse_pnp_list()
365 off = elt->pe_offset + sizeof(uint32_t); in parse_pnp_list()
366 } else if (elt->pe_kind == TYPE_T) { in parse_pnp_list()
368 off = elt->pe_offset; in parse_pnp_list()
370 elt->pe_offset = roundup2(elt->pe_offset, elf_pointer_size(ef)); in parse_pnp_list()
371 off = elt->pe_offset + elf_pointer_size(ef); in parse_pnp_list()
373 if (elt->pe_kind & TYPE_PAIRED) { in parse_pnp_list()
378 newtype = elt->pe_kind & TYPE_FLAGGED ? 'J' : 'I'; in parse_pnp_list()
385 if (elt->pe_kind & TYPE_FLAGGED) in parse_pnp_list()
387 else if (elt->pe_kind & TYPE_GE) in parse_pnp_list()
389 else if (elt->pe_kind & TYPE_LE) in parse_pnp_list()
391 else if (elt->pe_kind & TYPE_MASK) in parse_pnp_list()
393 else if (elt->pe_kind & TYPE_INT) in parse_pnp_list()
395 else if (elt->pe_kind == TYPE_D) in parse_pnp_list()
397 else if (elt->pe_kind == TYPE_Z || elt->pe_kind == TYPE_E) in parse_pnp_list()
399 else if (elt->pe_kind == TYPE_T) in parse_pnp_list()
402 errx(1, "Impossible type %x\n", elt->pe_kind); in parse_pnp_list()
411 errx(1, "Failed to close memory stream"); in parse_pnp_list()
456 if (elt->pe_kind == TYPE_W32) { in parse_pnp_entry()
457 v4 = parse_32(walker + elt->pe_offset); in parse_pnp_entry()
466 } else if (elt->pe_kind & TYPE_INT) { in parse_pnp_entry()
467 switch (elt->pe_kind & TYPE_SZ_MASK) { in parse_pnp_entry()
469 memcpy(&v1, walker + elt->pe_offset, sizeof(v1)); in parse_pnp_entry()
470 if ((elt->pe_kind & TYPE_FLAGGED) && v1 == 0xff) in parse_pnp_entry()
471 value = -1; in parse_pnp_entry()
476 v2 = parse_16(walker + elt->pe_offset); in parse_pnp_entry()
477 if ((elt->pe_kind & TYPE_FLAGGED) && v2 == 0xffff) in parse_pnp_entry()
478 value = -1; in parse_pnp_entry()
483 v4 = parse_32(walker + elt->pe_offset); in parse_pnp_entry()
484 if ((elt->pe_kind & TYPE_FLAGGED) && v4 == 0xffffffff) in parse_pnp_entry()
485 value = -1; in parse_pnp_entry()
490 errx(1, "Invalid size somehow %#x", elt->pe_kind); in parse_pnp_entry()
495 } else if (elt->pe_kind == TYPE_T) { in parse_pnp_entry()
497 } else { /* E, Z or D -- P already filtered */ in parse_pnp_entry()
498 if (elt->pe_kind == TYPE_E) { in parse_pnp_entry()
499 v4 = parse_32(walker + elt->pe_offset); in parse_pnp_entry()
505 elt->pe_offset); in parse_pnp_entry()
510 buffer[sizeof(buffer) - 1] = '\0'; in parse_pnp_entry()
514 printf("%c:%s;", elt->pe_kind == TYPE_E ? 'E' : in parse_pnp_entry()
515 (elt->pe_kind == TYPE_Z ? 'Z' : 'D'), buffer); in parse_pnp_entry()
533 cval, descr, pnp->num_entry, pnp->entry_len); in record_pnp_info()
543 record_int(pnp->num_entry); in record_pnp_info()
544 len = pnp->num_entry * pnp->entry_len; in record_pnp_info()
545 error = elf_read_relocated_data(ef, pnp->table, len, &table); in record_pnp_info()
556 for (i = 0; i < pnp->num_entry; i++) { in record_pnp_info()
562 walker += pnp->entry_len; in record_pnp_info()
581 data = md->md_data; in parse_entry()
584 switch (md->md_type) { in parse_entry()
623 warnx("unknown metadata record %d in file %s", md->md_type, kldname); in parse_entry()
653 warnx("%s does not match architecture of %s", in read_kld()
664 * ordered first in the output linker.hints stream because it in read_kld()
666 * in the stream. Other MDTs only make sense in the context of in read_kld()
673 * file-scope objects is left implementation-defined. There is in read_kld()
742 "usage: kldxref [-Rdv] [-f hintsfile] path ..." in usage()
755 if ((*a)->fts_info == FTS_D && (*b)->fts_info != FTS_D) in compare()
757 if ((*a)->fts_info != FTS_D && (*b)->fts_info == FTS_D) in compare()
758 return (-1); in compare()
759 return (strcmp((*a)->fts_name, (*b)->fts_name)); in compare()
773 while ((opt = getopt(argc, argv, "Rdf:v")) != -1) { in main()
792 if (argc - optind < 1) in main()
794 argc -= optind; in main()
813 if ((p == NULL || p->fts_info == FTS_D) && fxref) { in main()
827 if (p->fts_info == FTS_D && !dflag) { in main()
830 ftsp->fts_path, xref_file); in main()
831 fxref = maketempfile(tempname, ftsp->fts_path); in main()
837 /* skip non-files.. */ in main()
838 if (p->fts_info != FTS_F) in main()
845 dot = strrchr(p->fts_name, '.'); in main()
848 read_kld(p->fts_path, p->fts_name); in main()