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