xref: /onnv-gate/usr/src/cmd/sgs/librtld/common/_librtld.h (revision 2850:689acf945b89)
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
51618Srie  * Common Development and Distribution License (the "License").
61618Srie  * 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  */
211618Srie 
220Sstevel@tonic-gate /*
231618Srie  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
241618Srie  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	__LIBRTLD_H
280Sstevel@tonic-gate #define	__LIBRTLD_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <libelf.h>
330Sstevel@tonic-gate #include <rtld.h>
340Sstevel@tonic-gate #include <machdep.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #ifdef	__cplusplus
370Sstevel@tonic-gate extern "C" {
380Sstevel@tonic-gate #endif
390Sstevel@tonic-gate 
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /*
420Sstevel@tonic-gate  * Define a cache structure that is used to retain all elf section information.
430Sstevel@tonic-gate  */
440Sstevel@tonic-gate typedef struct cache {
450Sstevel@tonic-gate 	int		c_flags;
460Sstevel@tonic-gate 	Elf_Scn		*c_scn;
470Sstevel@tonic-gate 	Shdr		*c_shdr;
480Sstevel@tonic-gate 	Elf_Data	*c_data;
490Sstevel@tonic-gate 	char		*c_name;
500Sstevel@tonic-gate 	void		*c_info;
510Sstevel@tonic-gate } Cache;
520Sstevel@tonic-gate 
530Sstevel@tonic-gate #define	FLG_C_EXCLUDE	1		/* exclude section from output image */
540Sstevel@tonic-gate #define	FLG_C_HEAP	2		/* heap section (addition) */
550Sstevel@tonic-gate #define	FLG_C_RELOC	3		/* relocation section requiring */
560Sstevel@tonic-gate 					/*	modification */
570Sstevel@tonic-gate #define	FLG_C_SHSTR	4		/* section header string table */
580Sstevel@tonic-gate #define	FLG_C_END	5		/* null terminating section marker */
590Sstevel@tonic-gate 
600Sstevel@tonic-gate 
610Sstevel@tonic-gate /*
620Sstevel@tonic-gate  * Define a structure for maintaining relocation information.  During the first
630Sstevel@tonic-gate  * pass through an input files relocation records, counts are maintained of the
640Sstevel@tonic-gate  * number of relocations to recreate in the output image.  The intent is to
650Sstevel@tonic-gate  * localize any remaining relocation records.  The relocation structure
660Sstevel@tonic-gate  * indicates the actions that must be performed on the output images relocation
670Sstevel@tonic-gate  * information.
680Sstevel@tonic-gate  */
690Sstevel@tonic-gate typedef struct reloc {
700Sstevel@tonic-gate 	int		r_flags;
710Sstevel@tonic-gate 	Xword		r_pltndx;	/* pltndx if a JMP relocation */
720Sstevel@tonic-gate 	Addr		r_value;	/* value to apply to relocation */
730Sstevel@tonic-gate 	unsigned long	r_size;		/* size (used for copy relocations) */
740Sstevel@tonic-gate 	const char	*r_name;		/* relocation symbol */
750Sstevel@tonic-gate } Reloc;
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #define	FLG_R_UNDO	0x01		/* undo any relocation offset value */
780Sstevel@tonic-gate #define	FLG_R_CLR	0x02		/* clear the relocation record */
790Sstevel@tonic-gate #define	FLG_R_INC	0x04		/* increment the relocation offset */
800Sstevel@tonic-gate 					/*	(uses new fixed addr) */
810Sstevel@tonic-gate #define	FLG_R_APPLY	0x08		/* apply the relocation */
820Sstevel@tonic-gate 
830Sstevel@tonic-gate 
840Sstevel@tonic-gate /*
850Sstevel@tonic-gate  * Define any local prototypes.
860Sstevel@tonic-gate  */
871618Srie extern	void	apply_reloc(void *, Reloc *, const char *, uchar_t *, Rt_map *);
880Sstevel@tonic-gate extern	void	clear_reloc(void *);
890Sstevel@tonic-gate extern	int	count_reloc(Cache *, Cache *, Rt_map *, int, Addr, Xword *,
90*2850Srie 		    Xword *, Xword *, Alist *);
911618Srie extern	void	inc_reloc(void *, void *, Reloc *, uchar_t *, uchar_t *);
92*2850Srie extern	int	syminfo(Cache *, Alist **);
931618Srie extern	void	undo_reloc(void *, uchar_t *, uchar_t *, Reloc *);
940Sstevel@tonic-gate extern	int	update_dynamic(Cache *, Cache *, Rt_map *, int, Addr, Off,
950Sstevel@tonic-gate 		    const char *, Xword, Xword, Xword, Xword, Xword);
960Sstevel@tonic-gate extern	void	update_reloc(Cache *, Cache *, Cache *, const char *,
970Sstevel@tonic-gate 		    Rt_map *, Rel **, Rel **, Rel **);
980Sstevel@tonic-gate extern	void	update_sym(Cache *, Cache *, Addr, Half, Addr);
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate #ifdef	__cplusplus
1010Sstevel@tonic-gate }
1020Sstevel@tonic-gate #endif
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate #endif /* __LIBRTLD_H */
105