Merge illumos-gate
[unleashed/lotheac.git] / usr / src / cmd / abi / appcert / static_prof / static_prof.h
blobd5c5db9b576f7ebc4b6f0daee29f645cbd294dc2
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1998-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #ifndef _STATIC_PROF_H
28 #define _STATIC_PROF_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
37 * include headers
40 #include <stdio.h>
41 #include <string.h>
42 #include <stdlib.h>
43 #include <unistd.h>
44 #include <fcntl.h>
45 #include <libelf.h>
46 #include <link.h>
47 #include <sys/elf_SPARC.h>
48 #include <sys/utsname.h>
49 #include <errno.h>
52 * Declaration of global variables
55 #define DEFBKTS 24997 /* 3571 nice big prime number */
56 #define MASK (~(unsigned long)0<<28)
59 * bucket struct of hash table
61 typedef struct binding_bucket
63 char *sym;
64 char *ref_lib;
65 char *def_lib;
66 char *obj;
67 char *section;
68 char *sttype;
69 char *stbind;
70 } binding_bucket;
72 static binding_bucket bkts[DEFBKTS];
75 * data structure for linked list of DT_NEEDED entries
77 typedef struct dt_list_tag
79 char *libname;
80 #if defined(_LP64)
81 Elf64_Sword d_tag;
82 #else
83 Elf32_Sword d_tag;
84 #endif
85 struct dt_list_tag *next;
86 } dt_list;
88 static dt_list *dt_needed = NULL; /* ptr to link list of dtneeded */
91 * struct for the binary object under test
93 typedef struct obj_com
95 char **filenames; /* name of application file */
96 char *filename;
97 int numfiles; /* number of applications to check */
98 /* ---Current application ELF file information--- */
99 char *ename; /* name of current ELF file */
100 int fd; /* file descriptor for current file */
101 Elf *elf; /* elf descriptor for current file */
102 #if defined(_LP64)
103 Elf64_Ehdr *ehdr; /* 64 bit elf header for current file */
104 Elf64_Phdr *phdr; /* 64 bit prog header for current file */
105 Elf64_Dyn *dynsect; /* pointer to 64 bit dynamic section */
106 #else
107 Elf32_Ehdr *ehdr; /* 32 bit elf header for current file */
108 Elf32_Phdr *phdr; /* 32 bit prog header for current file */
109 Elf32_Dyn *dynsect; /* ptr to 64 bit dynamic section */
110 #endif
111 Elf_Data *ddata; /* ptr to dstring table data descriptor */
112 char *dynnames; /* pointer to dynamic string table */
113 /* ---ELF file symbol table information--- */
114 /* dynamic symbol table */
115 #if defined(_LP64)
116 Elf64_Sym *dsym_tab;
117 #else
118 Elf32_Sym *dsym_tab;
119 #endif
120 Elf_Data *dsym_data;
121 int dsym_num;
122 char *dsym_names;
123 /* regular symbol table */
124 #if defined(_LP64)
125 Elf64_Sym *sym_tab;
126 #else
127 Elf32_Sym *sym_tab;
128 #endif
129 Elf_Data *sym_data;
130 int sym_num;
131 char *sym_names;
132 } obj_com;
135 * struct of the linked list of object files
137 typedef struct obj_list_tag
139 obj_com *obj;
140 struct obj_list_tag *next;
141 } obj_list;
143 static int oflag = 0; /* flag for redirecting output */
144 static int pflag = 0; /* flag for profiling to stdout */
145 static int sflag = 1; /* flag for silent mode */
146 static int aflag = 1; /* flag for read input as archive */
147 extern int errno; /* file opening error return code */
148 static FILE *OUTPUT_FD; /* output fd: default as stdout */
149 static char *outputfile; /* full pathname of output file */
151 #define SUCCEED 0
152 #define FAIL 1
154 #define TRUE 1
155 #define FALSE 0
157 #ifdef __cplusplus
159 #endif
161 #endif /* _STATIC_PROF_H */