Print this page
6066 dis: support for System/370, System/390, and z/Architecture ELF bins
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/dis/dis_main.c
          +++ new/usr/src/cmd/dis/dis_main.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  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 + * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  28   29   */
  29   30  
  30   31  #include <ctype.h>
  31   32  #include <getopt.h>
  32   33  #include <stdio.h>
  33   34  #include <stdlib.h>
  34   35  #include <string.h>
  35   36  #include <sys/sysmacros.h>
  36   37  #include <sys/elf_SPARC.h>
  37   38  
↓ open down ↓ 501 lines elided ↑ open up ↑
 539  540                          break;
 540  541  
 541  542                  case EM_386:
 542  543                          g_flags |= DIS_X86_SIZE32;
 543  544                          break;
 544  545  
 545  546                  case EM_AMD64:
 546  547                          g_flags |= DIS_X86_SIZE64;
 547  548                          break;
 548  549  
      550 +                case EM_S370:
      551 +                        g_flags |= DIS_S370;
      552 +
      553 +                        if (ehdr.e_ident[EI_CLASS] != ELFCLASS32 ||
      554 +                            ehdr.e_ident[EI_DATA] != ELFDATA2MSB) {
      555 +                                warn("invalid E_IDENT field for S370 object");
      556 +                                return;
      557 +                        }
      558 +                        break;
      559 +
      560 +                case EM_S390:
      561 +                        /*
      562 +                         * Both 390 and z/Architecture use EM_S390, the only
      563 +                         * differences is the class: ELFCLASS32 for plain
      564 +                         * old s390 and ELFCLASS64 for z/Architecture (aka.
      565 +                         * s390x).
      566 +                         */
      567 +                        if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
      568 +                                g_flags |= DIS_S390_31;
      569 +                        } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
      570 +                                g_flags |= DIS_S390_64;
      571 +                        } else {
      572 +                                warn("invalid E_IDENT field for S390 object");
      573 +                                return;
      574 +                        }
      575 +
      576 +                        if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB) {
      577 +                                warn("invalid E_IDENT field for S390 object");
      578 +                                return;
      579 +                        }
      580 +                        break;
      581 +
 549  582                  default:
 550  583                          die("%s: unsupported ELF machine 0x%x", filename,
 551  584                              ehdr.e_machine);
 552  585                  }
 553  586  
 554  587                  /*
 555  588                   * If ET_REL (.o), printing immediate symbols is likely to
 556  589                   * result in garbage, as symbol lookups on unrelocated
 557  590                   * immediates find false and useless matches.
 558  591                   */
↓ open down ↓ 176 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX