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