8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sgs / link_audit / common / symbindrep.c
blob344f61366fcc5f4da79128b6ecb9318679a8cbc4
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <link.h>
29 #include "env.h"
31 static Elist *bindto_list = NULL;
32 static Elist *bindfrom_list = NULL;
33 static FILE *output = stdout;
36 uint_t
37 la_version(uint_t version)
39 if (version < LAV_CURRENT) {
40 (void) fprintf(stderr,
41 "symbindrep.so: unexpected version: %d\n", version);
42 return (0);
45 build_env_list(&bindto_list, (const char *)"SYMBINDREP_BINDTO");
46 build_env_list(&bindfrom_list, (const char *)"SYMBINDREP_BINDFROM");
48 #ifdef _LP64
49 (void) fprintf(output,
50 " Symbol Bindings\n\n"
51 "Referencing Defining\n"
52 "Object Object Symbol\n"
53 "---------------------------------------------------------------"
54 "-------------------\n");
55 #else
56 (void) fprintf(output,
57 " Symbol Bindings\n\n"
58 "Referencing Defining\n"
59 "Object Object Symbol\n"
60 "---------------------------------------------------------------"
61 "---\n");
62 #endif
63 return (LAV_CURRENT);
66 /* ARGSUSED1 */
67 uint_t
68 la_objopen(Link_map *lmp, Lmid_t lmid, uintptr_t *cookie)
70 uint_t flags;
72 if ((bindto_list == NULL) ||
73 (check_list(bindto_list, lmp->l_name)))
74 flags = LA_FLG_BINDTO;
75 else
76 flags = 0;
78 if ((bindfrom_list == NULL) ||
79 (check_list(bindfrom_list, lmp->l_name)))
80 flags |= LA_FLG_BINDFROM;
82 *cookie = (uintptr_t)lmp->l_name;
83 return (flags);
87 /* ARGSUSED1 */
88 #if defined(_LP64)
89 uintptr_t
90 la_symbind64(Elf64_Sym *symp, uint_t symndx, uintptr_t *refcook,
91 uintptr_t *defcook, uint_t *sb_flags, const char *sym_name)
92 #else
93 uintptr_t
94 la_symbind32(Elf32_Sym *symp, uint_t symndx, uintptr_t *refcook,
95 uintptr_t *defcook, uint_t *sb_flags)
96 #endif
98 #if !defined(_LP64)
99 const char *sym_name = (const char *)symp->st_name;
100 #endif
102 (void) fprintf(output, "%-28s %-28s %s\n", (char *)(*refcook),
103 (char *)(*defcook), sym_name);
105 return (symp->st_value);
109 * Since we only want to report on the symbol bindings for this
110 * process and we *do not* want the actual program to run we exit
111 * at this point.
113 /* ARGSUSED0 */
114 void
115 la_preinit(uintptr_t *cookie)
117 (void) fflush(output);
118 exit(0);