Print this page
OS-7095 Want risc-v disassembler

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/dis/dis_main.c
          +++ new/usr/src/cmd/dis/dis_main.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   *
  26   26   * Copyright 2011 Jason King.  All rights reserved.
  27   27   * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
  28   28   * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
       29 + * Copyright 2018, Joyent, Inc.
  29   30   */
  30   31  
  31   32  #include <ctype.h>
  32   33  #include <getopt.h>
  33   34  #include <stdio.h>
  34   35  #include <stdlib.h>
  35   36  #include <string.h>
  36   37  #include <sys/sysmacros.h>
  37   38  #include <sys/elf_SPARC.h>
  38   39  
↓ open down ↓ 531 lines elided ↑ open up ↑
 570  571                                  g_flags |= DIS_S390_64;
 571  572                          } else {
 572  573                                  warn("invalid E_IDENT field for S390 object");
 573  574                                  return;
 574  575                          }
 575  576  
 576  577                          if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB) {
 577  578                                  warn("invalid E_IDENT field for S390 object");
 578  579                                  return;
 579  580                          }
      581 +                        break;
      582 +
      583 +                case EM_RISCV:
      584 +                        /*
      585 +                         * RISC-V is defined to be litle endian. The current ISA
      586 +                         * makes it clear that the 64-bit instructions can
      587 +                         * co-eixst with the 32-bit ones and therefore we don't
      588 +                         * need a separate elf class at this time.
      589 +                         */
      590 +                        if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
      591 +                                warn("invalid EI_DATA field for RISC-V object");
      592 +                                return;
      593 +                        }
      594 +
      595 +                        if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
      596 +                                g_flags |= DIS_RISCV_32;
      597 +                        } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
      598 +                                g_flags |= DIS_RISCV_64;
      599 +                        } else {
      600 +                                warn("invalid EI_CLASS field for RISC-V "
      601 +                                    "object");
      602 +                                return;
      603 +                        }
 580  604                          break;
 581  605  
 582  606                  default:
 583  607                          die("%s: unsupported ELF machine 0x%x", filename,
 584  608                              ehdr.e_machine);
 585  609                  }
 586  610  
 587  611                  /*
 588  612                   * If ET_REL (.o), printing immediate symbols is likely to
 589  613                   * result in garbage, as symbol lookups on unrelocated
↓ open down ↓ 178 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX