1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef __LIBRTLD_H 28*7c478bd9Sstevel@tonic-gate #define __LIBRTLD_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <libelf.h> 33*7c478bd9Sstevel@tonic-gate #include <rtld.h> 34*7c478bd9Sstevel@tonic-gate #include <machdep.h> 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate /* 42*7c478bd9Sstevel@tonic-gate * Define a cache structure that is used to retain all elf section information. 43*7c478bd9Sstevel@tonic-gate */ 44*7c478bd9Sstevel@tonic-gate typedef struct cache { 45*7c478bd9Sstevel@tonic-gate int c_flags; 46*7c478bd9Sstevel@tonic-gate Elf_Scn *c_scn; 47*7c478bd9Sstevel@tonic-gate Shdr *c_shdr; 48*7c478bd9Sstevel@tonic-gate Elf_Data *c_data; 49*7c478bd9Sstevel@tonic-gate char *c_name; 50*7c478bd9Sstevel@tonic-gate void *c_info; 51*7c478bd9Sstevel@tonic-gate } Cache; 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate #define FLG_C_EXCLUDE 1 /* exclude section from output image */ 54*7c478bd9Sstevel@tonic-gate #define FLG_C_HEAP 2 /* heap section (addition) */ 55*7c478bd9Sstevel@tonic-gate #define FLG_C_RELOC 3 /* relocation section requiring */ 56*7c478bd9Sstevel@tonic-gate /* modification */ 57*7c478bd9Sstevel@tonic-gate #define FLG_C_SHSTR 4 /* section header string table */ 58*7c478bd9Sstevel@tonic-gate #define FLG_C_END 5 /* null terminating section marker */ 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate /* 62*7c478bd9Sstevel@tonic-gate * Define a structure for maintaining relocation information. During the first 63*7c478bd9Sstevel@tonic-gate * pass through an input files relocation records, counts are maintained of the 64*7c478bd9Sstevel@tonic-gate * number of relocations to recreate in the output image. The intent is to 65*7c478bd9Sstevel@tonic-gate * localize any remaining relocation records. The relocation structure 66*7c478bd9Sstevel@tonic-gate * indicates the actions that must be performed on the output images relocation 67*7c478bd9Sstevel@tonic-gate * information. 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate typedef struct reloc { 70*7c478bd9Sstevel@tonic-gate int r_flags; 71*7c478bd9Sstevel@tonic-gate Xword r_pltndx; /* pltndx if a JMP relocation */ 72*7c478bd9Sstevel@tonic-gate Addr r_value; /* value to apply to relocation */ 73*7c478bd9Sstevel@tonic-gate unsigned long r_size; /* size (used for copy relocations) */ 74*7c478bd9Sstevel@tonic-gate const char *r_name; /* relocation symbol */ 75*7c478bd9Sstevel@tonic-gate } Reloc; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate #define FLG_R_UNDO 0x01 /* undo any relocation offset value */ 78*7c478bd9Sstevel@tonic-gate #define FLG_R_CLR 0x02 /* clear the relocation record */ 79*7c478bd9Sstevel@tonic-gate #define FLG_R_INC 0x04 /* increment the relocation offset */ 80*7c478bd9Sstevel@tonic-gate /* (uses new fixed addr) */ 81*7c478bd9Sstevel@tonic-gate #define FLG_R_APPLY 0x08 /* apply the relocation */ 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate /* 85*7c478bd9Sstevel@tonic-gate * Define any local prototypes. 86*7c478bd9Sstevel@tonic-gate */ 87*7c478bd9Sstevel@tonic-gate extern void apply_reloc(void *, Reloc *, const char *, unsigned char *, 88*7c478bd9Sstevel@tonic-gate Rt_map * lmp); 89*7c478bd9Sstevel@tonic-gate extern void clear_reloc(void *); 90*7c478bd9Sstevel@tonic-gate extern int count_reloc(Cache *, Cache *, Rt_map *, int, Addr, Xword *, 91*7c478bd9Sstevel@tonic-gate Xword *, Xword *); 92*7c478bd9Sstevel@tonic-gate extern void inc_reloc(void *, void *, Reloc *, unsigned char *, 93*7c478bd9Sstevel@tonic-gate unsigned char *); 94*7c478bd9Sstevel@tonic-gate extern void undo_reloc(void *, unsigned char *, unsigned char *, 95*7c478bd9Sstevel@tonic-gate Reloc *); 96*7c478bd9Sstevel@tonic-gate extern int update_dynamic(Cache *, Cache *, Rt_map *, int, Addr, Off, 97*7c478bd9Sstevel@tonic-gate const char *, Xword, Xword, Xword, Xword, Xword); 98*7c478bd9Sstevel@tonic-gate extern void update_reloc(Cache *, Cache *, Cache *, const char *, 99*7c478bd9Sstevel@tonic-gate Rt_map *, Rel **, Rel **, Rel **); 100*7c478bd9Sstevel@tonic-gate extern void update_sym(Cache *, Cache *, Addr, Half, Addr); 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 103*7c478bd9Sstevel@tonic-gate } 104*7c478bd9Sstevel@tonic-gate #endif 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate #endif /* __LIBRTLD_H */ 107