coff-aux.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* BFD back-end for Apple M68K COFF A/UX 3.x files.
  2. Copyright (C) 1996-2015 Free Software Foundation, Inc.
  3. Written by Richard Henderson <rth@tamu.edu>.
  4. This file is part of BFD, the Binary File Descriptor library.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program 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
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. #define TARGET_SYM m68k_coff_aux_vec
  18. #define TARGET_NAME "coff-m68k-aux"
  19. #ifndef TARG_AUX
  20. #define TARG_AUX
  21. #endif
  22. #define COFF_LONG_FILENAMES
  23. /* 4k pages */
  24. #define COFF_PAGE_SIZE 0x1000
  25. /* On AUX, a STYP_NOLOAD|STYP_BSS section is part of a shared library. */
  26. #define BSS_NOLOAD_IS_SHARED_LIBRARY
  27. #define STATIC_RELOCS
  28. #define COFF_COMMON_ADDEND
  29. #include "sysdep.h"
  30. #include "bfd.h"
  31. #define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
  32. static bfd_boolean
  33. coff_m68k_aux_link_add_one_symbol
  34. (struct bfd_link_info *, bfd *, const char *, flagword, asection *,
  35. bfd_vma, const char *, bfd_boolean, bfd_boolean,
  36. struct bfd_link_hash_entry **);
  37. #ifndef bfd_pe_print_pdata
  38. #define bfd_pe_print_pdata NULL
  39. #endif
  40. #include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */
  41. #include "coff-m68k.c"
  42. /* We need non-absolute symbols to override absolute symbols. This
  43. mirrors Apple's "solution" to let a static library symbol override
  44. a shared library symbol. On the whole not a good thing, given how
  45. shared libraries work here, but can work if you are careful with
  46. what you include in the shared object. */
  47. static bfd_boolean
  48. coff_m68k_aux_link_add_one_symbol (struct bfd_link_info *info,
  49. bfd *abfd,
  50. const char *name,
  51. flagword flags,
  52. asection *section,
  53. bfd_vma value,
  54. const char *string,
  55. bfd_boolean copy,
  56. bfd_boolean collect,
  57. struct bfd_link_hash_entry **hashp)
  58. {
  59. struct bfd_link_hash_entry *h, *inh, *t;
  60. if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0
  61. && !bfd_is_und_section (section)
  62. && !bfd_is_com_section (section))
  63. {
  64. /* The new symbol is a definition or an indirect definition */
  65. /* This bit copied from linker.c */
  66. if (hashp != NULL && *hashp != NULL)
  67. h = *hashp;
  68. else
  69. {
  70. h = bfd_link_hash_lookup (info->hash, name, TRUE, copy, FALSE);
  71. if (h == NULL)
  72. {
  73. if (hashp != NULL)
  74. *hashp = NULL;
  75. return FALSE;
  76. }
  77. }
  78. if (hashp != (struct bfd_link_hash_entry **) NULL)
  79. *hashp = h;
  80. /* end duplication from linker.c */
  81. t = h;
  82. inh = NULL;
  83. if (h->type == bfd_link_hash_indirect)
  84. {
  85. inh = h->u.i.link;
  86. t = inh;
  87. }
  88. if (t->type == bfd_link_hash_defined)
  89. {
  90. asection *msec = t->u.def.section;
  91. bfd_boolean special = FALSE;
  92. if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section))
  93. {
  94. t->u.def.section = section;
  95. t->u.def.value = value;
  96. special = TRUE;
  97. }
  98. else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec))
  99. special = TRUE;
  100. if (special)
  101. {
  102. if (info->notice_all
  103. || (info->notice_hash != NULL
  104. && bfd_hash_lookup (info->notice_hash, name,
  105. FALSE, FALSE) != NULL))
  106. {
  107. if (!(*info->callbacks->notice) (info, h, inh,
  108. abfd, section, value, flags))
  109. return FALSE;
  110. }
  111. return TRUE;
  112. }
  113. }
  114. }
  115. /* If we didn't exit early, finish processing in the generic routine */
  116. return _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
  117. value, string, copy, collect,
  118. hashp);
  119. }