xref: /titanic_41/usr/src/cmd/sgs/libelf/common/llib-lelf (revision 0adc16190e36914964740716575460dda750de39)
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/* LINTLIBRARY */
23/* PROTOLIB1 */
24
25/*
26 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
27 * Use is subject to license terms.
28 */
29
30#pragma ident	"%Z%%M%	%I%	%E% SMI"
31
32/*
33 * Generic interface definition for usr/src/lib/libelf.
34 */
35
36#include <libelf.h>
37#include <gelf.h>
38#include <nlist.h>
39
40
41/*
42 * Elf32 Symbols
43 */
44size_t		elf32_fsize(Elf_Type, size_t, uint_t);
45size_t		_elf32_fsize(Elf_Type, size_t, uint_t);
46Elf32_Ehdr *	elf32_getehdr(Elf *);
47Elf32_Ehdr *	_elf32_getehdr(Elf *);
48Elf32_Phdr *	elf32_getphdr(Elf *);
49Elf32_Phdr *	_elf32_getphdr(Elf *);
50Elf32_Shdr *	elf32_getshdr(Elf_Scn *);
51Elf32_Shdr *	_elf32_getshdr(Elf_Scn *);
52Elf32_Ehdr *	elf32_newehdr(Elf *);
53Elf32_Ehdr *	_elf32_newehdr(Elf *);
54Elf32_Phdr *	elf32_newphdr(Elf *, size_t);
55Elf32_Phdr *	_elf32_newphdr(Elf *, size_t);
56Elf_Data *	elf32_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
57Elf_Data *	_elf32_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
58Elf_Data *	elf32_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
59Elf_Data *	_elf32_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
60
61
62/*
63 * Elf64 Symbols
64 */
65size_t		elf64_fsize(Elf_Type, size_t, uint_t);
66Elf64_Ehdr *	elf64_getehdr(Elf *);
67Elf64_Phdr *	elf64_getphdr(Elf *);
68Elf64_Shdr *	elf64_getshdr(Elf_Scn *);
69Elf64_Ehdr *	elf64_newehdr(Elf *);
70Elf64_Phdr *	elf64_newphdr(Elf *, size_t);
71Elf_Data *	elf64_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
72Elf_Data *	elf64_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
73
74
75/*
76 * GElf Symbols
77 */
78size_t		gelf_fsize(Elf *, Elf_Type, size_t, uint_t);
79int		gelf_getclass(Elf *);
80GElf_Ehdr *	gelf_getehdr(Elf *, GElf_Ehdr *);
81int		gelf_update_ehdr(Elf *, GElf_Ehdr *);
82ulong_t		gelf_newehdr(Elf *, int);
83GElf_Phdr *	gelf_getphdr(Elf *, int, GElf_Phdr *);
84int		gelf_update_phdr(Elf *, int, GElf_Phdr *);
85ulong_t		gelf_newphdr(Elf *, size_t);
86GElf_Shdr *	gelf_getshdr(Elf_Scn *,  GElf_Shdr *);
87int		gelf_update_shdr(Elf_Scn *, GElf_Shdr *);
88Elf_Data *	gelf_xlatetof(Elf *, Elf_Data *, const Elf_Data *, uint_t);
89Elf_Data *	gelf_xlatetom(Elf *, Elf_Data *, const Elf_Data *, uint_t);
90GElf_Sym *	gelf_getsym(Elf_Data *, int, GElf_Sym *);
91int		gelf_update_sym(Elf_Data *, int, GElf_Sym *);
92GElf_Syminfo *	gelf_getsyminfo(Elf_Data *, int, GElf_Syminfo *);
93int		gelf_update_syminfo(Elf_Data *, int, GElf_Syminfo *);
94GElf_Sym *	gelf_getsymshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
95		    Elf32_Word *);
96int		gelf_update_symshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
97		    Elf32_Word);
98GElf_Move *	gelf_getmove(Elf_Data *, int, GElf_Move *);
99int		gelf_update_move(Elf_Data *, int, GElf_Move *);
100GElf_Dyn *	gelf_getdyn(Elf_Data *, int, GElf_Dyn *);
101int		gelf_update_dyn(Elf_Data *, int, GElf_Dyn *);
102GElf_Rela *	gelf_getrela(Elf_Data *, int, GElf_Rela *);
103int		gelf_update_rela(Elf_Data *, int, GElf_Rela *);
104GElf_Rel *	gelf_getrel(Elf_Data *, int, GElf_Rel *);
105int		gelf_update_rel(Elf_Data *, int, GElf_Rel *);
106GElf_Cap *	gelf_getcap(Elf_Data *, int, GElf_Cap *);
107int		gelf_update_cap(Elf_Data *, int, GElf_Cap *);
108
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 *);
188