dl-sysdep.h 2.5 KB

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