coff-apollo.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* BFD back-end for Apollo 68000 COFF binaries.
  2. Copyright (C) 1990-2015 Free Software Foundation, Inc.
  3. By Troy Rollo (troy@cbme.unsw.edu.au)
  4. Based on m68k standard COFF version Written by Cygnus Support.
  5. This file is part of BFD, the Binary File Descriptor library.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17. MA 02110-1301, USA. */
  18. #include "sysdep.h"
  19. #include "bfd.h"
  20. #include "libbfd.h"
  21. #include "coff/apollo.h"
  22. #include "coff/internal.h"
  23. #include "libcoff.h"
  24. #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
  25. #ifdef ONLY_DECLARE_RELOCS
  26. extern reloc_howto_type apollocoff_howto_table[];
  27. #else
  28. reloc_howto_type apollocoff_howto_table[] =
  29. {
  30. HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "8", TRUE, 0x000000ff,0x000000ff, FALSE),
  31. HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
  32. HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "32", TRUE, 0xffffffff,0xffffffff, FALSE),
  33. HOWTO (R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, "DISP8", TRUE, 0x000000ff,0x000000ff, FALSE),
  34. HOWTO (R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "DISP16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
  35. HOWTO (R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "DISP32", TRUE, 0xffffffff,0xffffffff, FALSE),
  36. HOWTO (R_RELLONG_NEG, 0, -2, 32, FALSE, 0, complain_overflow_bitfield, 0, "-32", TRUE, 0xffffffff,0xffffffff, FALSE),
  37. };
  38. #endif /* not ONLY_DECLARE_RELOCS */
  39. #ifndef BADMAG
  40. #define BADMAG(x) M68KBADMAG(x)
  41. #endif
  42. #define APOLLO_M68 1 /* Customize coffcode.h */
  43. /* Turn a howto into a reloc number. */
  44. extern void apollo_rtype2howto (arelent *, int);
  45. extern int apollo_howto2rtype (reloc_howto_type *);
  46. #ifndef ONLY_DECLARE_RELOCS
  47. void
  48. apollo_rtype2howto (arelent *internal, int relocentry)
  49. {
  50. switch (relocentry)
  51. {
  52. case R_RELBYTE: internal->howto = apollocoff_howto_table + 0; break;
  53. case R_RELWORD: internal->howto = apollocoff_howto_table + 1; break;
  54. case R_RELLONG: internal->howto = apollocoff_howto_table + 2; break;
  55. case R_PCRBYTE: internal->howto = apollocoff_howto_table + 3; break;
  56. case R_PCRWORD: internal->howto = apollocoff_howto_table + 4; break;
  57. case R_PCRLONG: internal->howto = apollocoff_howto_table + 5; break;
  58. case R_RELLONG_NEG: internal->howto = apollocoff_howto_table + 6; break;
  59. }
  60. }
  61. int
  62. apollo_howto2rtype (reloc_howto_type *internal)
  63. {
  64. if (internal->pc_relative)
  65. {
  66. switch (internal->bitsize)
  67. {
  68. case 32: return R_PCRLONG;
  69. case 16: return R_PCRWORD;
  70. case 8: return R_PCRBYTE;
  71. }
  72. }
  73. else
  74. {
  75. switch (internal->bitsize)
  76. {
  77. case 32: return R_RELLONG;
  78. case 16: return R_RELWORD;
  79. case 8: return R_RELBYTE;
  80. }
  81. }
  82. return R_RELLONG;
  83. }
  84. #endif /* not ONLY_DECLARE_RELOCS */
  85. #define RTYPE2HOWTO(internal, relocentry) \
  86. apollo_rtype2howto (internal, (relocentry)->r_type)
  87. #define SELECT_RELOC(external, internal) \
  88. external.r_type = apollo_howto2rtype (internal);
  89. #define bfd_pe_print_pdata NULL
  90. #include "coffcode.h"
  91. #ifndef TARGET_SYM
  92. #define TARGET_SYM m68k_coff_apollo_vec
  93. #endif
  94. #ifndef TARGET_NAME
  95. #define TARGET_NAME "apollo-m68k"
  96. #endif
  97. #ifdef NAMES_HAVE_UNDERSCORE
  98. CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, '_', NULL, COFF_SWAP_TABLE)
  99. #else
  100. CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, 0, NULL, COFF_SWAP_TABLE)
  101. #endif