Print this page
4839 3294 generated elfdump struct layouts by hand, shouldn't have


   6  * You may not use this file except in compliance with the License.
   7  *
   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 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 
  28 
  29 #include <stdlib.h>
  30 #include <stddef.h>
  31 #include <stdio.h>
  32 #include <string.h>
  33 #include <fcntl.h>
  34 #include <sys/types.h>
  35 #include <sys/stat.h>
  36 #include <unistd.h>
  37 #include <sys/sysmacros.h>
  38 #include <sys/corectl.h>
  39 #include <procfs.h>
  40 #include <sys/auxv.h>
  41 #include <sys/old_procfs.h>
  42 #include <sys/utsname.h>
  43 
  44 
  45 
  46 /*
  47  * This standalone program is used to generate the contents


 539         SCALAR_FIELD(timestruc_t,       tv_nsec,        0);
 540 
 541         END;
 542 }
 543 
 544 /* struct utsname, <sys/utsname.h> */
 545 static void
 546 gen_utsname(void)
 547 {
 548         START(utsname, struct utsname);
 549 
 550         ARRAY_FIELD(struct utsname,     sysname,        0);
 551         ARRAY_FIELD(struct utsname,     nodename,       0);
 552         ARRAY_FIELD(struct utsname,     release,        0);
 553         ARRAY_FIELD(struct utsname,     version,        0);
 554         ARRAY_FIELD(struct utsname,     machine,        0);
 555 
 556         END;
 557 }
 558 























 559 
 560 /*ARGSUSED*/
 561 int
 562 main(int argc, char *argv[])
 563 {
 564         const char *fmt = "\t&%s_layout,\n";
 565 
 566         printf("#include <struct_layout.h>\n");
 567 
 568         gen_auxv();
 569         gen_prgregset();
 570         gen_lwpstatus();
 571         gen_pstatus();
 572         gen_prstatus();
 573         gen_psinfo();
 574         gen_prpsinfo();
 575         gen_lwpsinfo();
 576         gen_prcred();
 577         gen_prpriv();
 578         gen_priv_impl_info();
 579         gen_fltset();
 580         gen_siginfo();
 581         gen_sigset();
 582         gen_sigaction();
 583         gen_stack();
 584         gen_sysset();
 585         gen_timestruc();
 586         gen_utsname();

 587 
 588 
 589         /*
 590          * Generate the full arch_layout description
 591          */
 592         (void) printf(
 593             "\n\n\n\nstatic const sl_arch_layout_t layout_%s = {\n",
 594             MACH);
 595         (void) printf(fmt, "auxv");
 596         (void) printf(fmt, "fltset");
 597         (void) printf(fmt, "lwpsinfo");
 598         (void) printf(fmt, "lwpstatus");
 599         (void) printf(fmt, "prcred");
 600         (void) printf(fmt, "priv_impl_info");
 601         (void) printf(fmt, "prpriv");
 602         (void) printf(fmt, "psinfo");
 603         (void) printf(fmt, "pstatus");
 604         (void) printf(fmt, "prgregset");
 605         (void) printf(fmt, "prpsinfo");
 606         (void) printf(fmt, "prstatus");
 607         (void) printf(fmt, "sigaction");
 608         (void) printf(fmt, "siginfo");
 609         (void) printf(fmt, "sigset");
 610         (void) printf(fmt, "stack");
 611         (void) printf(fmt, "sysset");
 612         (void) printf(fmt, "timestruc");
 613         (void) printf(fmt, "utsname");

 614         (void) printf("};\n");
 615 
 616         /*
 617          * A public function, to make the information available
 618          */
 619         (void) printf("\n\nconst sl_arch_layout_t *\n");
 620         (void) printf("struct_layout_%s(void)\n", MACH);
 621         (void) printf("{\n\treturn (&layout_%s);\n}\n", MACH);
 622 
 623         return (0);
 624 }


   6  * You may not use this file except in compliance with the License.
   7  *
   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 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */


  26 
  27 #include <stdlib.h>
  28 #include <stddef.h>
  29 #include <stdio.h>
  30 #include <string.h>
  31 #include <fcntl.h>
  32 #include <sys/types.h>
  33 #include <sys/stat.h>
  34 #include <unistd.h>
  35 #include <sys/sysmacros.h>
  36 #include <sys/corectl.h>
  37 #include <procfs.h>
  38 #include <sys/auxv.h>
  39 #include <sys/old_procfs.h>
  40 #include <sys/utsname.h>
  41 
  42 
  43 
  44 /*
  45  * This standalone program is used to generate the contents


 537         SCALAR_FIELD(timestruc_t,       tv_nsec,        0);
 538 
 539         END;
 540 }
 541 
 542 /* struct utsname, <sys/utsname.h> */
 543 static void
 544 gen_utsname(void)
 545 {
 546         START(utsname, struct utsname);
 547 
 548         ARRAY_FIELD(struct utsname,     sysname,        0);
 549         ARRAY_FIELD(struct utsname,     nodename,       0);
 550         ARRAY_FIELD(struct utsname,     release,        0);
 551         ARRAY_FIELD(struct utsname,     version,        0);
 552         ARRAY_FIELD(struct utsname,     machine,        0);
 553 
 554         END;
 555 }
 556 
 557 static void
 558 gen_prfdinfo(void)
 559 {
 560         START(prfdinfo, prfdinfo_t);
 561 
 562         SCALAR_FIELD(prfdinfo_t,        pr_fd,          0);
 563         SCALAR_FIELD(prfdinfo_t,        pr_mode,        0);
 564         SCALAR_FIELD(prfdinfo_t,        pr_uid,         0);
 565         SCALAR_FIELD(prfdinfo_t,        pr_gid,         0);
 566         SCALAR_FIELD(prfdinfo_t,        pr_major,       0);
 567         SCALAR_FIELD(prfdinfo_t,        pr_minor,       0);
 568         SCALAR_FIELD(prfdinfo_t,        pr_rmajor,      0);
 569         SCALAR_FIELD(prfdinfo_t,        pr_rminor,      0);
 570         SCALAR_FIELD(prfdinfo_t,        pr_ino,         0);
 571         SCALAR_FIELD(prfdinfo_t,        pr_offset,      0);
 572         SCALAR_FIELD(prfdinfo_t,        pr_size,        0);
 573         SCALAR_FIELD(prfdinfo_t,        pr_fileflags,   0);
 574         SCALAR_FIELD(prfdinfo_t,        pr_fdflags,     0);
 575         ARRAY_FIELD(prfdinfo_t,         pr_path,        0);
 576 
 577         END;
 578 }
 579 
 580 
 581 /*ARGSUSED*/
 582 int
 583 main(int argc, char *argv[])
 584 {
 585         const char *fmt = "\t&%s_layout,\n";
 586 
 587         printf("#include <struct_layout.h>\n");
 588 
 589         gen_auxv();
 590         gen_prgregset();
 591         gen_lwpstatus();
 592         gen_pstatus();
 593         gen_prstatus();
 594         gen_psinfo();
 595         gen_prpsinfo();
 596         gen_lwpsinfo();
 597         gen_prcred();
 598         gen_prpriv();
 599         gen_priv_impl_info();
 600         gen_fltset();
 601         gen_siginfo();
 602         gen_sigset();
 603         gen_sigaction();
 604         gen_stack();
 605         gen_sysset();
 606         gen_timestruc();
 607         gen_utsname();
 608         gen_prfdinfo();
 609 
 610 
 611         /*
 612          * Generate the full arch_layout description
 613          */
 614         (void) printf(
 615             "\n\n\n\nstatic const sl_arch_layout_t layout_%s = {\n",
 616             MACH);
 617         (void) printf(fmt, "auxv");
 618         (void) printf(fmt, "fltset");
 619         (void) printf(fmt, "lwpsinfo");
 620         (void) printf(fmt, "lwpstatus");
 621         (void) printf(fmt, "prcred");
 622         (void) printf(fmt, "priv_impl_info");
 623         (void) printf(fmt, "prpriv");
 624         (void) printf(fmt, "psinfo");
 625         (void) printf(fmt, "pstatus");
 626         (void) printf(fmt, "prgregset");
 627         (void) printf(fmt, "prpsinfo");
 628         (void) printf(fmt, "prstatus");
 629         (void) printf(fmt, "sigaction");
 630         (void) printf(fmt, "siginfo");
 631         (void) printf(fmt, "sigset");
 632         (void) printf(fmt, "stack");
 633         (void) printf(fmt, "sysset");
 634         (void) printf(fmt, "timestruc");
 635         (void) printf(fmt, "utsname");
 636         (void) printf(fmt, "prfdinfo");
 637         (void) printf("};\n");
 638 
 639         /*
 640          * A public function, to make the information available
 641          */
 642         (void) printf("\n\nconst sl_arch_layout_t *\n");
 643         (void) printf("struct_layout_%s(void)\n", MACH);
 644         (void) printf("{\n\treturn (&layout_%s);\n}\n", MACH);
 645 
 646         return (0);
 647 }