xref: /illumos-gate/usr/src/tools/ctf/common/symbol.c (revision dd72704bd9e794056c558153663c739e2012d721)
1 /*
2  * CDDL HEADER START
3  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <sys/types.h>
28 #include <string.h>
29 
30 #include "symbol.h"
31 
32 int
33 ignore_symbol(GElf_Sym *sym, const char *name)
34 {
35 	uchar_t type = GELF_ST_TYPE(sym->st_info);
36 
37 	/*
38 	 * As an optimization, we do not output function or data object
39 	 * records for undefined or anonymous symbols.
40 	 */
41 	if (sym->st_shndx == SHN_UNDEF || sym->st_name == 0)
42 		return (1);
43 
44 	/*
45 	 * _START_ and _END_ are added to the symbol table by the
46 	 * linker, and will never have associated type information.
47 	 */
48 	if (strcmp(name, "_START_") == 0 || strcmp(name, "_END_") == 0)
49 		return (1);
50 
51 	/*
52 	 * Do not output records for absolute-valued object symbols
53 	 * that have value zero.  The compiler insists on generating
54 	 * things like this for __fsr_init_value settings, etc.
55 	 */
56 	if (type == STT_OBJECT && sym->st_shndx == SHN_ABS &&
57 	    sym->st_value == 0)
58 		return (1);
59 	return (0);
60 }
61