xref: /titanic_44/usr/src/cmd/sgs/libelf/common/llib-lelf (revision 4a6ec905b96eb96a398c346f59e034a90ce8ad37)
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21/* LINTLIBRARY */
22/* PROTOLIB1 */
23
24/*
25 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
26 * Use is subject to license terms.
27 */
28
29#pragma ident	"%Z%%M%	%I%	%E% SMI"
30
31/*
32 * Generic interface definition for usr/src/lib/libelf.
33 */
34
35#include <libelf.h>
36#include <gelf.h>
37#include <nlist.h>
38
39
40/*
41 * Elf32 Symbols
42 */
43size_t		elf32_fsize(Elf_Type, size_t, uint_t);
44size_t		_elf32_fsize(Elf_Type, size_t, uint_t);
45Elf32_Ehdr *	elf32_getehdr(Elf *);
46Elf32_Ehdr *	_elf32_getehdr(Elf *);
47Elf32_Phdr *	elf32_getphdr(Elf *);
48Elf32_Phdr *	_elf32_getphdr(Elf *);
49Elf32_Shdr *	elf32_getshdr(Elf_Scn *);
50Elf32_Shdr *	_elf32_getshdr(Elf_Scn *);
51Elf32_Ehdr *	elf32_newehdr(Elf *);
52Elf32_Ehdr *	_elf32_newehdr(Elf *);
53Elf32_Phdr *	elf32_newphdr(Elf *, size_t);
54Elf32_Phdr *	_elf32_newphdr(Elf *, size_t);
55Elf_Data *	elf32_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
56Elf_Data *	_elf32_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
57Elf_Data *	elf32_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
58Elf_Data *	_elf32_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
59
60
61/*
62 * Elf64 Symbols
63 */
64size_t		elf64_fsize(Elf_Type, size_t, uint_t);
65Elf64_Ehdr *	elf64_getehdr(Elf *);
66Elf64_Phdr *	elf64_getphdr(Elf *);
67Elf64_Shdr *	elf64_getshdr(Elf_Scn *);
68Elf64_Ehdr *	elf64_newehdr(Elf *);
69Elf64_Phdr *	elf64_newphdr(Elf *, size_t);
70Elf_Data *	elf64_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
71Elf_Data *	elf64_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
72
73
74/*
75 * GElf Symbols
76 */
77size_t		gelf_fsize(Elf *, Elf_Type, size_t, uint_t);
78int		gelf_getclass(Elf *);
79GElf_Ehdr *	gelf_getehdr(Elf *, GElf_Ehdr *);
80int		gelf_update_ehdr(Elf *, GElf_Ehdr *);
81ulong_t		gelf_newehdr(Elf *, int);
82GElf_Phdr *	gelf_getphdr(Elf *, int, GElf_Phdr *);
83int		gelf_update_phdr(Elf *, int, GElf_Phdr *);
84ulong_t		gelf_newphdr(Elf *, size_t);
85GElf_Shdr *	gelf_getshdr(Elf_Scn *,  GElf_Shdr *);
86int		gelf_update_shdr(Elf_Scn *, GElf_Shdr *);
87Elf_Data *	gelf_xlatetof(Elf *, Elf_Data *, const Elf_Data *, uint_t);
88Elf_Data *	gelf_xlatetom(Elf *, Elf_Data *, const Elf_Data *, uint_t);
89GElf_Sym *	gelf_getsym(Elf_Data *, int, GElf_Sym *);
90int		gelf_update_sym(Elf_Data *, int, GElf_Sym *);
91GElf_Syminfo *	gelf_getsyminfo(Elf_Data *, int, GElf_Syminfo *);
92int		gelf_update_syminfo(Elf_Data *, int, GElf_Syminfo *);
93GElf_Sym *	gelf_getsymshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
94		    Elf32_Word *);
95int		gelf_update_symshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
96		    Elf32_Word);
97GElf_Move *	gelf_getmove(Elf_Data *, int, GElf_Move *);
98int		gelf_update_move(Elf_Data *, int, GElf_Move *);
99GElf_Dyn *	gelf_getdyn(Elf_Data *, int, GElf_Dyn *);
100int		gelf_update_dyn(Elf_Data *, int, GElf_Dyn *);
101GElf_Rela *	gelf_getrela(Elf_Data *, int, GElf_Rela *);
102int		gelf_update_rela(Elf_Data *, int, GElf_Rela *);
103GElf_Rel *	gelf_getrel(Elf_Data *, int, GElf_Rel *);
104int		gelf_update_rel(Elf_Data *, int, GElf_Rel *);
105GElf_Cap *	gelf_getcap(Elf_Data *, int, GElf_Cap *);
106int		gelf_update_cap(Elf_Data *, int, GElf_Cap *);
107
108GElf_Xword	_gelf_getdyndtflags_1(Elf *);
109
110/*
111 * Class-Independent Elf Symbols
112 */
113Elf *		elf_begin(int, Elf_Cmd, Elf *);
114Elf *		_elf_begin(int, Elf_Cmd, Elf *);
115int		elf_cntl(Elf *, Elf_Cmd);
116int		_elf_cntl(Elf *, Elf_Cmd);
117int		elf_end(Elf *);
118int		_elf_end(Elf *);
119const char *	elf_errmsg(int);
120const char *	_elf_errmsg(int);
121int		elf_errno(void);
122int		_elf_errno(void);
123void		elf_fill(int);
124void		_elf_fill(int);
125uint_t		elf_flagdata(Elf_Data *, Elf_Cmd, uint_t);
126uint_t		_elf_flagdata(Elf_Data *, Elf_Cmd, uint_t);
127uint_t		elf_flagehdr(Elf *, Elf_Cmd,  uint_t);
128uint_t		_elf_flagehdr(Elf *, Elf_Cmd,  uint_t);
129uint_t		elf_flagelf(Elf *, Elf_Cmd,  uint_t);
130uint_t		_elf_flagelf(Elf *, Elf_Cmd,  uint_t);
131uint_t		elf_flagphdr(Elf *, Elf_Cmd,  uint_t);
132uint_t		_elf_flagphdr(Elf *, Elf_Cmd,  uint_t);
133uint_t		elf_flagscn(Elf_Scn *, Elf_Cmd, uint_t);
134uint_t		_elf_flagscn(Elf_Scn *, Elf_Cmd, uint_t);
135uint_t		elf_flagshdr(Elf_Scn *, Elf_Cmd, uint_t);
136uint_t		_elf_flagshdr(Elf_Scn *, Elf_Cmd, uint_t);
137Elf_Arhdr *	elf_getarhdr(Elf *);
138Elf_Arhdr *	_elf_getarhdr(Elf *);
139Elf_Arsym *	elf_getarsym(Elf *, size_t *);
140Elf_Arsym *	_elf_getarsym(Elf *, size_t *);
141off_t		elf_getbase(Elf *);
142off_t		_elf_getbase(Elf *);
143Elf_Data *	elf_getdata(Elf_Scn *, Elf_Data *);
144Elf_Data *	_elf_getdata(Elf_Scn *, Elf_Data *);
145char *		elf_getident(Elf *, size_t *);
146char *		_elf_getident(Elf *, size_t *);
147int		elf_getphnum(Elf *, size_t *);
148int		elf_getshnum(Elf *, size_t *);
149int		elf_getshstrndx(Elf *, size_t *);
150Elf_Scn *	elf_getscn(Elf *elf, size_t);
151Elf_Scn *	_elf_getscn(Elf *elf, size_t);
152ulong_t		elf_hash(const char *);
153ulong_t		_elf_hash(const char *);
154Elf_Kind	elf_kind(Elf *);
155Elf_Kind	_elf_kind(Elf *);
156Elf *		elf_memory(char *, size_t);
157Elf *		_elf_memory(char *, size_t);
158size_t		elf_ndxscn(Elf_Scn *);
159size_t		_elf_ndxscn(Elf_Scn *);
160Elf_Data *	elf_newdata(Elf_Scn *);
161Elf_Data *	_elf_newdata(Elf_Scn *);
162Elf_Scn *	elf_newscn(Elf *);
163Elf_Scn *	_elf_newscn(Elf *);
164Elf_Cmd		elf_next(Elf *);
165Elf_Cmd		_elf_next(Elf *);
166Elf_Scn *	elf_nextscn(Elf *, Elf_Scn *);
167Elf_Scn *	_elf_nextscn(Elf *, Elf_Scn *);
168size_t		_elf_outsync(int, char *, size_t, uint_t);
169size_t		elf_rand(Elf *, size_t);
170size_t		_elf_rand(Elf *, size_t);
171Elf_Data *	elf_rawdata(Elf_Scn *, Elf_Data *);
172Elf_Data *	_elf_rawdata(Elf_Scn *, Elf_Data *);
173char *		elf_rawfile(Elf *, size_t *);
174char *		_elf_rawfile(Elf *, size_t *);
175char *		elf_strptr(Elf *, size_t, size_t);
176char *		_elf_strptr(Elf *, size_t, size_t);
177off_t		elf_update(Elf *, Elf_Cmd);
178off_t		_elf_update(Elf *, Elf_Cmd);
179uint_t		elf_version(uint_t);
180uint_t		_elf_version(uint_t);
181int		nlist(const char *, struct nlist *);
182
183
184/*
185 * Private Symbols
186 */
187Elf64_Off	_elf_getxoff(Elf_Data *);
188int		_elf_swap_wrimage(Elf *);
189uint_t		_elf_sys_encoding(void);
190