Document use of CC and CFLAGS in more detail (bug 20980, bug 21234).
[glibc.git] / sysdeps / hppa / dl-machine.h
blob31c855bfb08daba77025f0fb52bc5629fba3d45e
1 /* Machine-dependent ELF dynamic relocation inline functions. PA-RISC version.
2 Copyright (C) 1995-2018 Free Software Foundation, Inc.
3 Contributed by David Huggins-Daines <dhd@debian.org>
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef dl_machine_h
21 #define dl_machine_h 1
23 #define ELF_MACHINE_NAME "hppa"
25 #include <sys/param.h>
26 #include <assert.h>
27 #include <string.h>
28 #include <link.h>
29 #include <errno.h>
30 #include <dl-fptr.h>
31 #include <abort-instr.h>
32 #include <tls.h>
34 /* These two definitions must match the definition of the stub in
35 bfd/elf32-hppa.c (see plt_stub[]).
37 a. Define the size of the *entire* stub we place at the end of the PLT
38 table (right up against the GOT).
40 b. Define the number of bytes back from the GOT to the entry point of
41 the PLT stub. You see the PLT stub must be entered in the middle
42 so it can depwi to find it's own address (long jump stub)
44 c. Define the size of a single PLT entry so we can jump over the
45 last entry to get the stub address */
47 #define SIZEOF_PLT_STUB (7*4)
48 #define GOT_FROM_PLT_STUB (4*4)
49 #define PLT_ENTRY_SIZE (2*4)
51 /* Initialize the function descriptor table before relocations */
52 static inline void
53 __hppa_init_bootstrap_fdesc_table (struct link_map *map)
55 ElfW(Addr) *boot_table;
57 /* Careful: this will be called before got has been relocated... */
58 ELF_MACHINE_LOAD_ADDRESS(boot_table,_dl_boot_fptr_table);
60 map->l_mach.fptr_table_len = ELF_MACHINE_BOOT_FPTR_TABLE_LEN;
61 map->l_mach.fptr_table = boot_table;
64 #define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) \
65 __hppa_init_bootstrap_fdesc_table (BOOTSTRAP_MAP); \
66 _dl_fptr_init();
68 /* Return nonzero iff ELF header is compatible with the running host. */
69 static inline int
70 elf_machine_matches_host (const Elf32_Ehdr *ehdr)
72 return ehdr->e_machine == EM_PARISC;
75 /* Return the link-time address of _DYNAMIC. */
76 static inline Elf32_Addr
77 elf_machine_dynamic (void) __attribute__ ((const));
79 static inline Elf32_Addr
80 elf_machine_dynamic (void)
82 Elf32_Addr dynamic;
84 asm ("bl 1f,%0\n"
85 " addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 1),%0\n"
86 "1: ldw R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 5)(%%r1),%0\n"
87 : "=r" (dynamic) : : "r1");
89 return dynamic;
92 /* Return the run-time load address of the shared object. */
93 static inline Elf32_Addr
94 elf_machine_load_address (void) __attribute__ ((const));
96 static inline Elf32_Addr
97 elf_machine_load_address (void)
99 Elf32_Addr dynamic;
101 asm (
102 " bl 1f,%0\n"
103 " addil L'_DYNAMIC - ($PIC_pcrel$0 - 1),%0\n"
104 "1: ldo R'_DYNAMIC - ($PIC_pcrel$0 - 5)(%%r1),%0\n"
105 : "=r" (dynamic) : : "r1");
107 return dynamic - elf_machine_dynamic ();
110 /* Fixup a PLT entry to bounce directly to the function at VALUE. */
111 static inline struct fdesc __attribute__ ((always_inline))
112 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
113 const ElfW(Sym) *refsym, const ElfW(Sym) *sym,
114 const Elf32_Rela *reloc,
115 Elf32_Addr *reloc_addr, struct fdesc value)
117 volatile Elf32_Addr *rfdesc = reloc_addr;
118 /* map is the link_map for the caller, t is the link_map for the object
119 being called */
120 rfdesc[1] = value.gp;
121 /* Need to ensure that the gp is visible before the code
122 entry point is updated */
123 rfdesc[0] = value.ip;
124 return value;
127 /* Return the final value of a plt relocation. */
128 static inline struct fdesc
129 elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
130 struct fdesc value)
132 /* We are rela only, return a function descriptor as a plt entry. */
133 return (struct fdesc) { value.ip + reloc->r_addend, value.gp };
136 /* Set up the loaded object described by L so its unrelocated PLT
137 entries will jump to the on-demand fixup code in dl-runtime.c. */
139 static inline int
140 elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
142 Elf32_Addr *got = NULL;
143 Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type, r_sym;
144 const Elf32_Rela *reloc;
145 struct fdesc *fptr;
146 static union {
147 unsigned char c[8];
148 Elf32_Addr i[2];
149 } sig = {{0x00,0xc0,0xff,0xee, 0xde,0xad,0xbe,0xef}};
151 /* If we don't have a PLT we can just skip all this... */
152 if (__builtin_expect (l->l_info[DT_JMPREL] == NULL,0))
153 return lazy;
155 /* All paths use these values */
156 l_addr = l->l_addr;
157 jmprel = D_PTR(l, l_info[DT_JMPREL]);
158 end_jmprel = jmprel + l->l_info[DT_PLTRELSZ]->d_un.d_val;
160 extern void _dl_runtime_resolve (void);
161 extern void _dl_runtime_profile (void);
163 /* Linking lazily */
164 if (lazy)
166 /* FIXME: Search for the got, but backwards through the relocs, technically we should
167 find it on the first try. However, assuming the relocs got out of order the
168 routine is made a bit more robust by searching them all in case of failure. */
169 for (iplt = (end_jmprel - sizeof(Elf32_Rela)); iplt >= jmprel; iplt -= sizeof (Elf32_Rela))
172 reloc = (const Elf32_Rela *) iplt;
173 r_type = ELF32_R_TYPE (reloc->r_info);
174 r_sym = ELF32_R_SYM (reloc->r_info);
176 got = (Elf32_Addr *) (reloc->r_offset + l_addr + PLT_ENTRY_SIZE + SIZEOF_PLT_STUB);
178 /* If we aren't an IPLT, and we aren't NONE then it's a bad reloc */
179 if (__builtin_expect (r_type != R_PARISC_IPLT, 0))
181 if (__builtin_expect (r_type != R_PARISC_NONE, 0))
182 _dl_reloc_bad_type (l, r_type, 1);
183 continue;
186 /* Check for the plt_stub that binutils placed here for us
187 to use with _dl_runtime_resolve */
188 if (got[-2] != sig.i[0] || got[-1] != sig.i[1])
190 got = NULL; /* Not the stub... keep looking */
192 else
194 /* Found the GOT! */
195 register Elf32_Addr ltp __asm__ ("%r19");
197 /* Identify this shared object. Second entry in the got. */
198 got[1] = (Elf32_Addr) l;
200 /* This function will be called to perform the relocation. */
201 if (__builtin_expect (!profile, 1))
203 /* If a static application called us, then _dl_runtime_resolve is not
204 a function descriptor, but the *real* address of the function... */
205 if((unsigned long) &_dl_runtime_resolve & 3)
207 got[-2] = (Elf32_Addr) ((struct fdesc *)
208 ((unsigned long) &_dl_runtime_resolve & ~3))->ip;
210 else
212 /* Static executable! */
213 got[-2] = (Elf32_Addr) &_dl_runtime_resolve;
216 else
218 if (GLRO(dl_profile) != NULL
219 && _dl_name_match_p (GLRO(dl_profile), l))
221 /* This is the object we are looking for. Say that
222 we really want profiling and the timers are
223 started. */
224 GL(dl_profile_map) = l;
227 if((unsigned long) &_dl_runtime_profile & 3)
229 got[-2] = (Elf32_Addr) ((struct fdesc *)
230 ((unsigned long) &_dl_runtime_profile & ~3))->ip;
232 else
234 /* Static executable */
235 got[-2] = (Elf32_Addr) &_dl_runtime_profile;
238 /* Plunk in the gp of this function descriptor so we
239 can make the call to _dl_runtime_xxxxxx */
240 got[-1] = ltp;
241 break;
242 /* Done looking for the GOT, and stub is setup */
243 } /* else we found the GOT */
244 } /* for, walk the relocs backwards */
246 if(!got)
247 return 0; /* No lazy linking for you! */
249 /* Process all the relocs, now that we know the GOT... */
250 for (iplt = jmprel; iplt < end_jmprel; iplt += sizeof (Elf32_Rela))
252 reloc = (const Elf32_Rela *) iplt;
253 r_type = ELF32_R_TYPE (reloc->r_info);
254 r_sym = ELF32_R_SYM (reloc->r_info);
256 if (__builtin_expect (r_type == R_PARISC_IPLT, 1))
258 fptr = (struct fdesc *) (reloc->r_offset + l_addr);
259 if (r_sym != 0)
261 /* Relocate the pointer to the stub. */
262 fptr->ip = (Elf32_Addr) got - GOT_FROM_PLT_STUB;
264 /* Instead of the LTP value, we put the reloc offset
265 here. The trampoline code will load the proper
266 LTP and pass the reloc offset to the fixup
267 function. */
268 fptr->gp = iplt - jmprel;
269 } /* r_sym != 0 */
270 else
272 /* Relocate this *ABS* entry. */
273 fptr->ip = reloc->r_addend + l_addr;
274 fptr->gp = D_PTR (l, l_info[DT_PLTGOT]);
276 } /* r_type == R_PARISC_IPLT */
277 } /* for all the relocations */
278 } /* if lazy */
279 else
281 for (iplt = jmprel; iplt < end_jmprel; iplt += sizeof (Elf32_Rela))
283 reloc = (const Elf32_Rela *) iplt;
284 r_type = ELF32_R_TYPE (reloc->r_info);
285 r_sym = ELF32_R_SYM (reloc->r_info);
287 if (__builtin_expect ((r_type == R_PARISC_IPLT) && (r_sym == 0), 1))
289 fptr = (struct fdesc *) (reloc->r_offset + l_addr);
290 /* Relocate this *ABS* entry, set only the gp, the rest is set later
291 when elf_machine_rela_relative is called (WITHOUT the linkmap) */
292 fptr->gp = D_PTR (l, l_info[DT_PLTGOT]);
293 } /* r_type == R_PARISC_IPLT */
294 } /* for all the relocations */
296 return lazy;
300 /* Names of the architecture-specific auditing callback functions. */
301 #define ARCH_LA_PLTENTER hppa_gnu_pltenter
302 #define ARCH_LA_PLTEXIT hppa_gnu_pltexit
304 /* Adjust DL_STACK_END to get value we want in __libc_stack_end. */
305 #define DL_STACK_END(cookie) \
306 ((void *) (((long) (cookie)) + 0x160))
308 /* Initial entry point code for the dynamic linker.
309 The C function `_dl_start' is the real entry point;
310 its return value is the user program's entry point. */
312 #define RTLD_START \
313 /* Set up dp for any non-PIC lib constructors that may be called. */ \
314 static struct link_map * __attribute__((used)) \
315 set_dp (struct link_map *map) \
317 register Elf32_Addr dp asm ("%r27"); \
318 dp = D_PTR (map, l_info[DT_PLTGOT]); \
319 asm volatile ("" : : "r" (dp)); \
320 return map; \
323 asm ( \
324 " .text\n" \
325 " .globl _start\n" \
326 " .type _start,@function\n" \
327 "_start:\n" \
328 /* The kernel does not give us an initial stack frame. */ \
329 " ldo 64(%sp),%sp\n" \
330 /* Save the relevant arguments (yes, those are the correct \
331 registers, the kernel is weird) in their stack slots. */ \
332 " stw %r25,-40(%sp)\n" /* argc */ \
333 " stw %r24,-44(%sp)\n" /* argv */ \
335 /* We need the LTP, and we need it now. \
336 $PIC_pcrel$0 points 8 bytes past the current instruction, \
337 just like a branch reloc. This sequence gets us the \
338 runtime address of _DYNAMIC. */ \
339 " bl 0f,%r19\n" \
340 " addil L'_DYNAMIC - ($PIC_pcrel$0 - 1),%r19\n" \
341 "0: ldo R'_DYNAMIC - ($PIC_pcrel$0 - 5)(%r1),%r26\n" \
343 /* The link time address is stored in the first entry of the \
344 GOT. */ \
345 " addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 9),%r19\n" \
346 " ldw R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 13)(%r1),%r20\n" \
348 " sub %r26,%r20,%r20\n" /* Calculate load offset */ \
350 /* Rummage through the dynamic entries, looking for \
351 DT_PLTGOT. */ \
352 " ldw,ma 8(%r26),%r19\n" \
353 "1: cmpib,=,n 3,%r19,2f\n" /* tag == DT_PLTGOT? */ \
354 " cmpib,<>,n 0,%r19,1b\n" \
355 " ldw,ma 8(%r26),%r19\n" \
357 /* Uh oh! We didn't find one. Abort. */ \
358 " iitlbp %r0,(%sr0,%r0)\n" \
360 "2: ldw -4(%r26),%r19\n" /* Found it, load value. */ \
361 " add %r19,%r20,%r19\n" /* And add the load offset. */ \
363 /* Our initial stack layout is rather different from everyone \
364 else's due to the unique PA-RISC ABI. As far as I know it \
365 looks like this: \
367 ----------------------------------- (this frame created above) \
368 | 32 bytes of magic | \
369 |---------------------------------| \
370 | 32 bytes argument/sp save area | \
371 |---------------------------------| ((current->mm->env_end) \
372 | N bytes of slack | + 63 & ~63) \
373 |---------------------------------| \
374 | envvar and arg strings | \
375 |---------------------------------| \
376 | ELF auxiliary info | \
377 | (up to 28 words) | \
378 |---------------------------------| \
379 | Environment variable pointers | \
380 | upwards to NULL | \
381 |---------------------------------| \
382 | Argument pointers | \
383 | upwards to NULL | \
384 |---------------------------------| \
385 | argc (1 word) | \
386 ----------------------------------- \
388 So, obviously, we can't just pass %sp to _dl_start. That's \
389 okay, argv-4 will do just fine. \
391 The pleasant part of this is that if we need to skip \
392 arguments we can just decrement argc and move argv, because \
393 the stack pointer is utterly unrelated to the location of \
394 the environment and argument vectors. */ \
396 /* This is always within range so we'll be okay. */ \
397 " bl _dl_start,%rp\n" \
398 " ldo -4(%r24),%r26\n" \
400 " .globl _dl_start_user\n" \
401 " .type _dl_start_user,@function\n" \
402 "_dl_start_user:\n" \
403 /* Save the entry point in %r3. */ \
404 " copy %ret0,%r3\n" \
406 /* See if we were called as a command with the executable file \
407 name as an extra leading argument. */ \
408 " addil LT'_dl_skip_args,%r19\n" \
409 " ldw RT'_dl_skip_args(%r1),%r20\n" \
410 " ldw 0(%r20),%r20\n" \
412 " ldw -40(%sp),%r25\n" /* argc */ \
413 " comib,= 0,%r20,.Lnofix\n" /* FIXME: Mispredicted branch */\
414 " ldw -44(%sp),%r24\n" /* argv (delay slot) */ \
416 " sub %r25,%r20,%r25\n" \
417 " stw %r25,-40(%sp)\n" \
418 " sh2add %r20,%r24,%r24\n" \
419 " stw %r24,-44(%sp)\n" \
421 ".Lnofix:\n" \
422 " addil LT'_rtld_local,%r19\n" \
423 " ldw RT'_rtld_local(%r1),%r26\n" \
424 " bl set_dp, %r2\n" \
425 " ldw 0(%r26),%r26\n" \
427 /* Call _dl_init(_dl_loaded, argc, argv, envp). */ \
428 " copy %r28,%r26\n" \
430 /* envp = argv + argc + 1 */ \
431 " sh2add %r25,%r24,%r23\n" \
432 " bl _dl_init,%r2\n" \
433 " ldo 4(%r23),%r23\n" /* delay slot */ \
435 /* Reload argc, argv to the registers start.S expects. */ \
436 " ldw -40(%sp),%r25\n" \
437 " ldw -44(%sp),%r24\n" \
439 /* _dl_fini is a local function in the loader, so we construct \
440 a false OPD here and pass this to the application. */ \
441 /* FIXME: Should be able to use P%, and LR RR to have the \
442 the linker construct a proper OPD. */ \
443 " .section .data\n" \
444 "__dl_fini_plabel:\n" \
445 " .word _dl_fini\n" \
446 " .word 0xdeadbeef\n" \
447 " .previous\n" \
449 /* %r3 contains a function pointer, we need to mask out the \
450 lower bits and load the gp and jump address. */ \
451 " depi 0,31,2,%r3\n" \
452 " ldw 0(%r3),%r2\n" \
453 " addil LT'__dl_fini_plabel,%r19\n" \
454 " ldw RT'__dl_fini_plabel(%r1),%r23\n" \
455 " stw %r19,4(%r23)\n" \
456 " ldw 4(%r3),%r19\n" /* load the object's gp */ \
457 " bv %r0(%r2)\n" \
458 " depi 2,31,2,%r23\n" /* delay slot */ \
461 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
462 a TLS variable, so references should not be allowed to define the value.
463 ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to one
464 of the main executable's symbols, as for a COPY reloc. */
465 #if !defined RTLD_BOOTSTRAP
466 # define elf_machine_type_class(type) \
467 ((((type) == R_PARISC_IPLT \
468 || (type) == R_PARISC_EPLT \
469 || (type) == R_PARISC_TLS_DTPMOD32 \
470 || (type) == R_PARISC_TLS_DTPOFF32 \
471 || (type) == R_PARISC_TLS_TPREL32) \
472 * ELF_RTYPE_CLASS_PLT) \
473 | (((type) == R_PARISC_COPY) * ELF_RTYPE_CLASS_COPY))
474 #else
475 #define elf_machine_type_class(type) \
476 ((((type) == R_PARISC_IPLT \
477 || (type) == R_PARISC_EPLT) \
478 * ELF_RTYPE_CLASS_PLT) \
479 | (((type) == R_PARISC_COPY) * ELF_RTYPE_CLASS_COPY))
480 #endif
482 /* Used by the runtime in fixup to figure out if reloc is *really* PLT */
483 #define ELF_MACHINE_JMP_SLOT R_PARISC_IPLT
484 #define ELF_MACHINE_SIZEOF_JMP_SLOT PLT_ENTRY_SIZE
486 /* We only use RELA. */
487 #define ELF_MACHINE_NO_REL 1
488 #define ELF_MACHINE_NO_RELA 0
490 /* Return the address of the entry point. */
491 #define ELF_MACHINE_START_ADDRESS(map, start) \
492 ({ \
493 ElfW(Addr) addr; \
494 DL_DT_FUNCTION_ADDRESS(map, start, static, addr) \
495 addr; \
498 /* We define an initialization functions. This is called very early in
499 * _dl_sysdep_start. */
500 #define DL_PLATFORM_INIT dl_platform_init ()
502 static inline void __attribute__ ((unused))
503 dl_platform_init (void)
505 if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
506 /* Avoid an empty string which would disturb us. */
507 GLRO(dl_platform) = NULL;
510 #endif /* !dl_machine_h */
512 /* These are only actually used where RESOLVE_MAP is defined, anyway. */
513 #ifdef RESOLVE_MAP
515 #define reassemble_21(as21) \
516 ( (((as21) & 0x100000) >> 20) \
517 | (((as21) & 0x0ffe00) >> 8) \
518 | (((as21) & 0x000180) << 7) \
519 | (((as21) & 0x00007c) << 14) \
520 | (((as21) & 0x000003) << 12))
522 #define reassemble_14(as14) \
523 ( (((as14) & 0x1fff) << 1) \
524 | (((as14) & 0x2000) >> 13))
526 auto void __attribute__((always_inline))
527 elf_machine_rela (struct link_map *map,
528 const Elf32_Rela *reloc,
529 const Elf32_Sym *sym,
530 const struct r_found_version *version,
531 void *const reloc_addr_arg,
532 int skip_ifunc)
534 Elf32_Addr *const reloc_addr = reloc_addr_arg;
535 const Elf32_Sym *const refsym = sym;
536 unsigned long const r_type = ELF32_R_TYPE (reloc->r_info);
537 struct link_map *sym_map;
538 Elf32_Addr value;
540 # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC && !defined SHARED
541 /* This is defined in rtld.c, but nowhere in the static libc.a; make the
542 reference weak so static programs can still link. This declaration
543 cannot be done when compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP)
544 because rtld.c contains the common defn for _dl_rtld_map, which is
545 incompatible with a weak decl in the same file. */
546 weak_extern (GL(dl_rtld_map));
547 # endif
549 /* RESOLVE_MAP will return a null value for undefined syms, and
550 non-null for all other syms. In particular, relocs with no
551 symbol (symbol index of zero), also called *ABS* relocs, will be
552 resolved to MAP. (The first entry in a symbol table is all
553 zeros, and an all zero Elf32_Sym has a binding of STB_LOCAL.)
554 See RESOLVE_MAP definition in elf/dl-reloc.c */
555 # ifdef RTLD_BOOTSTRAP
556 /* RESOLVE_MAP in rtld.c doesn't have the local sym test. */
557 sym_map = (ELF32_ST_BIND (sym->st_info) != STB_LOCAL
558 ? RESOLVE_MAP (&sym, version, r_type) : map);
559 # else
560 sym_map = RESOLVE_MAP (&sym, version, r_type);
561 # endif
563 if (sym_map)
565 value = sym ? sym_map->l_addr + sym->st_value : 0;
566 value += reloc->r_addend;
568 else
569 value = 0;
571 switch (r_type)
573 case R_PARISC_DIR32:
574 /* .eh_frame can have unaligned relocs. */
575 if ((unsigned long) reloc_addr_arg & 3)
577 char *rel_addr = (char *) reloc_addr_arg;
578 rel_addr[0] = value >> 24;
579 rel_addr[1] = value >> 16;
580 rel_addr[2] = value >> 8;
581 rel_addr[3] = value;
582 return;
584 break;
586 case R_PARISC_DIR21L:
588 unsigned int insn = *(unsigned int *)reloc_addr;
589 value = sym_map->l_addr + sym->st_value
590 + ((reloc->r_addend + 0x1000) & -0x2000);
591 value = value >> 11;
592 insn = (insn &~ 0x1fffff) | reassemble_21 (value);
593 *(unsigned int *)reloc_addr = insn;
595 return;
597 case R_PARISC_DIR14R:
599 unsigned int insn = *(unsigned int *)reloc_addr;
600 value = ((sym_map->l_addr + sym->st_value) & 0x7ff)
601 + (((reloc->r_addend & 0x1fff) ^ 0x1000) - 0x1000);
602 insn = (insn &~ 0x3fff) | reassemble_14 (value);
603 *(unsigned int *)reloc_addr = insn;
605 return;
607 case R_PARISC_PLABEL32:
608 /* Easy rule: If there is a symbol and it is global, then we
609 need to make a dynamic function descriptor. Otherwise we
610 have the address of a PLT slot for a local symbol which we
611 know to be unique. */
612 if (sym == NULL
613 || sym_map == NULL
614 || ELF32_ST_BIND (sym->st_info) == STB_LOCAL)
616 break;
618 /* Set bit 30 to indicate to $$dyncall that this is a PLABEL.
619 We have to do this outside of the generic function descriptor
620 code, since it doesn't know about our requirement for setting
621 protection bits */
622 value = (Elf32_Addr)((unsigned int)_dl_make_fptr (sym_map, sym, value) | 2);
623 break;
625 case R_PARISC_PLABEL21L:
626 case R_PARISC_PLABEL14R:
628 unsigned int insn = *(unsigned int *)reloc_addr;
630 if (__builtin_expect (sym == NULL, 0))
631 break;
633 value = (Elf32_Addr)((unsigned int)_dl_make_fptr (sym_map, sym, value) | 2);
635 if (r_type == R_PARISC_PLABEL21L)
637 value >>= 11;
638 insn = (insn &~ 0x1fffff) | reassemble_21 (value);
640 else
642 value &= 0x7ff;
643 insn = (insn &~ 0x3fff) | reassemble_14 (value);
646 *(unsigned int *)reloc_addr = insn;
648 return;
650 case R_PARISC_IPLT:
651 if (__builtin_expect (sym_map != NULL, 1))
653 elf_machine_fixup_plt (NULL, sym_map, NULL, NULL, reloc, reloc_addr,
654 DL_FIXUP_MAKE_VALUE(sym_map, value));
656 else
658 /* If we get here, it's a (weak) undefined sym. */
659 elf_machine_fixup_plt (NULL, map, NULL, NULL, reloc, reloc_addr,
660 DL_FIXUP_MAKE_VALUE(map, value));
662 return;
664 case R_PARISC_COPY:
665 if (__builtin_expect (sym == NULL, 0))
666 /* This can happen in trace mode if an object could not be
667 found. */
668 break;
669 if (__builtin_expect (sym->st_size > refsym->st_size, 0)
670 || (__builtin_expect (sym->st_size < refsym->st_size, 0)
671 && __builtin_expect (GLRO(dl_verbose), 0)))
673 const char *strtab;
675 strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
676 _dl_error_printf ("%s: Symbol `%s' has different size in shared object, "
677 "consider re-linking\n",
678 RTLD_PROGNAME, strtab + refsym->st_name);
680 memcpy (reloc_addr_arg, (void *) value,
681 MIN (sym->st_size, refsym->st_size));
682 return;
684 #if !defined RTLD_BOOTSTRAP
685 case R_PARISC_TLS_DTPMOD32:
686 value = sym_map->l_tls_modid;
687 break;
689 case R_PARISC_TLS_DTPOFF32:
690 /* During relocation all TLS symbols are defined and used.
691 Therefore the offset is already correct. */
692 if (sym != NULL)
693 *reloc_addr = sym->st_value;
694 return;
696 case R_PARISC_TLS_TPREL32:
697 /* The offset is negative, forward from the thread pointer */
698 if (sym != NULL)
700 CHECK_STATIC_TLS (map, sym_map);
701 value = sym_map->l_tls_offset + sym->st_value + reloc->r_addend;
703 break;
704 #endif /* use TLS */
706 case R_PARISC_NONE: /* Alright, Wilbur. */
707 return;
709 default:
710 _dl_reloc_bad_type (map, r_type, 0);
713 *reloc_addr = value;
716 /* hppa doesn't have an R_PARISC_RELATIVE reloc, but uses relocs with
717 ELF32_R_SYM (info) == 0 for a similar purpose. */
718 auto void __attribute__((always_inline))
719 elf_machine_rela_relative (Elf32_Addr l_addr,
720 const Elf32_Rela *reloc,
721 void *const reloc_addr_arg)
723 unsigned long const r_type = ELF32_R_TYPE (reloc->r_info);
724 Elf32_Addr *const reloc_addr = reloc_addr_arg;
725 static char msgbuf[] = { "Unknown" };
726 struct link_map map;
727 Elf32_Addr value;
729 value = l_addr + reloc->r_addend;
731 if (ELF32_R_SYM (reloc->r_info) != 0){
732 _dl_error_printf ("%s: In elf_machine_rela_relative "
733 "ELF32_R_SYM (reloc->r_info) != 0. Aborting.",
734 RTLD_PROGNAME);
735 ABORT_INSTRUCTION; /* Crash. */
738 switch (r_type)
740 case R_PARISC_DIR32:
741 /* .eh_frame can have unaligned relocs. */
742 if ((unsigned long) reloc_addr_arg & 3)
744 char *rel_addr = (char *) reloc_addr_arg;
745 rel_addr[0] = value >> 24;
746 rel_addr[1] = value >> 16;
747 rel_addr[2] = value >> 8;
748 rel_addr[3] = value;
749 return;
751 break;
753 case R_PARISC_PLABEL32:
754 break;
756 case R_PARISC_IPLT: /* elf_machine_runtime_setup already set gp */
757 break;
759 case R_PARISC_NONE:
760 return;
762 default: /* Bad reloc, map unknown (really it's the current map) */
763 map.l_name = msgbuf;
764 _dl_reloc_bad_type (&map, r_type, 0);
765 return;
768 *reloc_addr = value;
771 auto void __attribute__((always_inline))
772 elf_machine_lazy_rel (struct link_map *map,
773 Elf32_Addr l_addr, const Elf32_Rela *reloc,
774 int skip_ifunc)
776 /* We don't have anything to do here. elf_machine_runtime_setup has
777 done all the relocs already. */
780 #endif /* RESOLVE_MAP */