xref: /netbsd-src/external/cddl/osnet/dist/tools/ctf/common/symbol.c (revision 89300bd9df17b74e8b6eaccab1411408c4acfe01)
1a864dc36Sdarran /*
2a864dc36Sdarran  * CDDL HEADER START
3a864dc36Sdarran  *
4a864dc36Sdarran  * The contents of this file are subject to the terms of the
5a864dc36Sdarran  * Common Development and Distribution License, Version 1.0 only
6a864dc36Sdarran  * (the "License").  You may not use this file except in compliance
7a864dc36Sdarran  * with the License.
8a864dc36Sdarran  *
9a864dc36Sdarran  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10a864dc36Sdarran  * or http://www.opensolaris.org/os/licensing.
11a864dc36Sdarran  * See the License for the specific language governing permissions
12a864dc36Sdarran  * and limitations under the License.
13a864dc36Sdarran  *
14a864dc36Sdarran  * When distributing Covered Code, include this CDDL HEADER in each
15a864dc36Sdarran  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16a864dc36Sdarran  * If applicable, add the following below this CDDL HEADER, with the
17a864dc36Sdarran  * fields enclosed by brackets "[]" replaced with your own identifying
18a864dc36Sdarran  * information: Portions Copyright [yyyy] [name of copyright owner]
19a864dc36Sdarran  *
20a864dc36Sdarran  * CDDL HEADER END
21a864dc36Sdarran  */
22a864dc36Sdarran /*
23a864dc36Sdarran  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24a864dc36Sdarran  * Use is subject to license terms.
25a864dc36Sdarran  */
26a864dc36Sdarran 
27a864dc36Sdarran #pragma ident	"%Z%%M%	%I%	%E% SMI"
28a864dc36Sdarran 
29*89300bd9Sdarran #if HAVE_NBTOOL_CONFIG_H
30*89300bd9Sdarran # include "nbtool_config.h"
31*89300bd9Sdarran #endif
32*89300bd9Sdarran 
33a864dc36Sdarran #include <sys/types.h>
34a864dc36Sdarran #include <string.h>
35a864dc36Sdarran 
36a864dc36Sdarran #include "symbol.h"
37a864dc36Sdarran 
38a864dc36Sdarran int
ignore_symbol(GElf_Sym * sym,const char * name)39a864dc36Sdarran ignore_symbol(GElf_Sym *sym, const char *name)
40a864dc36Sdarran {
41a864dc36Sdarran 	uchar_t type = GELF_ST_TYPE(sym->st_info);
42a864dc36Sdarran 
43a864dc36Sdarran 	/*
44a864dc36Sdarran 	 * As an optimization, we do not output function or data object
45a864dc36Sdarran 	 * records for undefined or anonymous symbols.
46a864dc36Sdarran 	 */
47a864dc36Sdarran 	if (sym->st_shndx == SHN_UNDEF || sym->st_name == 0)
48a864dc36Sdarran 		return (1);
49a864dc36Sdarran 
50a864dc36Sdarran 	/*
51a864dc36Sdarran 	 * _START_ and _END_ are added to the symbol table by the
52a864dc36Sdarran 	 * linker, and will never have associated type information.
53a864dc36Sdarran 	 */
54a864dc36Sdarran 	if (strcmp(name, "_START_") == 0 || strcmp(name, "_END_") == 0)
55a864dc36Sdarran 		return (1);
56a864dc36Sdarran 
57a864dc36Sdarran 	/*
58a864dc36Sdarran 	 * Do not output records for absolute-valued object symbols
59a864dc36Sdarran 	 * that have value zero.  The compiler insists on generating
60a864dc36Sdarran 	 * things like this for __fsr_init_value settings, etc.
61a864dc36Sdarran 	 */
62a864dc36Sdarran 	if (type == STT_OBJECT && sym->st_shndx == SHN_ABS &&
63a864dc36Sdarran 	    sym->st_value == 0)
64a864dc36Sdarran 		return (1);
65a864dc36Sdarran 	return (0);
66a864dc36Sdarran }
67