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 #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <libelf.h> 337c478bd9Sstevel@tonic-gate #include <rtld.h> 347c478bd9Sstevel@tonic-gate #include <machdep.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * Define a cache structure that is used to retain all elf section information. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate typedef struct cache { 457c478bd9Sstevel@tonic-gate int c_flags; 467c478bd9Sstevel@tonic-gate Elf_Scn *c_scn; 477c478bd9Sstevel@tonic-gate Shdr *c_shdr; 487c478bd9Sstevel@tonic-gate Elf_Data *c_data; 497c478bd9Sstevel@tonic-gate char *c_name; 507c478bd9Sstevel@tonic-gate void *c_info; 517c478bd9Sstevel@tonic-gate } Cache; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #define FLG_C_EXCLUDE 1 /* exclude section from output image */ 547c478bd9Sstevel@tonic-gate #define FLG_C_HEAP 2 /* heap section (addition) */ 557c478bd9Sstevel@tonic-gate #define FLG_C_RELOC 3 /* relocation section requiring */ 567c478bd9Sstevel@tonic-gate /* modification */ 577c478bd9Sstevel@tonic-gate #define FLG_C_SHSTR 4 /* section header string table */ 587c478bd9Sstevel@tonic-gate #define FLG_C_END 5 /* null terminating section marker */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * Define a structure for maintaining relocation information. During the first 637c478bd9Sstevel@tonic-gate * pass through an input files relocation records, counts are maintained of the 647c478bd9Sstevel@tonic-gate * number of relocations to recreate in the output image. The intent is to 657c478bd9Sstevel@tonic-gate * localize any remaining relocation records. The relocation structure 667c478bd9Sstevel@tonic-gate * indicates the actions that must be performed on the output images relocation 677c478bd9Sstevel@tonic-gate * information. 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate typedef struct reloc { 707c478bd9Sstevel@tonic-gate int r_flags; 717c478bd9Sstevel@tonic-gate Xword r_pltndx; /* pltndx if a JMP relocation */ 727c478bd9Sstevel@tonic-gate Addr r_value; /* value to apply to relocation */ 737c478bd9Sstevel@tonic-gate unsigned long r_size; /* size (used for copy relocations) */ 747c478bd9Sstevel@tonic-gate const char *r_name; /* relocation symbol */ 757c478bd9Sstevel@tonic-gate } Reloc; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #define FLG_R_UNDO 0x01 /* undo any relocation offset value */ 787c478bd9Sstevel@tonic-gate #define FLG_R_CLR 0x02 /* clear the relocation record */ 797c478bd9Sstevel@tonic-gate #define FLG_R_INC 0x04 /* increment the relocation offset */ 807c478bd9Sstevel@tonic-gate /* (uses new fixed addr) */ 817c478bd9Sstevel@tonic-gate #define FLG_R_APPLY 0x08 /* apply the relocation */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * Define any local prototypes. 867c478bd9Sstevel@tonic-gate */ 875aefb655Srie extern void apply_reloc(void *, Reloc *, const char *, uchar_t *, Rt_map *); 887c478bd9Sstevel@tonic-gate extern void clear_reloc(void *); 897c478bd9Sstevel@tonic-gate extern int count_reloc(Cache *, Cache *, Rt_map *, int, Addr, Xword *, 90*2926dd2eSrie Xword *, Xword *, Alist *); 915aefb655Srie extern void inc_reloc(void *, void *, Reloc *, uchar_t *, uchar_t *); 92*2926dd2eSrie extern int syminfo(Cache *, Alist **); 935aefb655Srie extern void undo_reloc(void *, uchar_t *, uchar_t *, Reloc *); 947c478bd9Sstevel@tonic-gate extern int update_dynamic(Cache *, Cache *, Rt_map *, int, Addr, Off, 957c478bd9Sstevel@tonic-gate const char *, Xword, Xword, Xword, Xword, Xword); 967c478bd9Sstevel@tonic-gate extern void update_reloc(Cache *, Cache *, Cache *, const char *, 977c478bd9Sstevel@tonic-gate Rt_map *, Rel **, Rel **, Rel **); 987c478bd9Sstevel@tonic-gate extern void update_sym(Cache *, Cache *, Addr, Half, Addr); 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1017c478bd9Sstevel@tonic-gate } 1027c478bd9Sstevel@tonic-gate #endif 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate #endif /* __LIBRTLD_H */ 105