summaryrefslogtreecommitdiff
path: root/usr/src/cmd/abi/appcert/static_prof/static_prof.h
blob: 62372cc8ee44082d6a4c5ad4a7c47602e761dd76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1998-2000 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_STATIC_PROF_H
#define	_STATIC_PROF_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * include headers
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <libelf.h>
#include <link.h>
#include <sys/elf_SPARC.h>
#include <sys/utsname.h>
#include <errno.h>

/*
 * Declaration of global variables
 */

#define	DEFBKTS		24997	/* 3571 nice big prime number */
#define	MASK		(~(unsigned long)0<<28)

/*
 * bucket struct of hash table
 */
typedef struct binding_bucket
{
	char			*sym;
	char			*ref_lib;
	char			*def_lib;
	char			*obj;
	char			*section;
	char			*sttype;
	char			*stbind;
} binding_bucket;

static binding_bucket	bkts[DEFBKTS];

/*
 * data structure for linked list of DT_NEEDED entries
 */
typedef struct dt_list_tag
{
	char			*libname;
#if	defined(_LP64)
	Elf64_Sword		d_tag;
#else
	Elf32_Sword		d_tag;
#endif
	struct dt_list_tag	*next;
} dt_list;

static dt_list		*dt_needed = NULL; /* ptr to link list of dtneeded */

/*
 * struct for the binary object under test
 */
typedef struct obj_com
{
	char		**filenames;	/* name of application file */
	char		*filename;
	int		numfiles;	/* number of applications to check */
	/* ---Current application ELF file information--- */
	char		*ename;	/* name of current ELF file */
	int		fd;	/* file descriptor for current file */
	Elf		*elf;	/* elf descriptor for current file */
#if	defined(_LP64)
	Elf64_Ehdr	*ehdr;	/* 64 bit elf header for current file */
	Elf64_Phdr	*phdr;	/* 64 bit prog header for current file */
	Elf64_Dyn	*dynsect;	/* pointer to 64 bit dynamic section */
#else
	Elf32_Ehdr    	*ehdr;	/* 32 bit elf header for current file */
	Elf32_Phdr    	*phdr;	/* 32 bit prog header for current file */
	Elf32_Dyn	*dynsect;	/* ptr to 64 bit dynamic section */
#endif
	Elf_Data	*ddata;	/* ptr to dstring table data descriptor */
	char		*dynnames; /* pointer to dynamic string table */
	/* ---ELF file symbol table information--- */
	/* dynamic symbol table */
#if	defined(_LP64)
	Elf64_Sym	*dsym_tab;
#else
	Elf32_Sym	*dsym_tab;
#endif
	Elf_Data	*dsym_data;
	int		dsym_num;
	char		*dsym_names;
	/* regular symbol table */
#if	defined(_LP64)
	Elf64_Sym	*sym_tab;
#else
	Elf32_Sym	*sym_tab;
#endif
	Elf_Data	*sym_data;
	int		sym_num;
	char		*sym_names;
} obj_com;

/*
 * struct of the linked list of object files
 */
typedef struct obj_list_tag
{
	obj_com		*obj;
	struct obj_list_tag	*next;
} obj_list;

static int	oflag = 0;		/* flag for redirecting output */
static int	pflag = 0;		/* flag for profiling to stdout */
static int	sflag = 1;		/* flag for silent mode */
static int	aflag = 1;		/* flag for read input as archive */
extern int	errno;			/* file opening error return code */
static FILE	*OUTPUT_FD = stdout;	/* output fd: default as stdout */
static char	*outputfile;		/* full pathname of output file */

#define	SUCCEED		0
#define	FAIL		1

#define	TRUE		1
#define	FALSE		0

#ifdef	__cplusplus
}
#endif

#endif	/* _STATIC_PROF_H */