reloc.c (208256) | reloc.c (209885) |
---|---|
1/* $NetBSD: ppc_reloc.c,v 1.10 2001/09/10 06:09:41 mycroft Exp $ */ 2 3/*- 4 * Copyright (C) 1998 Tsubai Masanari 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * | 1/* $NetBSD: ppc_reloc.c,v 1.10 2001/09/10 06:09:41 mycroft Exp $ */ 2 3/*- 4 * Copyright (C) 1998 Tsubai Masanari 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/libexec/rtld-elf/powerpc/reloc.c 208256 2010-05-18 08:55:23Z rdivacky $ | 29 * $FreeBSD: head/libexec/rtld-elf/powerpc64/reloc.c 209885 2010-07-10 17:43:24Z nwhitehorn $ |
30 */ 31 32#include <sys/param.h> 33#include <sys/mman.h> 34 35#include <errno.h> 36#include <stdio.h> 37#include <stdlib.h> 38#include <string.h> 39#include <unistd.h> 40#include <machine/cpu.h> 41#include <machine/md_var.h> 42 43#include "debug.h" 44#include "rtld.h" 45 | 30 */ 31 32#include <sys/param.h> 33#include <sys/mman.h> 34 35#include <errno.h> 36#include <stdio.h> 37#include <stdlib.h> 38#include <string.h> 39#include <unistd.h> 40#include <machine/cpu.h> 41#include <machine/md_var.h> 42 43#include "debug.h" 44#include "rtld.h" 45 |
46#define _ppc_ha(x) ((((u_int32_t)(x) & 0x8000) ? \ 47 ((u_int32_t)(x) + 0x10000) : (u_int32_t)(x)) >> 16) 48#define _ppc_la(x) ((u_int32_t)(x) & 0xffff) | 46struct funcdesc { 47 Elf_Addr addr; 48 Elf_Addr toc; 49 Elf_Addr env; 50}; |
49 | 51 |
50#define min(a,b) (((a) < (b)) ? (a) : (b)) 51#define max(a,b) (((a) > (b)) ? (a) : (b)) 52 53#define PLT_EXTENDED_BEGIN (1 << 13) 54#define JMPTAB_BASE(N) (18 + N*2 + ((N > PLT_EXTENDED_BEGIN) ? \ 55 (N - PLT_EXTENDED_BEGIN)*2 : 0)) 56 | |
57/* 58 * Process the R_PPC_COPY relocations 59 */ 60int 61do_copy_relocations(Obj_Entry *dstobj) 62{ 63 const Elf_Rela *relalim; 64 const Elf_Rela *rela; --- 39 unchanged lines hidden (view full) --- 104 _rtld_error("Undefined symbol \"%s\" " 105 " referenced from COPY" 106 " relocation in %s", name, dstobj->path); 107 return (-1); 108 } 109 110 srcaddr = (const void *) (srcobj->relocbase+srcsym->st_value); 111 memcpy(dstaddr, srcaddr, size); | 52/* 53 * Process the R_PPC_COPY relocations 54 */ 55int 56do_copy_relocations(Obj_Entry *dstobj) 57{ 58 const Elf_Rela *relalim; 59 const Elf_Rela *rela; --- 39 unchanged lines hidden (view full) --- 99 _rtld_error("Undefined symbol \"%s\" " 100 " referenced from COPY" 101 " relocation in %s", name, dstobj->path); 102 return (-1); 103 } 104 105 srcaddr = (const void *) (srcobj->relocbase+srcsym->st_value); 106 memcpy(dstaddr, srcaddr, size); |
112 dbg("copy_reloc: src=%p,dst=%p,size=%d\n",srcaddr,dstaddr,size); | 107 dbg("copy_reloc: src=%p,dst=%p,size=%zd\n",srcaddr,dstaddr,size); |
113 } 114 115 return (0); 116} 117 118 119/* 120 * Perform early relocation of the run-time linker image --- 42 unchanged lines hidden (view full) --- 163 const Obj_Entry *defobj; 164 Elf_Addr tmp; 165 166 switch (ELF_R_TYPE(rela->r_info)) { 167 168 case R_PPC_NONE: 169 break; 170 | 108 } 109 110 return (0); 111} 112 113 114/* 115 * Perform early relocation of the run-time linker image --- 42 unchanged lines hidden (view full) --- 158 const Obj_Entry *defobj; 159 Elf_Addr tmp; 160 161 switch (ELF_R_TYPE(rela->r_info)) { 162 163 case R_PPC_NONE: 164 break; 165 |
171 case R_PPC_ADDR32: /* word32 S + A */ 172 case R_PPC_GLOB_DAT: /* word32 S + A */ | 166 case R_PPC64_ADDR64: /* doubleword64 S + A */ 167 case R_PPC_GLOB_DAT: |
173 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, 174 false, cache); 175 if (def == NULL) { 176 return (-1); 177 } 178 179 tmp = (Elf_Addr)(defobj->relocbase + def->st_value + 180 rela->r_addend); 181 182 /* Don't issue write if unnecessary; avoid COW page fault */ 183 if (*where != tmp) { 184 *where = tmp; 185 } 186 break; 187 | 168 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, 169 false, cache); 170 if (def == NULL) { 171 return (-1); 172 } 173 174 tmp = (Elf_Addr)(defobj->relocbase + def->st_value + 175 rela->r_addend); 176 177 /* Don't issue write if unnecessary; avoid COW page fault */ 178 if (*where != tmp) { 179 *where = tmp; 180 } 181 break; 182 |
188 case R_PPC_RELATIVE: /* word32 B + A */ | 183 case R_PPC_RELATIVE: /* doubleword64 B + A */ |
189 tmp = (Elf_Addr)(obj->relocbase + rela->r_addend); 190 191 /* As above, don't issue write unnecessarily */ 192 if (*where != tmp) { 193 *where = tmp; 194 } 195 break; 196 --- 14 unchanged lines hidden (view full) --- 211 break; 212 213 case R_PPC_JMP_SLOT: 214 /* 215 * These will be handled by the plt/jmpslot routines 216 */ 217 break; 218 | 184 tmp = (Elf_Addr)(obj->relocbase + rela->r_addend); 185 186 /* As above, don't issue write unnecessarily */ 187 if (*where != tmp) { 188 *where = tmp; 189 } 190 break; 191 --- 14 unchanged lines hidden (view full) --- 206 break; 207 208 case R_PPC_JMP_SLOT: 209 /* 210 * These will be handled by the plt/jmpslot routines 211 */ 212 break; 213 |
219 case R_PPC_DTPMOD32: | 214 case R_PPC64_DTPMOD64: |
220 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, 221 false, cache); 222 223 if (def == NULL) 224 return (-1); 225 226 *where = (Elf_Addr) defobj->tlsindex; 227 228 break; 229 | 215 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, 216 false, cache); 217 218 if (def == NULL) 219 return (-1); 220 221 *where = (Elf_Addr) defobj->tlsindex; 222 223 break; 224 |
230 case R_PPC_TPREL32: | 225 case R_PPC64_TPREL64: |
231 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, 232 false, cache); 233 234 if (def == NULL) 235 return (-1); 236 237 /* 238 * We lazily allocate offsets for static TLS as we --- 12 unchanged lines hidden (view full) --- 251 } 252 253 *(Elf_Addr **)where = *where * sizeof(Elf_Addr) 254 + (Elf_Addr *)(def->st_value + rela->r_addend 255 + defobj->tlsoffset - TLS_TP_OFFSET); 256 257 break; 258 | 226 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, 227 false, cache); 228 229 if (def == NULL) 230 return (-1); 231 232 /* 233 * We lazily allocate offsets for static TLS as we --- 12 unchanged lines hidden (view full) --- 246 } 247 248 *(Elf_Addr **)where = *where * sizeof(Elf_Addr) 249 + (Elf_Addr *)(def->st_value + rela->r_addend 250 + defobj->tlsoffset - TLS_TP_OFFSET); 251 252 break; 253 |
259 case R_PPC_DTPREL32: | 254 case R_PPC64_DTPREL64: |
260 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, 261 false, cache); 262 263 if (def == NULL) 264 return (-1); 265 266 *where += (Elf_Addr)(def->st_value + rela->r_addend 267 - TLS_DTV_OFFSET); 268 269 break; 270 271 default: | 255 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, 256 false, cache); 257 258 if (def == NULL) 259 return (-1); 260 261 *where += (Elf_Addr)(def->st_value + rela->r_addend 262 - TLS_DTV_OFFSET); 263 264 break; 265 266 default: |
272 _rtld_error("%s: Unsupported relocation type %d" | 267 _rtld_error("%s: Unsupported relocation type %ld" |
273 " in non-PLT relocations\n", obj->path, 274 ELF_R_TYPE(rela->r_info)); 275 return (-1); 276 } 277 return (0); 278} 279 280 281/* 282 * Process non-PLT relocations 283 */ 284int 285reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) 286{ 287 const Elf_Rela *relalim; 288 const Elf_Rela *rela; 289 SymCache *cache; | 268 " in non-PLT relocations\n", obj->path, 269 ELF_R_TYPE(rela->r_info)); 270 return (-1); 271 } 272 return (0); 273} 274 275 276/* 277 * Process non-PLT relocations 278 */ 279int 280reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) 281{ 282 const Elf_Rela *relalim; 283 const Elf_Rela *rela; 284 SymCache *cache; |
285 int bytes = obj->nchains * sizeof(SymCache); |
|
290 int r = -1; 291 292 /* 293 * The dynamic loader may be called from a thread, we have 294 * limited amounts of stack available so we cannot use alloca(). 295 */ 296 if (obj != obj_rtld) { | 286 int r = -1; 287 288 /* 289 * The dynamic loader may be called from a thread, we have 290 * limited amounts of stack available so we cannot use alloca(). 291 */ 292 if (obj != obj_rtld) { |
297 cache = calloc(obj->nchains, sizeof(SymCache)); 298 /* No need to check for NULL here */ | 293 cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, 294 -1, 0); 295 if (cache == MAP_FAILED) 296 cache = NULL; |
299 } else 300 cache = NULL; 301 302 /* 303 * From the SVR4 PPC ABI: 304 * "The PowerPC family uses only the Elf32_Rela relocation 305 * entries with explicit addends." 306 */ 307 relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize); 308 for (rela = obj->rela; rela < relalim; rela++) { 309 if (reloc_nonplt_object(obj_rtld, obj, rela, cache) < 0) 310 goto done; 311 } 312 r = 0; 313done: | 297 } else 298 cache = NULL; 299 300 /* 301 * From the SVR4 PPC ABI: 302 * "The PowerPC family uses only the Elf32_Rela relocation 303 * entries with explicit addends." 304 */ 305 relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize); 306 for (rela = obj->rela; rela < relalim; rela++) { 307 if (reloc_nonplt_object(obj_rtld, obj, rela, cache) < 0) 308 goto done; 309 } 310 r = 0; 311done: |
314 if (cache != NULL) 315 free(cache); | 312 if (cache) { 313 munmap(cache, bytes); 314 } |
316 return (r); 317} 318 | 315 return (r); 316} 317 |
318 |
|
319/* 320 * Initialise a PLT slot to the resolving trampoline 321 */ 322static int 323reloc_plt_object(Obj_Entry *obj, const Elf_Rela *rela) 324{ | 319/* 320 * Initialise a PLT slot to the resolving trampoline 321 */ 322static int 323reloc_plt_object(Obj_Entry *obj, const Elf_Rela *rela) 324{ |
325 Elf_Word *where = (Elf_Word *)(obj->relocbase + rela->r_offset); 326 Elf_Addr *pltresolve, *pltlongresolve, *jmptab; 327 Elf_Addr distance; 328 int N = obj->pltrelasize / sizeof(Elf_Rela); 329 int reloff; | 325 Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset); 326 Elf_Addr *glink; 327 long reloff; |
330 331 reloff = rela - obj->pltrela; 332 | 328 329 reloff = rela - obj->pltrela; 330 |
333 if (reloff < 0) 334 return (-1); | 331 if (obj->priv == NULL) 332 obj->priv = malloc(obj->pltrelasize); 333 glink = obj->priv + reloff*sizeof(Elf_Addr)*2; |
335 | 334 |
336 pltlongresolve = obj->pltgot + 5; 337 pltresolve = pltlongresolve + 5; 338 339 distance = (Elf_Addr)pltresolve - (Elf_Addr)(where + 1); 340 341 dbg(" reloc_plt_object: where=%p,pltres=%p,reloff=%x,distance=%x", 342 (void *)where, (void *)pltresolve, reloff, distance); 343 344 if (reloff < PLT_EXTENDED_BEGIN) { 345 /* li r11,reloff */ 346 /* b pltresolve */ 347 where[0] = 0x39600000 | reloff; 348 where[1] = 0x48000000 | (distance & 0x03fffffc); 349 } else { 350 jmptab = obj->pltgot + JMPTAB_BASE(N); 351 jmptab[reloff] = (u_int)pltlongresolve; 352 353 /* lis r11,jmptab[reloff]@ha */ 354 /* lwzu r12,jmptab[reloff]@l(r11) */ 355 /* mtctr r12 */ 356 /* bctr */ 357 where[0] = 0x3d600000 | _ppc_ha(&jmptab[reloff]); 358 where[1] = 0x858b0000 | _ppc_la(&jmptab[reloff]); 359 where[2] = 0x7d8903a6; 360 where[3] = 0x4e800420; | 335 if ((reloff < 0) || (reloff >= 0x8000)) { 336 return (-1); |
361 } | 337 } |
362 | |
363 | 338 |
364 /* 365 * The icache will be sync'd in init_pltgot, which is called 366 * after all the slots have been updated 367 */ | 339 dbg(" reloc_plt_object: where=%p,reloff=%lx,glink=%p", (void *)where, reloff, glink); |
368 | 340 |
341 memcpy(where, _rtld_bind_start, sizeof(struct funcdesc)); 342 ((struct funcdesc *)(where))->env = (Elf_Addr)glink; 343 *(glink++) = (Elf_Addr)obj; 344 *(glink++) = reloff*sizeof(Elf_Rela); 345 |
|
369 return (0); 370} 371 372 373/* 374 * Process the PLT relocations. 375 */ 376int 377reloc_plt(Obj_Entry *obj) 378{ 379 const Elf_Rela *relalim; 380 const Elf_Rela *rela; 381 382 if (obj->pltrelasize != 0) { | 346 return (0); 347} 348 349 350/* 351 * Process the PLT relocations. 352 */ 353int 354reloc_plt(Obj_Entry *obj) 355{ 356 const Elf_Rela *relalim; 357 const Elf_Rela *rela; 358 359 if (obj->pltrelasize != 0) { |
383 | |
384 relalim = (const Elf_Rela *)((char *)obj->pltrela + 385 obj->pltrelasize); 386 for (rela = obj->pltrela; rela < relalim; rela++) { 387 assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT); 388 389 if (reloc_plt_object(obj, rela) < 0) { 390 return (-1); 391 } --- 43 unchanged lines hidden (view full) --- 435 436 obj->jmpslots_done = true; 437 438 return (0); 439} 440 441 442/* | 360 relalim = (const Elf_Rela *)((char *)obj->pltrela + 361 obj->pltrelasize); 362 for (rela = obj->pltrela; rela < relalim; rela++) { 363 assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT); 364 365 if (reloc_plt_object(obj, rela) < 0) { 366 return (-1); 367 } --- 43 unchanged lines hidden (view full) --- 411 412 obj->jmpslots_done = true; 413 414 return (0); 415} 416 417 418/* |
443 * Update the value of a PLT jump slot. Branch directly to the target if 444 * it is within +/- 32Mb, otherwise go indirectly via the pltcall 445 * trampoline call and jump table. | 419 * Update the value of a PLT jump slot. |
446 */ 447Elf_Addr 448reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj, 449 const Obj_Entry *obj, const Elf_Rel *rel) 450{ | 420 */ 421Elf_Addr 422reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj, 423 const Obj_Entry *obj, const Elf_Rel *rel) 424{ |
451 Elf_Addr offset; 452 const Elf_Rela *rela = (const Elf_Rela *) rel; | 425 dbg(" reloc_jmpslot: where=%p, target=%p (%#lx + %#lx)", 426 (void *)wherep, (void *)target, *(Elf_Addr *)target, 427 (Elf_Addr)defobj->relocbase); |
453 | 428 |
454 dbg(" reloc_jmpslot: where=%p, target=%p", 455 (void *)wherep, (void *)target); 456 | |
457 /* 458 * At the PLT entry pointed at by `wherep', construct 459 * a direct transfer to the now fully resolved function 460 * address. 461 */ | 429 /* 430 * At the PLT entry pointed at by `wherep', construct 431 * a direct transfer to the now fully resolved function 432 * address. 433 */ |
462 offset = target - (Elf_Addr)wherep; | |
463 | 434 |
464 if (abs(offset) < 32*1024*1024) { /* inside 32MB? */ 465 /* b value # branch directly */ 466 *wherep = 0x48000000 | (offset & 0x03fffffc); 467 __syncicache(wherep, 4); 468 } else { 469 Elf_Addr *pltcall, *jmptab; 470 int distance; 471 int N = obj->pltrelasize / sizeof(Elf_Rela); 472 int reloff = rela - obj->pltrela; | 435 memcpy(wherep, (void *)target, sizeof(struct funcdesc)); 436 if (((struct funcdesc *)(wherep))->addr < (Elf_Addr)defobj->relocbase) { 437 /* 438 * XXX: It is possible (e.g. LD_BIND_NOW) that the function 439 * descriptor we are copying has not yet been relocated. 440 * If this happens, fix it. 441 */ |
473 | 442 |
474 if (reloff < 0) 475 return (-1); 476 477 pltcall = obj->pltgot; 478 479 dbg(" reloc_jmpslot: indir, reloff=%x, N=%x\n", 480 reloff, N); 481 482 jmptab = obj->pltgot + JMPTAB_BASE(N); 483 jmptab[reloff] = target; 484 485 if (reloff < PLT_EXTENDED_BEGIN) { 486 /* for extended PLT entries, we keep the old code */ 487 488 distance = (Elf_Addr)pltcall - (Elf_Addr)(wherep + 1); 489 490 /* li r11,reloff */ 491 /* b pltcall # use indirect pltcall routine */ 492 wherep[0] = 0x39600000 | reloff; 493 wherep[1] = 0x48000000 | (distance & 0x03fffffc); 494 __syncicache(wherep, 8); 495 } | 443 ((struct funcdesc *)(wherep))->addr += 444 (Elf_Addr)defobj->relocbase; 445 ((struct funcdesc *)(wherep))->toc += 446 (Elf_Addr)defobj->relocbase; |
496 } 497 | 447 } 448 |
449 __asm __volatile("dcbst 0,%0; sync" :: "r"(wherep) : "memory"); 450 |
|
498 return (target); 499} 500 | 451 return (target); 452} 453 |
501 502/* 503 * Setup the plt glue routines. 504 */ 505#define PLTCALL_SIZE 20 506#define PLTLONGRESOLVE_SIZE 20 507#define PLTRESOLVE_SIZE 24 508 | |
509void 510init_pltgot(Obj_Entry *obj) 511{ | 454void 455init_pltgot(Obj_Entry *obj) 456{ |
512 Elf_Word *pltcall, *pltresolve, *pltlongresolve; 513 Elf_Word *jmptab; 514 int N = obj->pltrelasize / sizeof(Elf_Rela); 515 516 pltcall = obj->pltgot; 517 518 if (pltcall == NULL) { 519 return; 520 } 521 522 /* 523 * From the SVR4 PPC ABI: 524 * 525 * 'The first 18 words (72 bytes) of the PLT are reserved for 526 * use by the dynamic linker. 527 * ... 528 * 'If the executable or shared object requires N procedure 529 * linkage table entries, the link editor shall reserve 3*N 530 * words (12*N bytes) following the 18 reserved words. The 531 * first 2*N of these words are the procedure linkage table 532 * entries themselves. The static linker directs calls to bytes 533 * (72 + (i-1)*8), for i between 1 and N inclusive. The remaining 534 * N words (4*N bytes) are reserved for use by the dynamic linker.' 535 */ 536 537 /* 538 * Copy the absolute-call assembler stub into the first part of 539 * the reserved PLT area. 540 */ 541 memcpy(pltcall, _rtld_powerpc_pltcall, PLTCALL_SIZE); 542 543 /* 544 * Determine the address of the jumptable, which is the dyn-linker 545 * reserved area after the call cells. Write the absolute address 546 * of the jumptable into the absolute-call assembler code so it 547 * can determine this address. 548 */ 549 jmptab = obj->pltgot + JMPTAB_BASE(N); 550 pltcall[1] |= _ppc_ha(jmptab); /* addis 11,11,jmptab@ha */ 551 pltcall[2] |= _ppc_la(jmptab); /* lwz 11,jmptab@l(11) */ 552 553 /* 554 * Skip down 20 bytes into the initial reserved area and copy 555 * in the standard resolving assembler call. Into this assembler, 556 * insert the absolute address of the _rtld_bind_start routine 557 * and the address of the relocation object. 558 * 559 * We place pltlongresolve first, so it can fix up its arguments 560 * and then fall through to the regular PLT resolver. 561 */ 562 pltlongresolve = obj->pltgot + 5; 563 564 memcpy(pltlongresolve, _rtld_powerpc_pltlongresolve, 565 PLTLONGRESOLVE_SIZE); 566 pltlongresolve[0] |= _ppc_ha(jmptab); /* lis 12,jmptab@ha */ 567 pltlongresolve[1] |= _ppc_la(jmptab); /* addi 12,12,jmptab@l */ 568 569 pltresolve = pltlongresolve + PLTLONGRESOLVE_SIZE/sizeof(uint32_t); 570 memcpy(pltresolve, _rtld_powerpc_pltresolve, PLTRESOLVE_SIZE); 571 pltresolve[0] |= _ppc_ha(_rtld_bind_start); 572 pltresolve[1] |= _ppc_la(_rtld_bind_start); 573 pltresolve[3] |= _ppc_ha(obj); 574 pltresolve[4] |= _ppc_la(obj); 575 576 /* 577 * Sync the icache for the byte range represented by the 578 * trampoline routines and call slots. 579 */ 580 __syncicache(pltcall, 72 + N * 8); | |
581} 582 583void 584allocate_initial_tls(Obj_Entry *list) 585{ | 457} 458 459void 460allocate_initial_tls(Obj_Entry *list) 461{ |
586 register Elf_Addr **tp __asm__("r2"); | 462 register Elf_Addr **tp __asm__("r13"); |
587 Elf_Addr **_tp; 588 589 /* 590 * Fix the size of the static TLS block by using the maximum 591 * offset allocated so far and adding a bit for dynamic modules to 592 * use. 593 */ 594 595 tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA; 596 | 463 Elf_Addr **_tp; 464 465 /* 466 * Fix the size of the static TLS block by using the maximum 467 * offset allocated so far and adding a bit for dynamic modules to 468 * use. 469 */ 470 471 tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA; 472 |
597 _tp = (Elf_Addr **) ((char *) allocate_tls(list, NULL, TLS_TCB_SIZE, 8) | 473 _tp = (Elf_Addr **) ((char *)allocate_tls(list, NULL, TLS_TCB_SIZE, 16) |
598 + TLS_TP_OFFSET + TLS_TCB_SIZE); 599 600 /* 601 * XXX gcc seems to ignore 'tp = _tp;' 602 */ 603 604 __asm __volatile("mr %0,%1" : "=r"(tp) : "r"(_tp)); 605} 606 607void* 608__tls_get_addr(tls_index* ti) 609{ | 474 + TLS_TP_OFFSET + TLS_TCB_SIZE); 475 476 /* 477 * XXX gcc seems to ignore 'tp = _tp;' 478 */ 479 480 __asm __volatile("mr %0,%1" : "=r"(tp) : "r"(_tp)); 481} 482 483void* 484__tls_get_addr(tls_index* ti) 485{ |
610 register Elf_Addr **tp __asm__("r2"); | 486 register Elf_Addr **tp __asm__("r13"); |
611 char *p; 612 613 p = tls_get_addr_common((Elf_Addr**)((Elf_Addr)tp - TLS_TP_OFFSET 614 - TLS_TCB_SIZE), ti->ti_module, ti->ti_offset); 615 616 return (p + TLS_DTV_OFFSET); 617} | 487 char *p; 488 489 p = tls_get_addr_common((Elf_Addr**)((Elf_Addr)tp - TLS_TP_OFFSET 490 - TLS_TCB_SIZE), ti->ti_module, ti->ti_offset); 491 492 return (p + TLS_DTV_OFFSET); 493} |