Print this page
10827 some symbols have the wrong CTF type
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libctf/common/ctf_merge.c
          +++ new/usr/src/lib/libctf/common/ctf_merge.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright (c) 2019 Joyent, Inc.
       13 + * Copyright 2019, Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * To perform a merge of two CTF containers, we first diff the two containers
  18   18   * types. For every type that's in the src container, but not in the dst
  19   19   * container, we note it and add it to dst container. If there are any objects
  20   20   * or functions associated with src, we go through and update the types that
  21   21   * they refer to such that they all refer to types in the dst container.
  22   22   *
  23   23   * The bulk of the logic for the merge, after we've run the diff, occurs in
↓ open down ↓ 584 lines elided ↑ open up ↑
 608  608                  break;
 609  609          default:
 610  610                  VERIFY(0);
 611  611                  ret = CTF_ERR;
 612  612          }
 613  613  
 614  614          return (ret);
 615  615  }
 616  616  
 617  617  /*
 618      - * Now that we've successfully merged everything, we're going to clean
 619      - * up the merge type table. Traditionally if we had just two different
 620      - * files that we were working between, the types would be fully
 621      - * resolved. However, because we were comparing with ourself every step
 622      - * of the way and not our reduced self, we need to go through and update
 623      - * every mapped entry to what it now points to in the deduped file.
      618 + * Now that we've successfully merged everything, we're going to remap the type
      619 + * table.
      620 + *
      621 + * Remember we have two containers: ->cm_src is what we're working from, and
      622 + * ->cm_out is where we are building the de-duplicated CTF.
      623 + *
      624 + * The index of this table is always the type IDs in ->cm_src.
      625 + *
      626 + * When we built this table originally in ctf_diff_self(), if we found a novel
      627 + * type, we marked it as .cmt_missing to indicate it needs adding to ->cm_out.
      628 + * Otherwise, .cmt_map indicated the ->cm_src type ID that this type duplicates.
      629 + *
      630 + * Then, in ctf_merge_common(), we walked through and added all "cmt_missing"
      631 + * types to ->cm_out with ctf_merge_add_type(). These routines update cmt_map
      632 + * to be the *new* type ID in ->cm_out.  In this function, you can read
      633 + * "cmt_missing" as meaning "added to ->cm_out, and cmt_map updated".
      634 + *
      635 + * So at this point, we need to mop up all types where .cmt_missing == B_FALSE,
      636 + * making sure *their* .cmt_map values also point to the ->cm_out container.
 624  637   */
 625  638  static void
 626      -ctf_merge_fixup_dedup_map(ctf_merge_types_t *cmp)
      639 +ctf_merge_dedup_remap(ctf_merge_types_t *cmp)
 627  640  {
 628  641          int i;
 629  642  
 630  643          for (i = 1; i < cmp->cm_src->ctf_typemax + 1; i++) {
 631  644                  ctf_id_t tid;
 632  645  
 633      -                /*
 634      -                 * Missing types always have their id updated to exactly what it
 635      -                 * should be.
 636      -                 */
 637  646                  if (cmp->cm_tmap[i].cmt_missing == B_TRUE) {
 638  647                          VERIFY(cmp->cm_tmap[i].cmt_map != 0);
 639  648                          continue;
 640  649                  }
 641  650  
 642  651                  tid = i;
 643  652                  while (cmp->cm_tmap[tid].cmt_missing == B_FALSE) {
 644  653                          VERIFY(cmp->cm_tmap[tid].cmt_map != 0);
 645  654                          tid = cmp->cm_tmap[tid].cmt_map;
 646  655                  }
↓ open down ↓ 47 lines elided ↑ open up ↑
 694  703                                  return (ret);
 695  704                          }
 696  705                  }
 697  706          }
 698  707  
 699  708          ret = ctf_update(cmp->cm_out);
 700  709          if (ret != 0)
 701  710                  return (ret);
 702  711  
 703  712          if (cmp->cm_dedup == B_TRUE) {
 704      -                ctf_merge_fixup_dedup_map(cmp);
      713 +                ctf_merge_dedup_remap(cmp);
 705  714          }
 706  715  
 707  716          ctf_dprintf("Beginning merge pass 3\n");
 708  717          /* Pass 3 */
 709  718          for (i = 1; i <= cmp->cm_src->ctf_typemax; i++) {
 710  719                  if (cmp->cm_tmap[i].cmt_fixup == B_TRUE) {
 711  720                          ret = ctf_merge_fixup_type(cmp, i);
 712  721                          if (ret != 0)
 713  722                                  return (ret);
 714  723                  }
 715  724          }
 716  725  
 717      -        if (cmp->cm_dedup == B_TRUE) {
 718      -                ctf_merge_fixup_dedup_map(cmp);
 719      -        }
 720      -
 721  726          return (0);
 722  727  }
 723  728  
 724  729  /*
 725  730   * Uniquification is slightly different from a stock merge. For starters, we
 726  731   * don't need to replace any forward references in the output. In this case
 727  732   * though, the types that already exist are in a parent container to the empty
 728  733   * output container.
 729  734   */
 730  735  static int
↓ open down ↓ 943 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX