xref: /onnv-gate/usr/src/cmd/sgs/libelf/common/llib-lelf (revision 12792:1f56a791e275)
10Sstevel@tonic-gate/*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
51824Srie * Common Development and Distribution License (the "License").
61824Srie * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate
220Sstevel@tonic-gate/*
2312457SAli.Bahrami@Oracle.COM * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
266812Sraf/* LINTLIBRARY */
276812Sraf/* PROTOLIB1 */
286812Sraf
290Sstevel@tonic-gate/*
300Sstevel@tonic-gate * Generic interface definition for usr/src/lib/libelf.
310Sstevel@tonic-gate */
320Sstevel@tonic-gate
3312457SAli.Bahrami@Oracle.COM#include <_libelf.h>
340Sstevel@tonic-gate#include <nlist.h>
350Sstevel@tonic-gate
360Sstevel@tonic-gate
370Sstevel@tonic-gate/*
380Sstevel@tonic-gate * Elf32 Symbols
390Sstevel@tonic-gate */
400Sstevel@tonic-gatesize_t		elf32_fsize(Elf_Type, size_t, uint_t);
410Sstevel@tonic-gateElf32_Ehdr *	elf32_getehdr(Elf *);
420Sstevel@tonic-gateElf32_Phdr *	elf32_getphdr(Elf *);
430Sstevel@tonic-gateElf32_Shdr *	elf32_getshdr(Elf_Scn *);
440Sstevel@tonic-gateElf32_Ehdr *	elf32_newehdr(Elf *);
450Sstevel@tonic-gateElf32_Phdr *	elf32_newphdr(Elf *, size_t);
460Sstevel@tonic-gateElf_Data *	elf32_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
470Sstevel@tonic-gateElf_Data *	elf32_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
480Sstevel@tonic-gate
490Sstevel@tonic-gate
500Sstevel@tonic-gate/*
510Sstevel@tonic-gate * Elf64 Symbols
520Sstevel@tonic-gate */
530Sstevel@tonic-gatesize_t		elf64_fsize(Elf_Type, size_t, uint_t);
540Sstevel@tonic-gateElf64_Ehdr *	elf64_getehdr(Elf *);
550Sstevel@tonic-gateElf64_Phdr *	elf64_getphdr(Elf *);
560Sstevel@tonic-gateElf64_Shdr *	elf64_getshdr(Elf_Scn *);
570Sstevel@tonic-gateElf64_Ehdr *	elf64_newehdr(Elf *);
580Sstevel@tonic-gateElf64_Phdr *	elf64_newphdr(Elf *, size_t);
590Sstevel@tonic-gateElf_Data *	elf64_xlatetof(Elf_Data *, const Elf_Data *, uint_t);
600Sstevel@tonic-gateElf_Data *	elf64_xlatetom(Elf_Data *, const Elf_Data *, uint_t);
610Sstevel@tonic-gate
620Sstevel@tonic-gate
630Sstevel@tonic-gate/*
640Sstevel@tonic-gate * GElf Symbols
650Sstevel@tonic-gate */
660Sstevel@tonic-gatesize_t		gelf_fsize(Elf *, Elf_Type, size_t, uint_t);
670Sstevel@tonic-gateint		gelf_getclass(Elf *);
680Sstevel@tonic-gateGElf_Ehdr *	gelf_getehdr(Elf *, GElf_Ehdr *);
690Sstevel@tonic-gateint		gelf_update_ehdr(Elf *, GElf_Ehdr *);
700Sstevel@tonic-gateulong_t		gelf_newehdr(Elf *, int);
710Sstevel@tonic-gateGElf_Phdr *	gelf_getphdr(Elf *, int, GElf_Phdr *);
720Sstevel@tonic-gateint		gelf_update_phdr(Elf *, int, GElf_Phdr *);
730Sstevel@tonic-gateulong_t		gelf_newphdr(Elf *, size_t);
740Sstevel@tonic-gateGElf_Shdr *	gelf_getshdr(Elf_Scn *,  GElf_Shdr *);
750Sstevel@tonic-gateint		gelf_update_shdr(Elf_Scn *, GElf_Shdr *);
760Sstevel@tonic-gateElf_Data *	gelf_xlatetof(Elf *, Elf_Data *, const Elf_Data *, uint_t);
770Sstevel@tonic-gateElf_Data *	gelf_xlatetom(Elf *, Elf_Data *, const Elf_Data *, uint_t);
780Sstevel@tonic-gateGElf_Sym *	gelf_getsym(Elf_Data *, int, GElf_Sym *);
790Sstevel@tonic-gateint		gelf_update_sym(Elf_Data *, int, GElf_Sym *);
800Sstevel@tonic-gateGElf_Syminfo *	gelf_getsyminfo(Elf_Data *, int, GElf_Syminfo *);
810Sstevel@tonic-gateint		gelf_update_syminfo(Elf_Data *, int, GElf_Syminfo *);
820Sstevel@tonic-gateGElf_Sym *	gelf_getsymshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
830Sstevel@tonic-gate		    Elf32_Word *);
840Sstevel@tonic-gateint		gelf_update_symshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
850Sstevel@tonic-gate		    Elf32_Word);
860Sstevel@tonic-gateGElf_Move *	gelf_getmove(Elf_Data *, int, GElf_Move *);
870Sstevel@tonic-gateint		gelf_update_move(Elf_Data *, int, GElf_Move *);
880Sstevel@tonic-gateGElf_Dyn *	gelf_getdyn(Elf_Data *, int, GElf_Dyn *);
890Sstevel@tonic-gateint		gelf_update_dyn(Elf_Data *, int, GElf_Dyn *);
900Sstevel@tonic-gateGElf_Rela *	gelf_getrela(Elf_Data *, int, GElf_Rela *);
910Sstevel@tonic-gateint		gelf_update_rela(Elf_Data *, int, GElf_Rela *);
920Sstevel@tonic-gateGElf_Rel *	gelf_getrel(Elf_Data *, int, GElf_Rel *);
930Sstevel@tonic-gateint		gelf_update_rel(Elf_Data *, int, GElf_Rel *);
940Sstevel@tonic-gateGElf_Cap *	gelf_getcap(Elf_Data *, int, GElf_Cap *);
950Sstevel@tonic-gateint		gelf_update_cap(Elf_Data *, int, GElf_Cap *);
960Sstevel@tonic-gate
971824SrieGElf_Xword	_gelf_getdyndtflags_1(Elf *);
980Sstevel@tonic-gate
990Sstevel@tonic-gate/*
1000Sstevel@tonic-gate * Class-Independent Elf Symbols
1010Sstevel@tonic-gate */
1020Sstevel@tonic-gateElf *		elf_begin(int, Elf_Cmd, Elf *);
1030Sstevel@tonic-gateint		elf_cntl(Elf *, Elf_Cmd);
1040Sstevel@tonic-gateint		elf_end(Elf *);
1050Sstevel@tonic-gateconst char *	elf_errmsg(int);
1060Sstevel@tonic-gateint		elf_errno(void);
1070Sstevel@tonic-gatevoid		elf_fill(int);
1080Sstevel@tonic-gateuint_t		elf_flagdata(Elf_Data *, Elf_Cmd, uint_t);
1090Sstevel@tonic-gateuint_t		elf_flagehdr(Elf *, Elf_Cmd,  uint_t);
1100Sstevel@tonic-gateuint_t		elf_flagelf(Elf *, Elf_Cmd,  uint_t);
1110Sstevel@tonic-gateuint_t		elf_flagphdr(Elf *, Elf_Cmd,  uint_t);
1120Sstevel@tonic-gateuint_t		elf_flagscn(Elf_Scn *, Elf_Cmd, uint_t);
1130Sstevel@tonic-gateuint_t		elf_flagshdr(Elf_Scn *, Elf_Cmd, uint_t);
1140Sstevel@tonic-gateElf_Arhdr *	elf_getarhdr(Elf *);
1150Sstevel@tonic-gateElf_Arsym *	elf_getarsym(Elf *, size_t *);
1160Sstevel@tonic-gateoff_t		elf_getbase(Elf *);
1170Sstevel@tonic-gateElf_Data *	elf_getdata(Elf_Scn *, Elf_Data *);
1180Sstevel@tonic-gatechar *		elf_getident(Elf *, size_t *);
119942Sahlint		elf_getphnum(Elf *, size_t *);
1200Sstevel@tonic-gateint		elf_getshnum(Elf *, size_t *);
1210Sstevel@tonic-gateint		elf_getshstrndx(Elf *, size_t *);
1220Sstevel@tonic-gateElf_Scn *	elf_getscn(Elf *elf, size_t);
1230Sstevel@tonic-gateulong_t		elf_hash(const char *);
1240Sstevel@tonic-gateElf_Kind	elf_kind(Elf *);
1250Sstevel@tonic-gateElf *		elf_memory(char *, size_t);
1260Sstevel@tonic-gatesize_t		elf_ndxscn(Elf_Scn *);
1270Sstevel@tonic-gateElf_Data *	elf_newdata(Elf_Scn *);
1280Sstevel@tonic-gateElf_Scn *	elf_newscn(Elf *);
1290Sstevel@tonic-gateElf_Cmd		elf_next(Elf *);
1300Sstevel@tonic-gateElf_Scn *	elf_nextscn(Elf *, Elf_Scn *);
1310Sstevel@tonic-gatesize_t		_elf_outsync(int, char *, size_t, uint_t);
1320Sstevel@tonic-gatesize_t		elf_rand(Elf *, size_t);
1330Sstevel@tonic-gateElf_Data *	elf_rawdata(Elf_Scn *, Elf_Data *);
1340Sstevel@tonic-gatechar *		elf_rawfile(Elf *, size_t *);
1350Sstevel@tonic-gatechar *		elf_strptr(Elf *, size_t, size_t);
1360Sstevel@tonic-gateoff_t		elf_update(Elf *, Elf_Cmd);
1370Sstevel@tonic-gateuint_t		elf_version(uint_t);
1380Sstevel@tonic-gateint		nlist(const char *, struct nlist *);
1390Sstevel@tonic-gate
1400Sstevel@tonic-gate
1410Sstevel@tonic-gate/*
1420Sstevel@tonic-gate * Private Symbols
1430Sstevel@tonic-gate */
14412457SAli.Bahrami@Oracle.COMextern void		_elf_execfill(_elf_execfill_func_t *);
14512457SAli.Bahrami@Oracle.COMextern off_t		_elf_getarhdrbase(Elf *);
146*12792SAli.Bahrami@Oracle.COMextern size_t		_elf_getarsymwordsize(Elf *);
14712457SAli.Bahrami@Oracle.COMextern size_t		_elf_getnextoff(Elf *);
14812457SAli.Bahrami@Oracle.COMElf64_Off		_elf_getxoff(Elf_Data *);
14912457SAli.Bahrami@Oracle.COMint			_elf_swap_wrimage(Elf *);
15012457SAli.Bahrami@Oracle.COMuint_t			_elf_sys_encoding(void);
15112457SAli.Bahrami@Oracle.COM
15212457SAli.Bahrami@Oracle.COMextern GElf_Xword	_gelf_getdyndtflags_1(Elf *);
153