xref: /aosp_15_r20/external/ltp/tools/sparse/sparse-ltp.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (C) 2021 SUSE LLC <[email protected]>
4*49cdfc7eSAndroid Build Coastguard Worker  *
5*49cdfc7eSAndroid Build Coastguard Worker  * Sparse allows us to perform checks on the AST (struct symbol) or on
6*49cdfc7eSAndroid Build Coastguard Worker  * a linearized representation. In the latter case we are given a set
7*49cdfc7eSAndroid Build Coastguard Worker  * of entry points (functions) containing basic blocks of
8*49cdfc7eSAndroid Build Coastguard Worker  * instructions.
9*49cdfc7eSAndroid Build Coastguard Worker  *
10*49cdfc7eSAndroid Build Coastguard Worker  * The basic blocks contain byte code in SSA form. This is similar to
11*49cdfc7eSAndroid Build Coastguard Worker  * the intermediate representation most compilers use during
12*49cdfc7eSAndroid Build Coastguard Worker  * optimisation.
13*49cdfc7eSAndroid Build Coastguard Worker  */
14*49cdfc7eSAndroid Build Coastguard Worker #include <stdarg.h>
15*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
16*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
17*49cdfc7eSAndroid Build Coastguard Worker #include <string.h>
18*49cdfc7eSAndroid Build Coastguard Worker #include <ctype.h>
19*49cdfc7eSAndroid Build Coastguard Worker #include <unistd.h>
20*49cdfc7eSAndroid Build Coastguard Worker #include <fcntl.h>
21*49cdfc7eSAndroid Build Coastguard Worker 
22*49cdfc7eSAndroid Build Coastguard Worker #include "lib.h"
23*49cdfc7eSAndroid Build Coastguard Worker #include "allocate.h"
24*49cdfc7eSAndroid Build Coastguard Worker #include "opcode.h"
25*49cdfc7eSAndroid Build Coastguard Worker #include "token.h"
26*49cdfc7eSAndroid Build Coastguard Worker #include "parse.h"
27*49cdfc7eSAndroid Build Coastguard Worker #include "symbol.h"
28*49cdfc7eSAndroid Build Coastguard Worker #include "expression.h"
29*49cdfc7eSAndroid Build Coastguard Worker #include "linearize.h"
30*49cdfc7eSAndroid Build Coastguard Worker 
31*49cdfc7eSAndroid Build Coastguard Worker /* The rules for test, library and tool code are different */
32*49cdfc7eSAndroid Build Coastguard Worker enum ltp_tu_kind {
33*49cdfc7eSAndroid Build Coastguard Worker 	LTP_LIB,
34*49cdfc7eSAndroid Build Coastguard Worker 	LTP_OTHER,
35*49cdfc7eSAndroid Build Coastguard Worker };
36*49cdfc7eSAndroid Build Coastguard Worker 
37*49cdfc7eSAndroid Build Coastguard Worker static enum ltp_tu_kind tu_kind = LTP_OTHER;
38*49cdfc7eSAndroid Build Coastguard Worker 
39*49cdfc7eSAndroid Build Coastguard Worker /* Check for LTP-002
40*49cdfc7eSAndroid Build Coastguard Worker  *
41*49cdfc7eSAndroid Build Coastguard Worker  * Inspects the destination symbol of each store instruction. If it is
42*49cdfc7eSAndroid Build Coastguard Worker  * TST_RET or TST_ERR then emit a warning.
43*49cdfc7eSAndroid Build Coastguard Worker  */
check_lib_sets_TEST_vars(const struct instruction * insn)44*49cdfc7eSAndroid Build Coastguard Worker static void check_lib_sets_TEST_vars(const struct instruction *insn)
45*49cdfc7eSAndroid Build Coastguard Worker {
46*49cdfc7eSAndroid Build Coastguard Worker 	static struct ident *TST_RES_id, *TST_ERR_id;
47*49cdfc7eSAndroid Build Coastguard Worker 
48*49cdfc7eSAndroid Build Coastguard Worker 	if (!TST_RES_id) {
49*49cdfc7eSAndroid Build Coastguard Worker 		TST_RES_id = built_in_ident("TST_RET");
50*49cdfc7eSAndroid Build Coastguard Worker 		TST_ERR_id = built_in_ident("TST_ERR");
51*49cdfc7eSAndroid Build Coastguard Worker 	}
52*49cdfc7eSAndroid Build Coastguard Worker 
53*49cdfc7eSAndroid Build Coastguard Worker 	if (insn->opcode != OP_STORE)
54*49cdfc7eSAndroid Build Coastguard Worker 		return;
55*49cdfc7eSAndroid Build Coastguard Worker 	if (insn->src->ident != TST_RES_id &&
56*49cdfc7eSAndroid Build Coastguard Worker 	    insn->src->ident != TST_ERR_id)
57*49cdfc7eSAndroid Build Coastguard Worker 		return;
58*49cdfc7eSAndroid Build Coastguard Worker 
59*49cdfc7eSAndroid Build Coastguard Worker 	warning(insn->pos,
60*49cdfc7eSAndroid Build Coastguard Worker 		"LTP-002: Library should not write to TST_RET or TST_ERR");
61*49cdfc7eSAndroid Build Coastguard Worker }
62*49cdfc7eSAndroid Build Coastguard Worker 
do_basicblock_checks(struct basic_block * bb)63*49cdfc7eSAndroid Build Coastguard Worker static void do_basicblock_checks(struct basic_block *bb)
64*49cdfc7eSAndroid Build Coastguard Worker {
65*49cdfc7eSAndroid Build Coastguard Worker 	struct instruction *insn;
66*49cdfc7eSAndroid Build Coastguard Worker 
67*49cdfc7eSAndroid Build Coastguard Worker 	FOR_EACH_PTR(bb->insns, insn) {
68*49cdfc7eSAndroid Build Coastguard Worker 		if (!bb_reachable(insn->bb))
69*49cdfc7eSAndroid Build Coastguard Worker 			continue;
70*49cdfc7eSAndroid Build Coastguard Worker 
71*49cdfc7eSAndroid Build Coastguard Worker 		if (tu_kind == LTP_LIB)
72*49cdfc7eSAndroid Build Coastguard Worker 			check_lib_sets_TEST_vars(insn);
73*49cdfc7eSAndroid Build Coastguard Worker 	} END_FOR_EACH_PTR(insn);
74*49cdfc7eSAndroid Build Coastguard Worker }
75*49cdfc7eSAndroid Build Coastguard Worker 
do_entrypoint_checks(struct entrypoint * ep)76*49cdfc7eSAndroid Build Coastguard Worker static void do_entrypoint_checks(struct entrypoint *ep)
77*49cdfc7eSAndroid Build Coastguard Worker {
78*49cdfc7eSAndroid Build Coastguard Worker 	struct basic_block *bb;
79*49cdfc7eSAndroid Build Coastguard Worker 
80*49cdfc7eSAndroid Build Coastguard Worker 	FOR_EACH_PTR(ep->bbs, bb) {
81*49cdfc7eSAndroid Build Coastguard Worker 		do_basicblock_checks(bb);
82*49cdfc7eSAndroid Build Coastguard Worker 	} END_FOR_EACH_PTR(bb);
83*49cdfc7eSAndroid Build Coastguard Worker }
84*49cdfc7eSAndroid Build Coastguard Worker 
85*49cdfc7eSAndroid Build Coastguard Worker /* The old API can not comply with the rules. So when we see one of
86*49cdfc7eSAndroid Build Coastguard Worker  * these symbols we know that it will result in further
87*49cdfc7eSAndroid Build Coastguard Worker  * warnings. Probably these will suggest inappropriate things. Usually
88*49cdfc7eSAndroid Build Coastguard Worker  * these symbols should be removed and the new API used
89*49cdfc7eSAndroid Build Coastguard Worker  * instead. Otherwise they can be ignored until all tests have been
90*49cdfc7eSAndroid Build Coastguard Worker  * converted to the new API.
91*49cdfc7eSAndroid Build Coastguard Worker  */
check_symbol_deprecated(const struct symbol * const sym)92*49cdfc7eSAndroid Build Coastguard Worker static bool check_symbol_deprecated(const struct symbol *const sym)
93*49cdfc7eSAndroid Build Coastguard Worker {
94*49cdfc7eSAndroid Build Coastguard Worker 	static struct ident *TCID_id, *TST_TOTAL_id;
95*49cdfc7eSAndroid Build Coastguard Worker 	const struct ident *id = sym->ident;
96*49cdfc7eSAndroid Build Coastguard Worker 
97*49cdfc7eSAndroid Build Coastguard Worker 	if (!TCID_id) {
98*49cdfc7eSAndroid Build Coastguard Worker 		TCID_id = built_in_ident("TCID");
99*49cdfc7eSAndroid Build Coastguard Worker 		TST_TOTAL_id = built_in_ident("TST_TOTAL");
100*49cdfc7eSAndroid Build Coastguard Worker 	}
101*49cdfc7eSAndroid Build Coastguard Worker 
102*49cdfc7eSAndroid Build Coastguard Worker 	if (id != TCID_id && id != TST_TOTAL_id)
103*49cdfc7eSAndroid Build Coastguard Worker 		return false;
104*49cdfc7eSAndroid Build Coastguard Worker 
105*49cdfc7eSAndroid Build Coastguard Worker 	warning(sym->pos,
106*49cdfc7eSAndroid Build Coastguard Worker 		"Ignoring deprecated API symbol: '%s'. Should this code be converted to the new API?",
107*49cdfc7eSAndroid Build Coastguard Worker 		show_ident(id));
108*49cdfc7eSAndroid Build Coastguard Worker 
109*49cdfc7eSAndroid Build Coastguard Worker 	return true;
110*49cdfc7eSAndroid Build Coastguard Worker }
111*49cdfc7eSAndroid Build Coastguard Worker 
112*49cdfc7eSAndroid Build Coastguard Worker /* Check for LTP-003 and LTP-004
113*49cdfc7eSAndroid Build Coastguard Worker  *
114*49cdfc7eSAndroid Build Coastguard Worker  * Try to find cases where the static keyword was forgotten.
115*49cdfc7eSAndroid Build Coastguard Worker  */
check_symbol_visibility(const struct symbol * const sym)116*49cdfc7eSAndroid Build Coastguard Worker static void check_symbol_visibility(const struct symbol *const sym)
117*49cdfc7eSAndroid Build Coastguard Worker {
118*49cdfc7eSAndroid Build Coastguard Worker 	const unsigned long mod = sym->ctype.modifiers;
119*49cdfc7eSAndroid Build Coastguard Worker 	const char *const name = show_ident(sym->ident);
120*49cdfc7eSAndroid Build Coastguard Worker 	const int has_lib_prefix = !strncmp("tst_", name, 4) ||
121*49cdfc7eSAndroid Build Coastguard Worker 		!strncmp("TST_", name, 4) ||
122*49cdfc7eSAndroid Build Coastguard Worker 		!strncmp("ltp_", name, 4) ||
123*49cdfc7eSAndroid Build Coastguard Worker 		!strncmp("safe_", name, 5);
124*49cdfc7eSAndroid Build Coastguard Worker 
125*49cdfc7eSAndroid Build Coastguard Worker 	if (!(mod & MOD_TOPLEVEL))
126*49cdfc7eSAndroid Build Coastguard Worker 		return;
127*49cdfc7eSAndroid Build Coastguard Worker 
128*49cdfc7eSAndroid Build Coastguard Worker 	if (has_lib_prefix && (mod & MOD_STATIC) && !(mod & MOD_INLINE)) {
129*49cdfc7eSAndroid Build Coastguard Worker 		warning(sym->pos,
130*49cdfc7eSAndroid Build Coastguard Worker 			"LTP-003: Symbol '%s' has the LTP public library prefix, but is static (private).",
131*49cdfc7eSAndroid Build Coastguard Worker 			name);
132*49cdfc7eSAndroid Build Coastguard Worker 		return;
133*49cdfc7eSAndroid Build Coastguard Worker 	}
134*49cdfc7eSAndroid Build Coastguard Worker 
135*49cdfc7eSAndroid Build Coastguard Worker 	if ((mod & MOD_STATIC))
136*49cdfc7eSAndroid Build Coastguard Worker 		return;
137*49cdfc7eSAndroid Build Coastguard Worker 
138*49cdfc7eSAndroid Build Coastguard Worker 	if (tu_kind == LTP_LIB && !has_lib_prefix) {
139*49cdfc7eSAndroid Build Coastguard Worker 		warning(sym->pos,
140*49cdfc7eSAndroid Build Coastguard Worker 			"LTP-003: Symbol '%s' is a public library function, but is missing the 'tst_' prefix",
141*49cdfc7eSAndroid Build Coastguard Worker 			name);
142*49cdfc7eSAndroid Build Coastguard Worker 		return;
143*49cdfc7eSAndroid Build Coastguard Worker 	}
144*49cdfc7eSAndroid Build Coastguard Worker 
145*49cdfc7eSAndroid Build Coastguard Worker 	if (sym->same_symbol)
146*49cdfc7eSAndroid Build Coastguard Worker 		return;
147*49cdfc7eSAndroid Build Coastguard Worker 
148*49cdfc7eSAndroid Build Coastguard Worker 	if (sym->ident == &main_ident)
149*49cdfc7eSAndroid Build Coastguard Worker 		return;
150*49cdfc7eSAndroid Build Coastguard Worker 
151*49cdfc7eSAndroid Build Coastguard Worker 	warning(sym->pos,
152*49cdfc7eSAndroid Build Coastguard Worker 		"Symbol '%s' has no prototype or library ('tst_') prefix. Should it be static?",
153*49cdfc7eSAndroid Build Coastguard Worker 		name);
154*49cdfc7eSAndroid Build Coastguard Worker }
155*49cdfc7eSAndroid Build Coastguard Worker 
156*49cdfc7eSAndroid Build Coastguard Worker /* See base_type() in dissect.c */
unwrap_base_type(const struct symbol * sym)157*49cdfc7eSAndroid Build Coastguard Worker static struct symbol *unwrap_base_type(const struct symbol *sym)
158*49cdfc7eSAndroid Build Coastguard Worker {
159*49cdfc7eSAndroid Build Coastguard Worker 	switch (sym->ctype.base_type->type) {
160*49cdfc7eSAndroid Build Coastguard Worker 	case SYM_ARRAY:
161*49cdfc7eSAndroid Build Coastguard Worker 	case SYM_NODE:
162*49cdfc7eSAndroid Build Coastguard Worker 	case SYM_PTR:
163*49cdfc7eSAndroid Build Coastguard Worker 		return unwrap_base_type(sym->ctype.base_type);
164*49cdfc7eSAndroid Build Coastguard Worker 	default:
165*49cdfc7eSAndroid Build Coastguard Worker 		return sym->ctype.base_type;
166*49cdfc7eSAndroid Build Coastguard Worker 	}
167*49cdfc7eSAndroid Build Coastguard Worker }
168*49cdfc7eSAndroid Build Coastguard Worker 
169*49cdfc7eSAndroid Build Coastguard Worker /* Checks if some struct array initializer is terminated with a blank
170*49cdfc7eSAndroid Build Coastguard Worker  * (zeroed) item i.e. {}
171*49cdfc7eSAndroid Build Coastguard Worker  */
is_terminated_with_null_struct(const struct symbol * const sym)172*49cdfc7eSAndroid Build Coastguard Worker static bool is_terminated_with_null_struct(const struct symbol *const sym)
173*49cdfc7eSAndroid Build Coastguard Worker {
174*49cdfc7eSAndroid Build Coastguard Worker 	const struct expression *const arr_init = sym->initializer;
175*49cdfc7eSAndroid Build Coastguard Worker 	const struct expression *item_init =
176*49cdfc7eSAndroid Build Coastguard Worker 		last_ptr_list((struct ptr_list *)arr_init->expr_list);
177*49cdfc7eSAndroid Build Coastguard Worker 
178*49cdfc7eSAndroid Build Coastguard Worker 	if (item_init->type == EXPR_POS)
179*49cdfc7eSAndroid Build Coastguard Worker 		item_init = item_init->init_expr;
180*49cdfc7eSAndroid Build Coastguard Worker 
181*49cdfc7eSAndroid Build Coastguard Worker 	if (item_init->type != EXPR_INITIALIZER)
182*49cdfc7eSAndroid Build Coastguard Worker 		return false;
183*49cdfc7eSAndroid Build Coastguard Worker 
184*49cdfc7eSAndroid Build Coastguard Worker 	return ptr_list_empty((struct ptr_list *)item_init->expr_list);
185*49cdfc7eSAndroid Build Coastguard Worker }
186*49cdfc7eSAndroid Build Coastguard Worker 
187*49cdfc7eSAndroid Build Coastguard Worker /* LTP-005: Check array sentinel value
188*49cdfc7eSAndroid Build Coastguard Worker  *
189*49cdfc7eSAndroid Build Coastguard Worker  * This is most important for the tags array. It is only accessed when
190*49cdfc7eSAndroid Build Coastguard Worker  * the test fails. So we perform a static check to ensure it ends with
191*49cdfc7eSAndroid Build Coastguard Worker  * {}.
192*49cdfc7eSAndroid Build Coastguard Worker  */
check_struct_array_initializer(const struct symbol * const sym)193*49cdfc7eSAndroid Build Coastguard Worker static void check_struct_array_initializer(const struct symbol *const sym)
194*49cdfc7eSAndroid Build Coastguard Worker {
195*49cdfc7eSAndroid Build Coastguard Worker 	if (is_terminated_with_null_struct(sym))
196*49cdfc7eSAndroid Build Coastguard Worker 		return;
197*49cdfc7eSAndroid Build Coastguard Worker 
198*49cdfc7eSAndroid Build Coastguard Worker 	warning(sym->pos,
199*49cdfc7eSAndroid Build Coastguard Worker 		"LTP-005: Struct array doesn't appear to be null-terminated; did you forget to add '{}' as the final entry?");
200*49cdfc7eSAndroid Build Coastguard Worker }
201*49cdfc7eSAndroid Build Coastguard Worker 
202*49cdfc7eSAndroid Build Coastguard Worker /* Find struct tst_test test = { ... } and perform tests on its initializer */
check_test_struct(const struct symbol * const sym)203*49cdfc7eSAndroid Build Coastguard Worker static void check_test_struct(const struct symbol *const sym)
204*49cdfc7eSAndroid Build Coastguard Worker {
205*49cdfc7eSAndroid Build Coastguard Worker 	static struct ident *tst_test, *tst_test_test;
206*49cdfc7eSAndroid Build Coastguard Worker 	struct ident *ctype_name = NULL;
207*49cdfc7eSAndroid Build Coastguard Worker 	struct expression *init = sym->initializer;
208*49cdfc7eSAndroid Build Coastguard Worker 	struct expression *entry;
209*49cdfc7eSAndroid Build Coastguard Worker 
210*49cdfc7eSAndroid Build Coastguard Worker 	if (!sym->ctype.base_type)
211*49cdfc7eSAndroid Build Coastguard Worker 		return;
212*49cdfc7eSAndroid Build Coastguard Worker 
213*49cdfc7eSAndroid Build Coastguard Worker 	ctype_name = sym->ctype.base_type->ident;
214*49cdfc7eSAndroid Build Coastguard Worker 
215*49cdfc7eSAndroid Build Coastguard Worker 	if (!init)
216*49cdfc7eSAndroid Build Coastguard Worker 		return;
217*49cdfc7eSAndroid Build Coastguard Worker 
218*49cdfc7eSAndroid Build Coastguard Worker 	if (!tst_test_test) {
219*49cdfc7eSAndroid Build Coastguard Worker 		tst_test = built_in_ident("tst_test");
220*49cdfc7eSAndroid Build Coastguard Worker 		tst_test_test = built_in_ident("test");
221*49cdfc7eSAndroid Build Coastguard Worker 	}
222*49cdfc7eSAndroid Build Coastguard Worker 
223*49cdfc7eSAndroid Build Coastguard Worker 	if (sym->ident != tst_test_test)
224*49cdfc7eSAndroid Build Coastguard Worker 		return;
225*49cdfc7eSAndroid Build Coastguard Worker 
226*49cdfc7eSAndroid Build Coastguard Worker 	if (ctype_name != tst_test)
227*49cdfc7eSAndroid Build Coastguard Worker 		return;
228*49cdfc7eSAndroid Build Coastguard Worker 
229*49cdfc7eSAndroid Build Coastguard Worker 	FOR_EACH_PTR(init->expr_list, entry) {
230*49cdfc7eSAndroid Build Coastguard Worker 		if (entry->init_expr->type != EXPR_SYMBOL)
231*49cdfc7eSAndroid Build Coastguard Worker 			continue;
232*49cdfc7eSAndroid Build Coastguard Worker 
233*49cdfc7eSAndroid Build Coastguard Worker 		switch (entry->ctype->ctype.base_type->type) {
234*49cdfc7eSAndroid Build Coastguard Worker 		case SYM_PTR:
235*49cdfc7eSAndroid Build Coastguard Worker 		case SYM_ARRAY:
236*49cdfc7eSAndroid Build Coastguard Worker 			break;
237*49cdfc7eSAndroid Build Coastguard Worker 		default:
238*49cdfc7eSAndroid Build Coastguard Worker 			return;
239*49cdfc7eSAndroid Build Coastguard Worker 		}
240*49cdfc7eSAndroid Build Coastguard Worker 
241*49cdfc7eSAndroid Build Coastguard Worker 		const struct symbol *entry_init = entry->init_expr->symbol;
242*49cdfc7eSAndroid Build Coastguard Worker 		const struct symbol *entry_ctype = unwrap_base_type(entry_init);
243*49cdfc7eSAndroid Build Coastguard Worker 
244*49cdfc7eSAndroid Build Coastguard Worker 		if (entry_ctype->type == SYM_STRUCT)
245*49cdfc7eSAndroid Build Coastguard Worker 			check_struct_array_initializer(entry_init);
246*49cdfc7eSAndroid Build Coastguard Worker 	} END_FOR_EACH_PTR(entry);
247*49cdfc7eSAndroid Build Coastguard Worker 
248*49cdfc7eSAndroid Build Coastguard Worker }
249*49cdfc7eSAndroid Build Coastguard Worker 
250*49cdfc7eSAndroid Build Coastguard Worker /* AST level checks */
do_symbol_checks(struct symbol * sym)251*49cdfc7eSAndroid Build Coastguard Worker static void do_symbol_checks(struct symbol *sym)
252*49cdfc7eSAndroid Build Coastguard Worker {
253*49cdfc7eSAndroid Build Coastguard Worker 	if (check_symbol_deprecated(sym))
254*49cdfc7eSAndroid Build Coastguard Worker 		return;
255*49cdfc7eSAndroid Build Coastguard Worker 
256*49cdfc7eSAndroid Build Coastguard Worker 	check_symbol_visibility(sym);
257*49cdfc7eSAndroid Build Coastguard Worker 	check_test_struct(sym);
258*49cdfc7eSAndroid Build Coastguard Worker }
259*49cdfc7eSAndroid Build Coastguard Worker 
260*49cdfc7eSAndroid Build Coastguard Worker /* Compile the AST into a graph of basicblocks */
process_symbols(struct symbol_list * list)261*49cdfc7eSAndroid Build Coastguard Worker static void process_symbols(struct symbol_list *list)
262*49cdfc7eSAndroid Build Coastguard Worker {
263*49cdfc7eSAndroid Build Coastguard Worker 	struct symbol *sym;
264*49cdfc7eSAndroid Build Coastguard Worker 
265*49cdfc7eSAndroid Build Coastguard Worker 	FOR_EACH_PTR(list, sym) {
266*49cdfc7eSAndroid Build Coastguard Worker 		struct entrypoint *ep;
267*49cdfc7eSAndroid Build Coastguard Worker 
268*49cdfc7eSAndroid Build Coastguard Worker 		do_symbol_checks(sym);
269*49cdfc7eSAndroid Build Coastguard Worker 
270*49cdfc7eSAndroid Build Coastguard Worker 		expand_symbol(sym);
271*49cdfc7eSAndroid Build Coastguard Worker 		ep = linearize_symbol(sym);
272*49cdfc7eSAndroid Build Coastguard Worker 		if (!ep || !ep->entry)
273*49cdfc7eSAndroid Build Coastguard Worker 			continue;
274*49cdfc7eSAndroid Build Coastguard Worker 
275*49cdfc7eSAndroid Build Coastguard Worker 		do_entrypoint_checks(ep);
276*49cdfc7eSAndroid Build Coastguard Worker 
277*49cdfc7eSAndroid Build Coastguard Worker 		if (dbg_entry)
278*49cdfc7eSAndroid Build Coastguard Worker 			show_entry(ep);
279*49cdfc7eSAndroid Build Coastguard Worker 	} END_FOR_EACH_PTR(sym);
280*49cdfc7eSAndroid Build Coastguard Worker }
281*49cdfc7eSAndroid Build Coastguard Worker 
collect_info_from_args(const int argc,char * const * const argv)282*49cdfc7eSAndroid Build Coastguard Worker static void collect_info_from_args(const int argc, char *const *const argv)
283*49cdfc7eSAndroid Build Coastguard Worker {
284*49cdfc7eSAndroid Build Coastguard Worker 	int i;
285*49cdfc7eSAndroid Build Coastguard Worker 
286*49cdfc7eSAndroid Build Coastguard Worker 	for (i = 0; i < argc; i++) {
287*49cdfc7eSAndroid Build Coastguard Worker 		if (!strcmp("-DLTPLIB", argv[i]))
288*49cdfc7eSAndroid Build Coastguard Worker 			tu_kind = LTP_LIB;
289*49cdfc7eSAndroid Build Coastguard Worker 	}
290*49cdfc7eSAndroid Build Coastguard Worker }
291*49cdfc7eSAndroid Build Coastguard Worker 
main(int argc,char ** argv)292*49cdfc7eSAndroid Build Coastguard Worker int main(int argc, char **argv)
293*49cdfc7eSAndroid Build Coastguard Worker {
294*49cdfc7eSAndroid Build Coastguard Worker 	struct string_list *filelist = NULL;
295*49cdfc7eSAndroid Build Coastguard Worker 	char *file;
296*49cdfc7eSAndroid Build Coastguard Worker 
297*49cdfc7eSAndroid Build Coastguard Worker 	Waddress_space = 0;
298*49cdfc7eSAndroid Build Coastguard Worker 	Wbitwise = 0;
299*49cdfc7eSAndroid Build Coastguard Worker 	Wcast_truncate = 0;
300*49cdfc7eSAndroid Build Coastguard Worker 	Wcontext = 0;
301*49cdfc7eSAndroid Build Coastguard Worker 	Wdecl = 0;
302*49cdfc7eSAndroid Build Coastguard Worker 	Wexternal_function_has_definition = 0;
303*49cdfc7eSAndroid Build Coastguard Worker 	Wflexible_array_array = 0;
304*49cdfc7eSAndroid Build Coastguard Worker 	Wimplicit_int = 0;
305*49cdfc7eSAndroid Build Coastguard Worker 	Wint_to_pointer_cast = 0;
306*49cdfc7eSAndroid Build Coastguard Worker 	Wmemcpy_max_count = 0;
307*49cdfc7eSAndroid Build Coastguard Worker 	Wnon_pointer_null = 0;
308*49cdfc7eSAndroid Build Coastguard Worker 	Wone_bit_signed_bitfield = 0;
309*49cdfc7eSAndroid Build Coastguard Worker 	Woverride_init = 0;
310*49cdfc7eSAndroid Build Coastguard Worker 	Wpointer_to_int_cast = 0;
311*49cdfc7eSAndroid Build Coastguard Worker 	Wvla = 0;
312*49cdfc7eSAndroid Build Coastguard Worker 
313*49cdfc7eSAndroid Build Coastguard Worker 	do_output = 0;
314*49cdfc7eSAndroid Build Coastguard Worker 
315*49cdfc7eSAndroid Build Coastguard Worker 	collect_info_from_args(argc, argv);
316*49cdfc7eSAndroid Build Coastguard Worker 
317*49cdfc7eSAndroid Build Coastguard Worker 	process_symbols(sparse_initialize(argc, argv, &filelist));
318*49cdfc7eSAndroid Build Coastguard Worker 	FOR_EACH_PTR(filelist, file) {
319*49cdfc7eSAndroid Build Coastguard Worker 		process_symbols(sparse(file));
320*49cdfc7eSAndroid Build Coastguard Worker 	} END_FOR_EACH_PTR(file);
321*49cdfc7eSAndroid Build Coastguard Worker 
322*49cdfc7eSAndroid Build Coastguard Worker 	report_stats();
323*49cdfc7eSAndroid Build Coastguard Worker 	return 0;
324*49cdfc7eSAndroid Build Coastguard Worker }
325