1 /* elf reloc code for the microblaze platform, based on glibc 2.3.6, dl-machine.h */
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 #define ELF_USES_RELOCA
24 /* Initialise the GOT */
25 #define INIT_GOT(GOT_BASE,MODULE) \
27 GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
28 GOT_BASE[1] = (unsigned long) MODULE; \
31 /* Here we define the magic numbers that this dynamic loader should accept */
33 #define MAGIC1 EM_MICROBLAZE_OLD
35 /* Used for error messages */
36 #define ELF_TARGET "microblaze"
38 #define elf_machine_type_class(type) \
39 (((type) == R_MICROBLAZE_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT \
40 | ((type) == R_MICROBLAZE_COPY) * ELF_RTYPE_CLASS_COPY)
42 /* Return the link-time address of _DYNAMIC. Conveniently, this is the
43 first element of the GOT. This must be inlined in a function which
45 static inline Elf32_Addr
46 elf_machine_dynamic (void)
48 Elf32_Addr got_entry_0;
57 /* Return the run-time load address of the shared object. */
58 static inline Elf32_Addr
59 elf_machine_load_address (void)
61 /* Compute the difference between the runtime address of _DYNAMIC as seen
62 by a GOTOFF reference, and the link-time address found in the special
63 unrelocated first GOT entry. */
65 __asm__ __volatile__ (
66 "addik %0,r20,_DYNAMIC@GOTOFF"
69 return dyn - elf_machine_dynamic ();
74 static __always_inline void
75 elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
76 Elf32_Word relative_count)
78 Elf32_Rel * rpnt = (void *) rel_addr;
80 Elf32_Addr *const reloc_addr = (void *) (load_off + (rpnt)->r_offset);
82 *reloc_addr += load_off;
83 } while (--relative_count);