dl-sysdep.h 2.3 KB

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