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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 2001 by Sun Microsystems, Inc. 24 * All rights reserved. 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 *, unsigned char *, 88 Rt_map * lmp); 89 extern void clear_reloc(void *); 90 extern int count_reloc(Cache *, Cache *, Rt_map *, int, Addr, Xword *, 91 Xword *, Xword *); 92 extern void inc_reloc(void *, void *, Reloc *, unsigned char *, 93 unsigned char *); 94 extern void undo_reloc(void *, unsigned char *, unsigned char *, 95 Reloc *); 96 extern int update_dynamic(Cache *, Cache *, Rt_map *, int, Addr, Off, 97 const char *, Xword, Xword, Xword, Xword, Xword); 98 extern void update_reloc(Cache *, Cache *, Cache *, const char *, 99 Rt_map *, Rel **, Rel **, Rel **); 100 extern void update_sym(Cache *, Cache *, Addr, Half, Addr); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* __LIBRTLD_H */ 107