]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/ia64/dl-machine.h
2003-03-03 Roland McGrath <roland@redhat.com>
[thirdparty/glibc.git] / sysdeps / ia64 / dl-machine.h
1 /* Machine-dependent ELF dynamic relocation inline functions. IA-64 version.
2 Copyright (C) 1995-1997, 2000-2002, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 #ifndef dl_machine_h
21 #define dl_machine_h 1
22
23 #define ELF_MACHINE_NAME "ia64"
24
25 #include <assert.h>
26 #include <string.h>
27 #include <link.h>
28 #include <errno.h>
29 #include <tls.h>
30
31 /* Translate a processor specific dynamic tag to the index
32 in l_info array. */
33 #define DT_IA_64(x) (DT_IA_64_##x - DT_LOPROC + DT_NUM)
34
35 /* There are currently 123 dynamic symbols in ld.so.
36 IA64_BOOT_FPTR_TABLE_LEN needs to be at least that big. */
37 #define IA64_BOOT_FPTR_TABLE_LEN 200
38
39 /* An FDESC is a function descriptor. */
40
41 struct ia64_fdesc
42 {
43 Elf64_Addr ip; /* code entry point */
44 Elf64_Addr gp; /* global pointer */
45 };
46
47 struct ia64_fdesc_table
48 {
49 struct ia64_fdesc_table *next;
50 unsigned int len; /* # of entries in fdesc table */
51 volatile unsigned int first_unused; /* index of first available entry */
52 struct ia64_fdesc fdesc[0];
53 };
54
55 extern Elf64_Addr __ia64_make_fptr (struct link_map *, const Elf64_Sym *,
56 Elf64_Addr);
57
58 static inline void
59 __ia64_init_bootstrap_fdesc_table (struct link_map *map)
60 {
61 Elf64_Addr *boot_table;
62
63 /* careful: this will be called before got has been relocated... */
64 asm (";; addl %0 = @gprel (__ia64_boot_fptr_table), gp" : "=r"(boot_table));
65
66 map->l_mach.fptr_table_len = IA64_BOOT_FPTR_TABLE_LEN;
67 map->l_mach.fptr_table = boot_table;
68 }
69
70 #define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) \
71 __ia64_init_bootstrap_fdesc_table (&bootstrap_map);
72
73 /* Return nonzero iff ELF header is compatible with the running host. */
74 static inline int
75 elf_machine_matches_host (const Elf64_Ehdr *ehdr)
76 {
77 return ehdr->e_machine == EM_IA_64;
78 }
79
80
81 /* Return the link-time address of _DYNAMIC. */
82 static inline Elf64_Addr
83 elf_machine_dynamic (void)
84 {
85 Elf64_Addr *p;
86
87 __asm__ (
88 ".section .sdata\n"
89 " .type __dynamic_ltv#, @object\n"
90 " .size __dynamic_ltv#, 8\n"
91 "__dynamic_ltv:\n"
92 " data8 @ltv(_DYNAMIC#)\n"
93 ".previous\n"
94 " addl %0 = @gprel(__dynamic_ltv#), gp ;;"
95 : "=r" (p));
96
97 return *p;
98 }
99
100
101 /* Return the run-time load address of the shared object. */
102 static inline Elf64_Addr
103 elf_machine_load_address (void)
104 {
105 Elf64_Addr ip;
106 int *p;
107
108 __asm__ (
109 "1: mov %0 = ip\n"
110 ".section .sdata\n"
111 "2: data4 @ltv(1b)\n"
112 " .align 8\n"
113 ".previous\n"
114 " addl %1 = @gprel(2b), gp ;;"
115 : "=r" (ip), "=r" (p));
116
117 return ip - (Elf64_Addr) *p;
118 }
119
120 /* Set up the loaded object described by L so its unrelocated PLT
121 entries will jump to the on-demand fixup code in dl-runtime.c. */
122
123 static inline int
124 elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
125 {
126 extern void _dl_runtime_resolve (void);
127 extern void _dl_runtime_profile (void);
128
129 if (lazy)
130 {
131 register Elf64_Addr gp __asm__ ("gp");
132 Elf64_Addr *reserve, doit;
133
134 /*
135 * Careful with the typecast here or it will try to add l-l_addr
136 * pointer elements
137 */
138 reserve = ((Elf64_Addr *)
139 (l->l_info[DT_IA_64 (PLT_RESERVE)]->d_un.d_ptr + l->l_addr));
140 /* Identify this shared object. */
141 reserve[0] = (Elf64_Addr) l;
142
143 /* This function will be called to perform the relocation. */
144 if (!profile)
145 doit = (Elf64_Addr) ((struct ia64_fdesc *) &_dl_runtime_resolve)->ip;
146 else
147 {
148 if (_dl_name_match_p (GL(dl_profile), l))
149 {
150 /* This is the object we are looking for. Say that we really
151 want profiling and the timers are started. */
152 GL(dl_profile_map) = l;
153 }
154 doit = (Elf64_Addr) ((struct ia64_fdesc *) &_dl_runtime_profile)->ip;
155 }
156
157 reserve[1] = doit;
158 reserve[2] = gp;
159 }
160
161 return lazy;
162 }
163
164
165 /*
166 This code is used in dl-runtime.c to call the `fixup' function
167 and then redirect to the address it returns. `fixup()' takes two
168 arguments, however profile_fixup() takes three.
169
170 The ABI specifies that we will never see more than 8 input
171 registers to a function call, thus it is safe to simply allocate
172 those, and simpler than playing stack games.
173 - 12/09/99 Jes
174 */
175 #define TRAMPOLINE_TEMPLATE(tramp_name, fixup_name) \
176 extern void tramp_name (void); \
177 asm ( \
178 " .global " #tramp_name "#\n" \
179 " .proc " #tramp_name "#\n" \
180 #tramp_name ":\n" \
181 " { .mmi\n" \
182 " .prologue\n" \
183 " .save ar.pfs, r40\n" \
184 " alloc loc0 = ar.pfs, 8, 6, 3, 0\n" \
185 " adds r2 = -144, r12\n" \
186 " adds r3 = -128, r12\n" \
187 " }\n" \
188 " { .mii\n" \
189 " .fframe 160\n" \
190 " adds r12 = -160, r12\n" \
191 " .save rp, r41\n" \
192 " mov loc1 = b0\n" \
193 " .body\n" \
194 " mov out2 = b0 /* needed by fixup_profile */\n" \
195 " ;;\n" \
196 " }\n" \
197 " { .mfb\n" \
198 " mov loc2 = r8 /* preserve struct value register */\n" \
199 " nop.f 0\n" \
200 " nop.b 0\n" \
201 " }\n" \
202 " { .mii\n" \
203 " mov loc3 = r9 /* preserve language specific register */\n" \
204 " mov loc4 = r10 /* preserve language specific register */\n" \
205 " mov loc5 = r11 /* preserve language specific register */\n" \
206 " }\n" \
207 " { .mmi\n" \
208 " stf.spill [r2] = f8, 32\n" \
209 " stf.spill [r3] = f9, 32\n" \
210 " mov out0 = r16\n" \
211 " ;;\n" \
212 " }\n" \
213 " { .mmi\n" \
214 " stf.spill [r2] = f10, 32\n" \
215 " stf.spill [r3] = f11, 32\n" \
216 " shl out1 = r15, 4\n" \
217 " ;;\n" \
218 " }\n" \
219 " { .mmi\n" \
220 " stf.spill [r2] = f12, 32\n" \
221 " stf.spill [r3] = f13, 32\n" \
222 " shladd out1 = r15, 3, out1\n" \
223 " ;;\n" \
224 " }\n" \
225 " { .mmb\n" \
226 " stf.spill [r2] = f14\n" \
227 " stf.spill [r3] = f15\n" \
228 " br.call.sptk.many b0 = " #fixup_name "#\n" \
229 " }\n" \
230 " { .mii\n" \
231 " ld8 r9 = [ret0], 8\n" \
232 " adds r2 = 16, r12\n" \
233 " adds r3 = 32, r12\n" \
234 " ;;\n" \
235 " }\n" \
236 " { .mmi\n" \
237 " ldf.fill f8 = [r2], 32\n" \
238 " ldf.fill f9 = [r3], 32\n" \
239 " mov b0 = loc1\n" \
240 " ;;\n" \
241 " }\n" \
242 " { .mmi\n" \
243 " ldf.fill f10 = [r2], 32\n" \
244 " ldf.fill f11 = [r3], 32\n" \
245 " mov b6 = r9\n" \
246 " ;;\n" \
247 " }\n" \
248 " { .mmi\n" \
249 " ldf.fill f12 = [r2], 32\n" \
250 " ldf.fill f13 = [r3], 32\n" \
251 " mov ar.pfs = loc0\n" \
252 " ;;\n" \
253 " }\n" \
254 " { .mmi\n" \
255 " ldf.fill f14 = [r2], 32\n" \
256 " ldf.fill f15 = [r3], 32\n" \
257 " .restore sp /* pop the unwind frame state */\n" \
258 " adds r12 = 160, r12\n" \
259 " ;;\n" \
260 " }\n" \
261 " { .mii\n" \
262 " mov r9 = loc3 /* restore language specific register */\n" \
263 " mov r10 = loc4 /* restore language specific register */\n" \
264 " mov r11 = loc5 /* restore language specific register */\n" \
265 " }\n" \
266 " { .mii\n" \
267 " ld8 gp = [ret0]\n" \
268 " mov r8 = loc2 /* restore struct value register */\n" \
269 " ;;\n" \
270 " }\n" \
271 " /* An alloc is needed for the break system call to work.\n" \
272 " We don't care about the old value of the pfs register. */\n" \
273 " { .mmb\n" \
274 " .prologue\n" \
275 " .body\n" \
276 " alloc r2 = ar.pfs, 0, 0, 8, 0\n" \
277 " br.sptk.many b6\n" \
278 " ;;\n" \
279 " }\n" \
280 " .endp " #tramp_name "#\n");
281
282 #ifndef PROF
283 #define ELF_MACHINE_RUNTIME_TRAMPOLINE \
284 TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup); \
285 TRAMPOLINE_TEMPLATE (_dl_runtime_profile, profile_fixup);
286 #else
287 #define ELF_MACHINE_RUNTIME_TRAMPOLINE \
288 TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup); \
289 strong_alias (_dl_runtime_resolve, _dl_runtime_profile);
290 #endif
291
292
293 /* Initial entry point code for the dynamic linker.
294 The C function `_dl_start' is the real entry point;
295 its return value is the user program's entry point. */
296
297 #define RTLD_START asm ( \
298 ".text\n" \
299 " .global _start#\n" \
300 " .proc _start#\n" \
301 "_start:\n" \
302 "0: { .mii\n" \
303 " .prologue\n" \
304 " .save ar.pfs, r32\n" \
305 " .save rp, r0\n" \
306 " alloc loc0 = ar.pfs, 0, 3, 4, 0\n" \
307 " .body\n" \
308 " mov r2 = ip\n" \
309 " addl r3 = @gprel(0b), r0\n" \
310 " ;;\n" \
311 " }\n" \
312 " { .mlx\n" \
313 " /* Calculate the GP, and save a copy in loc1. */\n" \
314 " sub gp = r2, r3\n" \
315 " movl r8 = 0x9804c0270033f\n" \
316 " ;;\n" \
317 " }\n" \
318 " { .mii\n" \
319 " mov ar.fpsr = r8\n" \
320 " sub loc1 = r2, r3\n" \
321 " /* _dl_start wants a pointer to the pointer to the arg block and\n" \
322 " the arg block starts with an integer, thus the magic 16. */\n" \
323 " adds out0 = 16, sp\n" \
324 " }\n" \
325 " { .bbb\n" \
326 " br.call.sptk.many b0 = _dl_start#\n" \
327 " ;;\n" \
328 " }\n" \
329 " .endp _start#\n" \
330 " /* FALLTHRU */\n" \
331 " .global _dl_start_user#\n" \
332 " .proc _dl_start_user#\n" \
333 "_dl_start_user:\n" \
334 " .prologue\n" \
335 " .save ar.pfs, r32\n" \
336 " .save rp, r0\n" \
337 " .body\n" \
338 " { .mii\n" \
339 " /* Save the pointer to the user entry point fptr in loc2. */\n" \
340 " mov loc2 = ret0\n" \
341 " /* Store the highest stack address. */\n" \
342 " addl r2 = @ltoff(__libc_stack_end#), gp\n" \
343 " addl r3 = @gprel(_dl_skip_args), gp\n" \
344 " ;;\n" \
345 " }\n" \
346 " { .mmi\n" \
347 " ld8 r2 = [r2]\n" \
348 " ld4 r3 = [r3]\n" \
349 " adds r11 = 24, sp /* Load the address of argv. */\n" \
350 " ;;\n" \
351 " }\n" \
352 " { .mii\n" \
353 " st8 [r2] = sp\n" \
354 " adds r10 = 16, sp /* Load the address of argc. */\n" \
355 " mov out2 = r11\n" \
356 " ;;\n" \
357 " /* See if we were run as a command with the executable file\n" \
358 " name as an extra leading argument. If so, adjust the argv\n" \
359 " pointer to skip _dl_skip_args words.\n" \
360 " Note that _dl_skip_args is an integer, not a long - Jes\n" \
361 "\n" \
362 " The stack pointer has to be 16 byte aligned. We cannot simply\n" \
363 " addjust the stack pointer. We have to move the whole argv and\n" \
364 " envp and adjust _dl_argv by _dl_skip_args. H.J. */\n" \
365 " }\n" \
366 " { .mib\n" \
367 " ld8 out1 = [r10] /* is argc actually stored as a long\n" \
368 " or as an int? */\n" \
369 " addl r2 = @ltoff(_dl_argv), gp\n" \
370 " ;;\n" \
371 " }\n" \
372 " { .mmi\n" \
373 " ld8 r2 = [r2] /* Get the address of _dl_argv. */\n" \
374 " sub out1 = out1, r3 /* Get the new argc. */\n" \
375 " shladd r3 = r3, 3, r0\n" \
376 " ;;\n" \
377 " }\n" \
378 " {\n" \
379 " .mib\n" \
380 " ld8 r17 = [r2] /* Get _dl_argv. */\n" \
381 " add r15 = r11, r3 /* The address of the argv we move */\n" \
382 " ;;\n" \
383 " }\n" \
384 " /* ??? Could probably merge these two loops into 3 bundles.\n" \
385 " using predication to control which set of copies we're on. */\n" \
386 "1: /* Copy argv. */\n" \
387 " { .mfi\n" \
388 " ld8 r16 = [r15], 8 /* Load the value in the old argv. */\n" \
389 " ;;\n" \
390 " }\n" \
391 " { .mib\n" \
392 " st8 [r11] = r16, 8 /* Store it in the new argv. */\n" \
393 " cmp.ne p6, p7 = 0, r16\n" \
394 "(p6) br.cond.dptk.few 1b\n" \
395 " ;;\n" \
396 " }\n" \
397 " { .mmi\n" \
398 " mov out3 = r11\n" \
399 " sub r17 = r17, r3 /* Substract _dl_skip_args. */\n" \
400 " addl out0 = @gprel(_rtld_local), gp\n" \
401 " }\n" \
402 "1: /* Copy env. */\n" \
403 " { .mfi\n" \
404 " ld8 r16 = [r15], 8 /* Load the value in the old env. */\n" \
405 " ;;\n" \
406 " }\n" \
407 " { .mib\n" \
408 " st8 [r11] = r16, 8 /* Store it in the new env. */\n" \
409 " cmp.ne p6, p7 = 0, r16\n" \
410 "(p6) br.cond.dptk.few 1b\n" \
411 " ;;\n" \
412 " }\n" \
413 " { .mmb\n" \
414 " st8 [r10] = out1 /* Record the new argc. */\n" \
415 " ld8 out0 = [out0] /* get the linkmap */\n" \
416 " }\n" \
417 " { .mmb\n" \
418 " st8 [r2] = r17 /* Load the new _dl_argv. */\n" \
419 " br.call.sptk.many b0 = _dl_init_internal#\n" \
420 " ;;\n" \
421 " }\n" \
422 " /* Pass our finializer function to the user,\n" \
423 " and jump to the user's entry point. */\n" \
424 " { .mmi\n" \
425 " ld8 r3 = [loc2], 8\n" \
426 " mov b0 = r0\n" \
427 " }\n" \
428 " { .mmi\n" \
429 " addl ret0 = @ltoff(@fptr(_dl_fini#)), gp\n" \
430 " ;;\n" \
431 " mov b6 = r3\n" \
432 " }\n" \
433 " { .mmi\n" \
434 " ld8 ret0 = [ret0]\n" \
435 " ld8 gp = [loc2]\n" \
436 " mov ar.pfs = loc0\n" \
437 " ;;\n" \
438 " }\n" \
439 " { .mfb\n" \
440 " br.sptk.many b6\n" \
441 " ;;\n" \
442 " }\n" \
443 " .endp _dl_start_user#\n" \
444 ".previous\n");
445
446
447 #ifndef RTLD_START_SPECIAL_INIT
448 #define RTLD_START_SPECIAL_INIT /* nothing */
449 #endif
450
451 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or TLS
452 variable, so undefined references should not be allowed to define the
453 value.
454 ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
455 of the main executable's symbols, as for a COPY reloc, which we don't
456 use. */
457 /* ??? Ignore *MSB for now. */
458 #if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD)
459 #define elf_machine_type_class(type) \
460 (((type) == R_IA64_IPLTLSB || (type) == R_IA64_DTPMOD64LSB \
461 || (type) == R_IA64_DTPREL64LSB || (type) == R_IA64_TPREL64LSB) \
462 * ELF_RTYPE_CLASS_PLT)
463 #else
464 #define elf_machine_type_class(type) \
465 (((type) == R_IA64_IPLTLSB) * ELF_RTYPE_CLASS_PLT)
466 #endif
467
468 /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
469 #define ELF_MACHINE_JMP_SLOT R_IA64_IPLTLSB
470
471 /* According to the IA-64 specific documentation, Rela is always used. */
472 #define ELF_MACHINE_NO_REL 1
473
474 /* Return the address of the entry point. */
475 #define ELF_MACHINE_START_ADDRESS(map, start) \
476 DL_STATIC_FUNCTION_ADDRESS (map, start)
477
478 #define elf_machine_profile_fixup_plt(l, reloc, rel_addr, value) \
479 elf_machine_fixup_plt (l, reloc, rel_addr, value)
480
481 #define elf_machine_profile_plt(reloc_addr) ((Elf64_Addr) (reloc_addr))
482
483 /* Fixup a PLT entry to bounce directly to the function at VALUE. */
484 static inline Elf64_Addr
485 elf_machine_fixup_plt (struct link_map *l, lookup_t t,
486 const Elf64_Rela *reloc,
487 Elf64_Addr *reloc_addr, Elf64_Addr value)
488 {
489 /* l is the link_map for the caller, t is the link_map for the object
490 * being called */
491 /* got has already been relocated in elf_get_dynamic_info() */
492 reloc_addr[1] = t->l_info[DT_PLTGOT]->d_un.d_ptr;
493 /* we need a "release" here to ensure that the gp is visible before
494 the code entry point is updated: */
495 ((volatile Elf64_Addr *) reloc_addr)[0] = value;
496 return (Elf64_Addr) reloc_addr;
497 }
498
499 /* Return the final value of a plt relocation. */
500 static inline Elf64_Addr
501 elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
502 Elf64_Addr value)
503 {
504 /* No need to handle rel vs rela since IA64 is rela only */
505 return value + reloc->r_addend;
506 }
507
508 #endif /* !dl_machine_h */
509
510 #ifdef RESOLVE_MAP
511
512 #define R_IA64_TYPE(R) ((R) & -8)
513 #define R_IA64_FORMAT(R) ((R) & 7)
514
515 #define R_IA64_FORMAT_32MSB 4
516 #define R_IA64_FORMAT_32LSB 5
517 #define R_IA64_FORMAT_64MSB 6
518 #define R_IA64_FORMAT_64LSB 7
519
520
521 /* Perform the relocation specified by RELOC and SYM (which is fully
522 resolved). MAP is the object containing the reloc. */
523 static inline void
524 elf_machine_rela (struct link_map *map,
525 const Elf64_Rela *reloc,
526 const Elf64_Sym *sym,
527 const struct r_found_version *version,
528 Elf64_Addr *const reloc_addr)
529 {
530 const unsigned long int r_type = ELF64_R_TYPE (reloc->r_info);
531 Elf64_Addr value;
532
533 #if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC && !defined SHARED
534 /* This is defined in rtld.c, but nowhere in the static libc.a; make the
535 reference weak so static programs can still link. This declaration
536 cannot be done when compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP)
537 because rtld.c contains the common defn for _dl_rtld_map, which is
538 incompatible with a weak decl in the same file. */
539 weak_extern (_dl_rtld_map);
540 #endif
541
542 /* We cannot use a switch here because we cannot locate the switch
543 jump table until we've self-relocated. */
544
545 #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
546 if (__builtin_expect (R_IA64_TYPE (r_type) == R_IA64_TYPE (R_IA64_REL64LSB),
547 0))
548 {
549 assert (ELF64_R_TYPE (reloc->r_info) == R_IA64_REL64LSB);
550 value = *reloc_addr;
551 # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
552 /* Already done in dynamic linker. */
553 if (map != &GL(dl_rtld_map))
554 # endif
555 value += map->l_addr;
556 }
557 else
558 #endif
559 if (__builtin_expect (r_type == R_IA64_NONE, 0))
560 return;
561 else
562 {
563 struct link_map *sym_map;
564
565 /* RESOLVE_MAP() will return NULL if it fail to locate the symbol. */
566 if ((sym_map = RESOLVE_MAP (&sym, version, r_type)))
567 {
568 value = sym_map->l_addr + sym->st_value + reloc->r_addend;
569
570 if (R_IA64_TYPE (r_type) == R_IA64_TYPE (R_IA64_DIR64LSB))
571 ;/* No adjustment. */
572 else if (r_type == R_IA64_IPLTLSB)
573 {
574 elf_machine_fixup_plt (NULL, sym_map, reloc, reloc_addr, value);
575 return;
576 }
577 else if (R_IA64_TYPE (r_type) == R_IA64_TYPE (R_IA64_FPTR64LSB))
578 value = __ia64_make_fptr (sym_map, sym, value);
579 else if (R_IA64_TYPE (r_type) == R_IA64_TYPE (R_IA64_PCREL64LSB))
580 value -= (Elf64_Addr) reloc_addr & -16;
581 #if defined USE_TLS && (!defined RTLD_BOOTSTRAP || defined USE___THREAD)
582 else if (R_IA64_TYPE (r_type) == R_IA64_TYPE (R_IA64_DTPMOD64LSB))
583 # ifdef RTLD_BOOTSTRAP
584 /* During startup the dynamic linker is always index 1. */
585 value = 1;
586 # else
587 /* Get the information from the link map returned by the
588 resolv function. */
589 value = sym_map->l_tls_modid;
590 else if (R_IA64_TYPE (r_type) == R_IA64_TYPE (R_IA64_DTPREL64LSB))
591 value -= sym_map->l_addr;
592 # endif
593 else if (R_IA64_TYPE (r_type) == R_IA64_TYPE (R_IA64_TPREL64LSB))
594 {
595 # ifndef RTLD_BOOTSTRAP
596 CHECK_STATIC_TLS (map, sym_map);
597 # endif
598 value += sym_map->l_tls_offset - sym_map->l_addr;
599 }
600 #endif
601 else
602 assert (! "unexpected dynamic reloc type");
603 }
604 else
605 value = 0;
606 }
607
608 /* ??? Ignore MSB and Instruction format for now. */
609 if (R_IA64_FORMAT (r_type) == R_IA64_FORMAT_64LSB)
610 *reloc_addr = value;
611 else if (R_IA64_FORMAT (r_type) == R_IA64_FORMAT_32LSB)
612 *(int *) reloc_addr = value;
613 else if (r_type == R_IA64_IPLTLSB)
614 {
615 reloc_addr[0] = 0;
616 reloc_addr[1] = 0;
617 }
618 else
619 assert (! "unexpected dynamic reloc format");
620 }
621
622 /* Let do-rel.h know that on IA-64 if l_addr is 0, all RELATIVE relocs
623 can be skipped. */
624 #define ELF_MACHINE_REL_RELATIVE 1
625
626 static inline void
627 elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
628 Elf64_Addr *const reloc_addr)
629 {
630 /* ??? Ignore MSB and Instruction format for now. */
631 assert (ELF64_R_TYPE (reloc->r_info) == R_IA64_REL64LSB);
632
633 *reloc_addr += l_addr;
634 }
635
636 /* Perform a RELATIVE reloc on the .got entry that transfers to the .plt. */
637 static inline void
638 elf_machine_lazy_rel (struct link_map *map,
639 Elf64_Addr l_addr, const Elf64_Rela *reloc)
640 {
641 Elf64_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
642 const unsigned long int r_type = ELF64_R_TYPE (reloc->r_info);
643
644 if (r_type == R_IA64_IPLTLSB)
645 {
646 reloc_addr[0] += l_addr;
647 reloc_addr[1] += l_addr;
648 }
649 else if (r_type == R_IA64_NONE)
650 return;
651 else
652 assert (! "unexpected PLT reloc type");
653 }
654
655 #endif /* RESOLVE_MAP */