xref: /titanic_44/usr/src/cmd/sgs/libelf/common/llib-lelf (revision a60349c89adffc0902b2353230891d8e7f2b24d9)
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
22/*
23 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26/* LINTLIBRARY */
27/* PROTOLIB1 */
28
29/*
30 * Generic interface definition for usr/src/lib/libelf.
31 */
32
33#include <_libelf.h>
34#include <nlist.h>
35
36
37/*
38 * Elf32 Symbols
39 */
40size_t		elf32_fsize(Elf_Type, size_t, uint_t);
41Elf32_Ehdr *	elf32_getehdr(Elf *);
42Elf32_Phdr *	elf32_getphdr(Elf *);
43Elf32_Shdr *	elf32_getshdr(Elf_Scn *);
44Elf32_Ehdr *	elf32_newehdr(Elf *);
45Elf32_Phdr *	elf32_newphdr(Elf *, size_t);
46Elf_Data *	elf32_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
47Elf_Data *	elf32_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
48
49
50/*
51 * Elf64 Symbols
52 */
53size_t		elf64_fsize(Elf_Type, size_t, uint_t);
54Elf64_Ehdr *	elf64_getehdr(Elf *);
55Elf64_Phdr *	elf64_getphdr(Elf *);
56Elf64_Shdr *	elf64_getshdr(Elf_Scn *);
57Elf64_Ehdr *	elf64_newehdr(Elf *);
58Elf64_Phdr *	elf64_newphdr(Elf *, size_t);
59Elf_Data *	elf64_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
60Elf_Data *	elf64_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
61
62
63/*
64 * GElf Symbols
65 */
66size_t		gelf_fsize(Elf *, Elf_Type, size_t, uint_t);
67int		gelf_getclass(Elf *);
68GElf_Ehdr *	gelf_getehdr(Elf *, GElf_Ehdr *);
69int		gelf_update_ehdr(Elf *, GElf_Ehdr *);
70ulong_t		gelf_newehdr(Elf *, int);
71GElf_Phdr *	gelf_getphdr(Elf *, int, GElf_Phdr *);
72int		gelf_update_phdr(Elf *, int, GElf_Phdr *);
73ulong_t		gelf_newphdr(Elf *, size_t);
74GElf_Shdr *	gelf_getshdr(Elf_Scn *,  GElf_Shdr *);
75int		gelf_update_shdr(Elf_Scn *, GElf_Shdr *);
76Elf_Data *	gelf_xlatetof(Elf *, Elf_Data *, const Elf_Data *, uint_t);
77Elf_Data *	gelf_xlatetom(Elf *, Elf_Data *, const Elf_Data *, uint_t);
78GElf_Sym *	gelf_getsym(Elf_Data *, int, GElf_Sym *);
79int		gelf_update_sym(Elf_Data *, int, GElf_Sym *);
80GElf_Syminfo *	gelf_getsyminfo(Elf_Data *, int, GElf_Syminfo *);
81int		gelf_update_syminfo(Elf_Data *, int, GElf_Syminfo *);
82GElf_Sym *	gelf_getsymshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
83		    Elf32_Word *);
84int		gelf_update_symshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
85		    Elf32_Word);
86GElf_Move *	gelf_getmove(Elf_Data *, int, GElf_Move *);
87int		gelf_update_move(Elf_Data *, int, GElf_Move *);
88GElf_Dyn *	gelf_getdyn(Elf_Data *, int, GElf_Dyn *);
89int		gelf_update_dyn(Elf_Data *, int, GElf_Dyn *);
90GElf_Rela *	gelf_getrela(Elf_Data *, int, GElf_Rela *);
91int		gelf_update_rela(Elf_Data *, int, GElf_Rela *);
92GElf_Rel *	gelf_getrel(Elf_Data *, int, GElf_Rel *);
93int		gelf_update_rel(Elf_Data *, int, GElf_Rel *);
94GElf_Cap *	gelf_getcap(Elf_Data *, int, GElf_Cap *);
95int		gelf_update_cap(Elf_Data *, int, GElf_Cap *);
96
97GElf_Xword	_gelf_getdyndtflags_1(Elf *);
98
99/*
100 * Class-Independent Elf Symbols
101 */
102Elf *		elf_begin(int, Elf_Cmd, Elf *);
103int		elf_cntl(Elf *, Elf_Cmd);
104int		elf_end(Elf *);
105const char *	elf_errmsg(int);
106int		elf_errno(void);
107void		elf_fill(int);
108uint_t		elf_flagdata(Elf_Data *, Elf_Cmd, uint_t);
109uint_t		elf_flagehdr(Elf *, Elf_Cmd,  uint_t);
110uint_t		elf_flagelf(Elf *, Elf_Cmd,  uint_t);
111uint_t		elf_flagphdr(Elf *, Elf_Cmd,  uint_t);
112uint_t		elf_flagscn(Elf_Scn *, Elf_Cmd, uint_t);
113uint_t		elf_flagshdr(Elf_Scn *, Elf_Cmd, uint_t);
114Elf_Arhdr *	elf_getarhdr(Elf *);
115Elf_Arsym *	elf_getarsym(Elf *, size_t *);
116off_t		elf_getbase(Elf *);
117Elf_Data *	elf_getdata(Elf_Scn *, Elf_Data *);
118char *		elf_getident(Elf *, size_t *);
119int		elf_getphnum(Elf *, size_t *);
120int		elf_getshnum(Elf *, size_t *);
121int		elf_getshstrndx(Elf *, size_t *);
122Elf_Scn *	elf_getscn(Elf *elf, size_t);
123ulong_t		elf_hash(const char *);
124Elf_Kind	elf_kind(Elf *);
125Elf *		elf_memory(char *, size_t);
126size_t		elf_ndxscn(Elf_Scn *);
127Elf_Data *	elf_newdata(Elf_Scn *);
128Elf_Scn *	elf_newscn(Elf *);
129Elf_Cmd		elf_next(Elf *);
130Elf_Scn *	elf_nextscn(Elf *, Elf_Scn *);
131size_t		_elf_outsync(int, char *, size_t, uint_t);
132size_t		elf_rand(Elf *, size_t);
133Elf_Data *	elf_rawdata(Elf_Scn *, Elf_Data *);
134char *		elf_rawfile(Elf *, size_t *);
135char *		elf_strptr(Elf *, size_t, size_t);
136off_t		elf_update(Elf *, Elf_Cmd);
137uint_t		elf_version(uint_t);
138int		nlist(const char *, struct nlist *);
139
140
141/*
142 * Private Symbols
143 */
144extern void		_elf_execfill(_elf_execfill_func_t *);
145extern off_t		_elf_getarhdrbase(Elf *);
146extern size_t		_elf_getarsymwordsize(Elf *);
147extern size_t		_elf_getnextoff(Elf *);
148Elf64_Off		_elf_getxoff(Elf_Data *);
149int			_elf_swap_wrimage(Elf *);
150uint_t			_elf_sys_encoding(void);
151
152extern GElf_Xword	_gelf_getdyndtflags_1(Elf *);
153