]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/ldso/ldso/m68k/dl-sysdep.h
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / ldso / ldso / m68k / dl-sysdep.h
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Various assembly language/system dependent hacks that are required
4  * so that we can minimize the amount of platform specific code.
5  * Copyright (C) 2005 by Erik Andersen <andersen@codepoet.org>
6  */
7
8 /* Define this if the system uses RELOCA.  */
9 #define ELF_USES_RELOCA
10 #include <elf.h>
11 /* Initialization sequence for a GOT.  */
12 #define INIT_GOT(GOT_BASE,MODULE) \
13 do { \
14         GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
15         GOT_BASE[1] = (unsigned long) (MODULE); \
16 } while(0)
17
18 /* Here we define the magic numbers that this dynamic loader should accept */
19 #define MAGIC1 EM_68K
20 #undef  MAGIC2
21
22 /* Used for error messages */
23 #define ELF_TARGET "m68k"
24
25 /* Need bootstrap relocations */
26 #define ARCH_NEEDS_BOOTSTRAP_RELOCS
27
28 struct elf_resolve;
29 extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
30
31 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
32    PLT entries should not be allowed to define the value.
33    ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
34    of the main executable's symbols, as for a COPY reloc.  */
35 #define elf_machine_type_class(type) \
36   ((((type) == R_68K_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)   \
37    | (((type) == R_68K_COPY) * ELF_RTYPE_CLASS_COPY))
38
39 /* Return the link-time address of _DYNAMIC.  Conveniently, this is the
40    first element of the GOT.  This must be inlined in a function which
41    uses global data.  */
42 static __always_inline Elf32_Addr
43 elf_machine_dynamic (void)
44 {
45         Elf32_Addr got;
46
47         __asm__ ("move.l _DYNAMIC@GOT.w(%%a5), %0"
48                         : "=a" (got));
49         return got;
50 }
51
52 #ifdef __mcoldfire__
53 #define PCREL_OP(OP, SRC, DST, TMP, PC) \
54   "move.l #" SRC " - ., " TMP "\n\t" OP " (-8, " PC ", " TMP "), " DST
55 #else
56 #define PCREL_OP(OP, SRC, DST, TMP, PC) \
57   OP " " SRC "(" PC "), " DST
58 #endif
59
60 /* Return the run-time load address of the shared object.  */
61 static __always_inline Elf32_Addr
62 elf_machine_load_address (void)
63 {
64         Elf32_Addr addr;
65         __asm__ (PCREL_OP ("lea", "_dl_start", "%0", "%0", "%%pc") "\n\t"
66                         "sub.l _dl_start@GOT.w(%%a5), %0"
67                         : "=a" (addr));
68         return addr;
69 }
70
71 static __always_inline void
72 elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
73                       Elf32_Word relative_count)
74 {
75          Elf32_Rela * rpnt = (void *)rel_addr;
76         --rpnt;
77         do {
78                 Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset);
79
80                 *reloc_addr = load_off + rpnt->r_addend;
81         } while (--relative_count);
82 }