Print this page
6066 dis: support for System/370, System/390, and z/Architecture ELF bins


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright 2011 Jason King.  All rights reserved.
  27  * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>

  28  */
  29 
  30 #include <ctype.h>
  31 #include <getopt.h>
  32 #include <stdio.h>
  33 #include <stdlib.h>
  34 #include <string.h>
  35 #include <sys/sysmacros.h>
  36 #include <sys/elf_SPARC.h>
  37 
  38 #include <libdisasm.h>
  39 
  40 #include "dis_target.h"
  41 #include "dis_util.h"
  42 #include "dis_list.h"
  43 
  44 int g_demangle;         /* Demangle C++ names */
  45 int g_quiet;            /* Quiet mode */
  46 int g_numeric;          /* Numeric mode */
  47 int g_flags;            /* libdisasm language flags */


 527                                 g_flags |= DIS_SPARC_V9;
 528                         break;
 529                 }
 530 
 531                 case EM_SPARCV9:
 532                         if (ehdr.e_ident[EI_CLASS] != ELFCLASS64 ||
 533                             ehdr.e_ident[EI_DATA] != ELFDATA2MSB) {
 534                                 warn("invalid E_IDENT field for SPARC object");
 535                                 return;
 536                         }
 537 
 538                         g_flags |= DIS_SPARC_V9 | DIS_SPARC_V9_SGI;
 539                         break;
 540 
 541                 case EM_386:
 542                         g_flags |= DIS_X86_SIZE32;
 543                         break;
 544 
 545                 case EM_AMD64:
 546                         g_flags |= DIS_X86_SIZE64;


























 547                         break;
 548 
 549                 default:
 550                         die("%s: unsupported ELF machine 0x%x", filename,
 551                             ehdr.e_machine);
 552                 }
 553 
 554                 /*
 555                  * If ET_REL (.o), printing immediate symbols is likely to
 556                  * result in garbage, as symbol lookups on unrelocated
 557                  * immediates find false and useless matches.
 558                  */
 559 
 560                 if (ehdr.e_type == ET_REL)
 561                         g_flags |= DIS_NOIMMSYM;
 562 
 563                 if (!g_quiet && dis_tgt_member(current) != NULL)
 564                         (void) printf("\narchive member %s\n",
 565                             dis_tgt_member(current));
 566 




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright 2011 Jason King.  All rights reserved.
  27  * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
  28  * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  29  */
  30 
  31 #include <ctype.h>
  32 #include <getopt.h>
  33 #include <stdio.h>
  34 #include <stdlib.h>
  35 #include <string.h>
  36 #include <sys/sysmacros.h>
  37 #include <sys/elf_SPARC.h>
  38 
  39 #include <libdisasm.h>
  40 
  41 #include "dis_target.h"
  42 #include "dis_util.h"
  43 #include "dis_list.h"
  44 
  45 int g_demangle;         /* Demangle C++ names */
  46 int g_quiet;            /* Quiet mode */
  47 int g_numeric;          /* Numeric mode */
  48 int g_flags;            /* libdisasm language flags */


 528                                 g_flags |= DIS_SPARC_V9;
 529                         break;
 530                 }
 531 
 532                 case EM_SPARCV9:
 533                         if (ehdr.e_ident[EI_CLASS] != ELFCLASS64 ||
 534                             ehdr.e_ident[EI_DATA] != ELFDATA2MSB) {
 535                                 warn("invalid E_IDENT field for SPARC object");
 536                                 return;
 537                         }
 538 
 539                         g_flags |= DIS_SPARC_V9 | DIS_SPARC_V9_SGI;
 540                         break;
 541 
 542                 case EM_386:
 543                         g_flags |= DIS_X86_SIZE32;
 544                         break;
 545 
 546                 case EM_AMD64:
 547                         g_flags |= DIS_X86_SIZE64;
 548                         break;
 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                         if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
 562                                 g_flags |= DIS_S390_31;
 563                         } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
 564                                 g_flags |= DIS_S390_64;
 565                         } else {
 566                                 warn("invalid E_IDENT field for S390 object");
 567                                 return;
 568                         }
 569 
 570                         if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB) {
 571                                 warn("invalid E_IDENT field for S390 object");
 572                                 return;
 573                         }
 574                         break;
 575 
 576                 default:
 577                         die("%s: unsupported ELF machine 0x%x", filename,
 578                             ehdr.e_machine);
 579                 }
 580 
 581                 /*
 582                  * If ET_REL (.o), printing immediate symbols is likely to
 583                  * result in garbage, as symbol lookups on unrelocated
 584                  * immediates find false and useless matches.
 585                  */
 586 
 587                 if (ehdr.e_type == ET_REL)
 588                         g_flags |= DIS_NOIMMSYM;
 589 
 590                 if (!g_quiet && dis_tgt_member(current) != NULL)
 591                         (void) printf("\narchive member %s\n",
 592                             dis_tgt_member(current));
 593