reloc.c (112419) | reloc.c (115396) |
---|---|
1/*- 2 * Copyright 1996, 1997, 1998, 1999 John D. Polstra. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * | 1/*- 2 * Copyright 1996, 1997, 1998, 1999 John D. Polstra. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * |
25 * $FreeBSD: head/libexec/rtld-elf/ia64/reloc.c 112419 2003-03-19 21:38:27Z arun $ | 25 * $FreeBSD: head/libexec/rtld-elf/ia64/reloc.c 115396 2003-05-29 22:58:26Z kan $ |
26 */ 27 28/* 29 * Dynamic linker for ELF. 30 * 31 * John Polstra <jdp@polstra.com>. 32 */ 33 --- 83 unchanged lines hidden (view full) --- 117 fptrs = NULL; 118 } else { 119 fptrs = malloc(fbytes); 120 if (fptrs != NULL) 121 memset(fptrs, 0, fbytes); 122 } 123 124 /* | 26 */ 27 28/* 29 * Dynamic linker for ELF. 30 * 31 * John Polstra <jdp@polstra.com>. 32 */ 33 --- 83 unchanged lines hidden (view full) --- 117 fptrs = NULL; 118 } else { 119 fptrs = malloc(fbytes); 120 if (fptrs != NULL) 121 memset(fptrs, 0, fbytes); 122 } 123 124 /* |
125 * This assertion is necessary to guarantee function pointer 126 * uniqueness | 125 * This assertion is necessary to guarantee function pointer 126 * uniqueness |
127 */ 128 assert(fptrs != NULL); 129 130 return (obj->priv = fptrs); 131} 132 133static void 134free_fptrs(Obj_Entry *obj, bool mapped) 135{ 136 struct fptr **fptrs; 137 size_t fbytes; 138 | 127 */ 128 assert(fptrs != NULL); 129 130 return (obj->priv = fptrs); 131} 132 133static void 134free_fptrs(Obj_Entry *obj, bool mapped) 135{ 136 struct fptr **fptrs; 137 size_t fbytes; 138 |
139 fptrs = obj->priv; | 139 fptrs = obj->priv; |
140 if (fptrs == NULL) 141 return; 142 143 fbytes = obj->nchains * sizeof(struct fptr *); | 140 if (fptrs == NULL) 141 return; 142 143 fbytes = obj->nchains * sizeof(struct fptr *); |
144 if (mapped) | 144 if (mapped) |
145 munmap(fptrs, fbytes); 146 else 147 free(fptrs); 148 obj->priv = NULL; 149} 150 151/* Relocate a non-PLT object with addend. */ 152static int --- 28 unchanged lines hidden (view full) --- 181 store64(where, target + rela->r_addend); 182 break; 183 } 184 185 case R_IA64_FPTR64LSB: { 186 /* 187 * We have to make sure that all @fptr references to 188 * the same function are identical so that code can | 145 munmap(fptrs, fbytes); 146 else 147 free(fptrs); 148 obj->priv = NULL; 149} 150 151/* Relocate a non-PLT object with addend. */ 152static int --- 28 unchanged lines hidden (view full) --- 181 store64(where, target + rela->r_addend); 182 break; 183 } 184 185 case R_IA64_FPTR64LSB: { 186 /* 187 * We have to make sure that all @fptr references to 188 * the same function are identical so that code can |
189 * compare function pointers. | 189 * compare function pointers. |
190 */ 191 const Elf_Sym *def; 192 const Obj_Entry *defobj; 193 struct fptr *fptr = 0; 194 Elf_Addr target, gp; 195 int sym_index; 196 197 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, --- 110 unchanged lines hidden (view full) --- 308 goto done; 309 } 310 311 r = 0; 312done: 313 if (cache) 314 munmap(cache, bytes); 315 | 190 */ 191 const Elf_Sym *def; 192 const Obj_Entry *defobj; 193 struct fptr *fptr = 0; 194 Elf_Addr target, gp; 195 int sym_index; 196 197 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, --- 110 unchanged lines hidden (view full) --- 308 goto done; 309 } 310 311 r = 0; 312done: 313 if (cache) 314 munmap(cache, bytes); 315 |
316 /* 317 * Release temporarily mapped fptrs if relocating | 316 /* 317 * Release temporarily mapped fptrs if relocating |
318 * rtld object itself. A new table will be created 319 * in make_function_pointer using malloc when needed. 320 */ 321 if (obj->rtld && obj->priv) 322 free_fptrs(obj, true); 323 324 return (r); 325} --- 209 unchanged lines hidden --- | 318 * rtld object itself. A new table will be created 319 * in make_function_pointer using malloc when needed. 320 */ 321 if (obj->rtld && obj->priv) 322 free_fptrs(obj, true); 323 324 return (r); 325} --- 209 unchanged lines hidden --- |