xref: /illumos-gate/usr/src/cmd/sgs/librtld/common/_librtld.h (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
215aefb655Srie 
227c478bd9Sstevel@tonic-gate /*
235aefb655Srie  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
245aefb655Srie  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	__LIBRTLD_H
287c478bd9Sstevel@tonic-gate #define	__LIBRTLD_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include <libelf.h>
317c478bd9Sstevel@tonic-gate #include <rtld.h>
327c478bd9Sstevel@tonic-gate #include <machdep.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * Define a cache structure that is used to retain all elf section information.
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate typedef struct cache {
437c478bd9Sstevel@tonic-gate 	int		c_flags;
447c478bd9Sstevel@tonic-gate 	Elf_Scn		*c_scn;
457c478bd9Sstevel@tonic-gate 	Shdr		*c_shdr;
467c478bd9Sstevel@tonic-gate 	Elf_Data	*c_data;
477c478bd9Sstevel@tonic-gate 	char		*c_name;
487c478bd9Sstevel@tonic-gate 	void		*c_info;
497c478bd9Sstevel@tonic-gate } Cache;
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate #define	FLG_C_EXCLUDE	1		/* exclude section from output image */
527c478bd9Sstevel@tonic-gate #define	FLG_C_HEAP	2		/* heap section (addition) */
537c478bd9Sstevel@tonic-gate #define	FLG_C_RELOC	3		/* relocation section requiring */
547c478bd9Sstevel@tonic-gate 					/*	modification */
557c478bd9Sstevel@tonic-gate #define	FLG_C_SHSTR	4		/* section header string table */
567c478bd9Sstevel@tonic-gate #define	FLG_C_END	5		/* null terminating section marker */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate  * Define a structure for maintaining relocation information.  During the first
617c478bd9Sstevel@tonic-gate  * pass through an input files relocation records, counts are maintained of the
627c478bd9Sstevel@tonic-gate  * number of relocations to recreate in the output image.  The intent is to
637c478bd9Sstevel@tonic-gate  * localize any remaining relocation records.  The relocation structure
647c478bd9Sstevel@tonic-gate  * indicates the actions that must be performed on the output images relocation
657c478bd9Sstevel@tonic-gate  * information.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate typedef struct reloc {
687c478bd9Sstevel@tonic-gate 	int		r_flags;
697c478bd9Sstevel@tonic-gate 	Xword		r_pltndx;	/* pltndx if a JMP relocation */
707c478bd9Sstevel@tonic-gate 	Addr		r_value;	/* value to apply to relocation */
717c478bd9Sstevel@tonic-gate 	unsigned long	r_size;		/* size (used for copy relocations) */
727c478bd9Sstevel@tonic-gate 	const char	*r_name;		/* relocation symbol */
737c478bd9Sstevel@tonic-gate } Reloc;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #define	FLG_R_UNDO	0x01		/* undo any relocation offset value */
767c478bd9Sstevel@tonic-gate #define	FLG_R_CLR	0x02		/* clear the relocation record */
777c478bd9Sstevel@tonic-gate #define	FLG_R_INC	0x04		/* increment the relocation offset */
787c478bd9Sstevel@tonic-gate 					/*	(uses new fixed addr) */
797c478bd9Sstevel@tonic-gate #define	FLG_R_APPLY	0x08		/* apply the relocation */
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * Define any local prototypes.
847c478bd9Sstevel@tonic-gate  */
855aefb655Srie extern	void	apply_reloc(void *, Reloc *, const char *, uchar_t *, Rt_map *);
867c478bd9Sstevel@tonic-gate extern	void	clear_reloc(void *);
877c478bd9Sstevel@tonic-gate extern	int	count_reloc(Cache *, Cache *, Rt_map *, int, Addr, Xword *,
88*2926dd2eSrie 		    Xword *, Xword *, Alist *);
895aefb655Srie extern	void	inc_reloc(void *, void *, Reloc *, uchar_t *, uchar_t *);
90*2926dd2eSrie extern	int	syminfo(Cache *, Alist **);
915aefb655Srie extern	void	undo_reloc(void *, uchar_t *, uchar_t *, Reloc *);
927c478bd9Sstevel@tonic-gate extern	int	update_dynamic(Cache *, Cache *, Rt_map *, int, Addr, Off,
937c478bd9Sstevel@tonic-gate 		    const char *, Xword, Xword, Xword, Xword, Xword);
947c478bd9Sstevel@tonic-gate extern	void	update_reloc(Cache *, Cache *, Cache *, const char *,
957c478bd9Sstevel@tonic-gate 		    Rt_map *, Rel **, Rel **, Rel **);
967c478bd9Sstevel@tonic-gate extern	void	update_sym(Cache *, Cache *, Addr, Half, Addr);
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
997c478bd9Sstevel@tonic-gate }
1007c478bd9Sstevel@tonic-gate #endif
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate #endif /* __LIBRTLD_H */
103