Deleted Added
full compact
reloc.c (133133) reloc.c (137122)
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 133133 2004-08-04 19:12:14Z dfr $
29 * $FreeBSD: head/libexec/rtld-elf/powerpc/reloc.c 137122 2004-11-02 09:47:01Z ssouhlal $
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>

--- 163 unchanged lines hidden (view full) ---

201 break;
202
203 case R_PPC_JMP_SLOT:
204 /*
205 * These will be handled by the plt/jmpslot routines
206 */
207 break;
208
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>

--- 163 unchanged lines hidden (view full) ---

201 break;
202
203 case R_PPC_JMP_SLOT:
204 /*
205 * These will be handled by the plt/jmpslot routines
206 */
207 break;
208
209 case R_PPC_DTPMOD32:
210 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
211 false, cache);
212
213 if (def == NULL)
214 return (-1);
215
216 *where = (Elf_Addr) defobj->tlsindex;
217
218 break;
219
220 case R_PPC_TPREL32:
221 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
222 false, cache);
223
224 if (def == NULL)
225 return (-1);
226
227 /*
228 * We lazily allocate offsets for static TLS as we
229 * see the first relocation that references the
230 * TLS block. This allows us to support (small
231 * amounts of) static TLS in dynamically loaded
232 * modules. If we run out of space, we generate an
233 * error.
234 */
235 if (!defobj->tls_done) {
236 if (!allocate_tls_offset((Obj_Entry*) defobj)) {
237 _rtld_error("%s: No space available for static "
238 "Thread Local Storage", obj->path);
239 return (-1);
240 }
241 }
242
243 *(Elf_Addr **)where = *where * sizeof(Elf_Addr)
244 + (Elf_Addr *)(def->st_value + rela->r_addend
245 + defobj->tlsoffset - TLS_TP_OFFSET - TLS_TCB_SIZE);
246
247 break;
248
249 case R_PPC_DTPREL32:
250 def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
251 false, cache);
252
253 if (def == NULL)
254 return (-1);
255
256 *where += (Elf_Addr)(def->st_value + rela->r_addend
257 - TLS_DTV_OFFSET);
258
259 break;
260
209 default:
210 _rtld_error("%s: Unsupported relocation type %d"
211 " in non-PLT relocations\n", obj->path,
212 ELF_R_TYPE(rela->r_info));
213 return (-1);
214 }
215 return (0);
216}

--- 272 unchanged lines hidden (view full) ---

489 */
490 __syncicache(pltcall, 72 + N * 8);
491}
492
493void
494allocate_initial_tls(Obj_Entry *list)
495{
496 register Elf_Addr **tp __asm__("r2");
261 default:
262 _rtld_error("%s: Unsupported relocation type %d"
263 " in non-PLT relocations\n", obj->path,
264 ELF_R_TYPE(rela->r_info));
265 return (-1);
266 }
267 return (0);
268}

--- 272 unchanged lines hidden (view full) ---

541 */
542 __syncicache(pltcall, 72 + N * 8);
543}
544
545void
546allocate_initial_tls(Obj_Entry *list)
547{
548 register Elf_Addr **tp __asm__("r2");
549 Elf_Addr **_tp;
497
498 /*
499 * Fix the size of the static TLS block by using the maximum
500 * offset allocated so far and adding a bit for dynamic modules to
501 * use.
502 */
503
504 tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
505
550
551 /*
552 * Fix the size of the static TLS block by using the maximum
553 * offset allocated so far and adding a bit for dynamic modules to
554 * use.
555 */
556
557 tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
558
506 tp = (Elf_Addr **) ((char *) allocate_tls(list, 0, 8, 8) + 0x7008);
559 _tp = (Elf_Addr **) ((char *) allocate_tls(list, 0, 8, 8)
560 + TLS_TP_OFFSET + TLS_TCB_SIZE);
561
562 /*
563 * XXX gcc seems to ignore 'tp = _tp;'
564 */
565
566 __asm __volatile("mr %0,%1" : "=r"(tp) : "r"(_tp));
507}
508
509void*
510__tls_get_addr(tls_index* ti)
511{
512 register Elf_Addr **tp __asm__("r2");
513 char *p;
514
567}
568
569void*
570__tls_get_addr(tls_index* ti)
571{
572 register Elf_Addr **tp __asm__("r2");
573 char *p;
574
515 p = tls_get_addr_common(tp, ti->ti_module, ti->ti_offset);
516 return p + 0x8000;
575 p = tls_get_addr_common((Elf_Addr**)((Elf_Addr)tp - TLS_TP_OFFSET
576 - TLS_TCB_SIZE), ti->ti_module, ti->ti_offset);
577
578 return (p + TLS_DTV_OFFSET);
517}
579}