xref: /titanic_50/usr/src/cmd/sgs/librtld/common/_librtld.h (revision ab9b2e153c3a9a2b1141fefa87925b1a9beb1236)
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 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	__LIBRTLD_H
28 #define	__LIBRTLD_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <libelf.h>
33 #include <rtld.h>
34 #include <machdep.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 
41 /*
42  * Define a cache structure that is used to retain all elf section information.
43  */
44 typedef struct cache {
45 	int		c_flags;
46 	Elf_Scn		*c_scn;
47 	Shdr		*c_shdr;
48 	Elf_Data	*c_data;
49 	char		*c_name;
50 	void		*c_info;
51 } Cache;
52 
53 #define	FLG_C_EXCLUDE	1		/* exclude section from output image */
54 #define	FLG_C_HEAP	2		/* heap section (addition) */
55 #define	FLG_C_RELOC	3		/* relocation section requiring */
56 					/*	modification */
57 #define	FLG_C_SHSTR	4		/* section header string table */
58 #define	FLG_C_END	5		/* null terminating section marker */
59 
60 
61 /*
62  * Define a structure for maintaining relocation information.  During the first
63  * pass through an input files relocation records, counts are maintained of the
64  * number of relocations to recreate in the output image.  The intent is to
65  * localize any remaining relocation records.  The relocation structure
66  * indicates the actions that must be performed on the output images relocation
67  * information.
68  */
69 typedef struct reloc {
70 	int		r_flags;
71 	Xword		r_pltndx;	/* pltndx if a JMP relocation */
72 	Addr		r_value;	/* value to apply to relocation */
73 	unsigned long	r_size;		/* size (used for copy relocations) */
74 	const char	*r_name;		/* relocation symbol */
75 } Reloc;
76 
77 #define	FLG_R_UNDO	0x01		/* undo any relocation offset value */
78 #define	FLG_R_CLR	0x02		/* clear the relocation record */
79 #define	FLG_R_INC	0x04		/* increment the relocation offset */
80 					/*	(uses new fixed addr) */
81 #define	FLG_R_APPLY	0x08		/* apply the relocation */
82 
83 
84 /*
85  * Define any local prototypes.
86  */
87 extern	void	apply_reloc(void *, Reloc *, const char *, uchar_t *, Rt_map *);
88 extern	void	clear_reloc(void *);
89 extern	int	count_reloc(Cache *, Cache *, Rt_map *, int, Addr, Xword *,
90 		    Xword *, Xword *, Alist *);
91 extern	void	inc_reloc(void *, void *, Reloc *, uchar_t *, uchar_t *);
92 extern	int	syminfo(Cache *, Alist **);
93 extern	void	undo_reloc(void *, uchar_t *, uchar_t *, Reloc *);
94 extern	int	update_dynamic(Cache *, Cache *, Rt_map *, int, Addr, Off,
95 		    const char *, Xword, Xword, Xword, Xword, Xword);
96 extern	void	update_reloc(Cache *, Cache *, Cache *, const char *,
97 		    Rt_map *, Rel **, Rel **, Rel **);
98 extern	void	update_sym(Cache *, Cache *, Addr, Half, Addr);
99 
100 #ifdef	__cplusplus
101 }
102 #endif
103 
104 #endif /* __LIBRTLD_H */
105