dl-sysdep.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Various assmbly language/system dependent hacks that are required
  2. so that we can minimize the amount of platform specific code. */
  3. /* Define this if the system uses RELOCA. */
  4. #define ELF_USES_RELOCA
  5. #include <elf.h>
  6. /* Initialization sequence for a GOT. */
  7. #define INIT_GOT(GOT_BASE,MODULE) \
  8. { \
  9. GOT_BASE[2] = (int) _dl_linux_resolve; \
  10. GOT_BASE[1] = (int) (MODULE); \
  11. }
  12. /* Here we define the magic numbers that this dynamic loader should accept */
  13. #define MAGIC1 EM_68K
  14. #undef MAGIC2
  15. /* Used for error messages */
  16. #define ELF_TARGET "m68k"
  17. struct elf_resolve;
  18. extern unsigned int _dl_linux_resolver (int, int, struct elf_resolve *, int);
  19. /* Define this because we do not want to call .udiv in the library.
  20. Not needed for m68k. */
  21. #define do_rem(result, n, base) ((result) = (n) % (base))
  22. /* 4096 bytes alignment */
  23. #define PAGE_ALIGN 0xfffff000
  24. #define ADDR_ALIGN 0xfff
  25. #define OFFS_ALIGN 0x7ffff000
  26. /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
  27. PLT entries should not be allowed to define the value.
  28. ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
  29. of the main executable's symbols, as for a COPY reloc. */
  30. #define elf_machine_type_class(type) \
  31. ((((type) == R_68K_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
  32. | (((type) == R_68K_COPY) * ELF_RTYPE_CLASS_COPY))
  33. /* Return the link-time address of _DYNAMIC. Conveniently, this is the
  34. first element of the GOT. This must be inlined in a function which
  35. uses global data. */
  36. static inline Elf32_Addr
  37. elf_machine_dynamic (void)
  38. {
  39. register Elf32_Addr *got asm ("%a5");
  40. return *got;
  41. }
  42. /* Return the run-time load address of the shared object. */
  43. static inline Elf32_Addr
  44. elf_machine_load_address (void)
  45. {
  46. Elf32_Addr addr;
  47. asm ("lea _dl_boot(%%pc), %0\n\t"
  48. "sub.l _dl_boot@GOT.w(%%a5), %0"
  49. : "=a" (addr));
  50. return addr;
  51. }
  52. static inline void
  53. elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
  54. Elf32_Word relative_count)
  55. {
  56. Elf32_Rela * rpnt = (void *) (rel_addr + load_off);
  57. --rpnt;
  58. do {
  59. Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset);
  60. *reloc_addr = load_off + rpnt->r_addend;
  61. } while (--relative_count);
  62. }