OSDN Git Service

Moved the addition of load address from the fast path
[uclinux-h8/uClibc.git] / ldso / ldso / m68k / dl-sysdep.h
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Various assmbly 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] = (int) _dl_linux_resolve; \
15         GOT_BASE[1] = (int) (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 struct elf_resolve;
26 extern unsigned int _dl_linux_resolver (struct elf_resolve *, int);
27
28 /* Define this because we do not want to call .udiv in the library.
29    Not needed for m68k.  */
30 #define do_rem(result, n, base)  ((result) = (n) % (base))
31
32 /* 4096 bytes alignment */
33 #define PAGE_ALIGN 0xfffff000
34 #define ADDR_ALIGN 0xfff
35 #define OFFS_ALIGN 0x7ffff000
36
37 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
38    PLT entries should not be allowed to define the value.
39    ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
40    of the main executable's symbols, as for a COPY reloc.  */
41 #define elf_machine_type_class(type) \
42   ((((type) == R_68K_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)   \
43    | (((type) == R_68K_COPY) * ELF_RTYPE_CLASS_COPY))
44
45 /* Return the link-time address of _DYNAMIC.  Conveniently, this is the
46    first element of the GOT.  This must be inlined in a function which
47    uses global data.  */
48 static inline Elf32_Addr
49 elf_machine_dynamic (void)
50 {
51         register Elf32_Addr *got asm ("%a5");
52         return *got;
53 }
54
55
56 /* Return the run-time load address of the shared object.  */
57 static inline Elf32_Addr
58 elf_machine_load_address (void)
59 {
60         Elf32_Addr addr;
61         asm ("lea _dl_start(%%pc), %0\n\t"
62              "sub.l _dl_start@GOT.w(%%a5), %0"
63              : "=a" (addr));
64         return addr;
65 }
66
67 static inline void
68 elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
69                       Elf32_Word relative_count)
70 {
71          Elf32_Rela * rpnt = (void *)rel_addr;
72         --rpnt;
73         do {
74                 Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset);
75
76                 *reloc_addr = load_off + rpnt->r_addend;
77         } while (--relative_count);
78 }