]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - cddl/contrib/opensolaris/tools/ctf/common/symbol.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / cddl / contrib / opensolaris / tools / ctf / common / symbol.c
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 #pragma ident   "%Z%%M% %I%     %E% SMI"
28
29 #include <sys/types.h>
30 #include <string.h>
31
32 #include "symbol.h"
33
34 int
35 ignore_symbol(GElf_Sym *sym, const char *name)
36 {
37         uchar_t type = GELF_ST_TYPE(sym->st_info);
38
39         /*
40          * As an optimization, we do not output function or data object
41          * records for undefined or anonymous symbols.
42          */
43         if (sym->st_shndx == SHN_UNDEF || sym->st_name == 0)
44                 return (1);
45
46         /*
47          * _START_ and _END_ are added to the symbol table by the
48          * linker, and will never have associated type information.
49          */
50         if (strcmp(name, "_START_") == 0 || strcmp(name, "_END_") == 0)
51                 return (1);
52
53         /*
54          * Do not output records for absolute-valued object symbols
55          * that have value zero.  The compiler insists on generating
56          * things like this for __fsr_init_value settings, etc.
57          */
58         if (type == STT_OBJECT && sym->st_shndx == SHN_ABS &&
59             sym->st_value == 0)
60                 return (1);
61         return (0);
62 }