xref: /openbsd-src/gnu/usr.bin/binutils-2.17/bfd/sparclinux.c (revision 3d8817e467ea46cf4772788d6804dd293abfb01a)
1*3d8817e4Smiod /* BFD back-end for linux flavored sparc a.out binaries.
2*3d8817e4Smiod    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
3*3d8817e4Smiod    2003, 2004, 2006 Free Software Foundation, Inc.
4*3d8817e4Smiod 
5*3d8817e4Smiod This file is part of BFD, the Binary File Descriptor library.
6*3d8817e4Smiod 
7*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
8*3d8817e4Smiod it under the terms of the GNU General Public License as published by
9*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or
10*3d8817e4Smiod (at your option) any later version.
11*3d8817e4Smiod 
12*3d8817e4Smiod This program is distributed in the hope that it will be useful,
13*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
14*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*3d8817e4Smiod GNU General Public License for more details.
16*3d8817e4Smiod 
17*3d8817e4Smiod You should have received a copy of the GNU General Public License
18*3d8817e4Smiod along with this program; if not, write to the Free Software
19*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
20*3d8817e4Smiod USA.  */
21*3d8817e4Smiod 
22*3d8817e4Smiod #define TARGET_PAGE_SIZE	4096
23*3d8817e4Smiod #define ZMAGIC_DISK_BLOCK_SIZE	1024
24*3d8817e4Smiod #define SEGMENT_SIZE		TARGET_PAGE_SIZE
25*3d8817e4Smiod #define TEXT_START_ADDR		0x0
26*3d8817e4Smiod #define N_SHARED_LIB(x)		0
27*3d8817e4Smiod 
28*3d8817e4Smiod #define MACHTYPE_OK(mtype) ((mtype) == M_SPARC || (mtype) == M_UNKNOWN)
29*3d8817e4Smiod 
30*3d8817e4Smiod #include "bfd.h"
31*3d8817e4Smiod #include "sysdep.h"
32*3d8817e4Smiod #include "libbfd.h"
33*3d8817e4Smiod #include "aout/aout64.h"
34*3d8817e4Smiod #include "aout/stab_gnu.h"
35*3d8817e4Smiod #include "aout/ar.h"
36*3d8817e4Smiod #include "libaout.h"           /* BFD a.out internal data structures */
37*3d8817e4Smiod 
38*3d8817e4Smiod #define DEFAULT_ARCH bfd_arch_sparc
39*3d8817e4Smiod /* Do not "beautify" the CONCAT* macro args.  Traditional C will not
40*3d8817e4Smiod    remove whitespace added here, and thus will fail to concatenate
41*3d8817e4Smiod    the tokens.  */
42*3d8817e4Smiod #define MY(OP) CONCAT2 (sparclinux_,OP)
43*3d8817e4Smiod #define TARGETNAME "a.out-sparc-linux"
44*3d8817e4Smiod 
45*3d8817e4Smiod extern const bfd_target MY(vec);
46*3d8817e4Smiod 
47*3d8817e4Smiod /* We always generate QMAGIC files in preference to ZMAGIC files.  It
48*3d8817e4Smiod    would be possible to make this a linker option, if that ever
49*3d8817e4Smiod    becomes important.  */
50*3d8817e4Smiod 
51*3d8817e4Smiod static void MY_final_link_callback
52*3d8817e4Smiod   PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
53*3d8817e4Smiod 
54*3d8817e4Smiod static bfd_boolean sparclinux_bfd_final_link
55*3d8817e4Smiod   PARAMS ((bfd *abfd, struct bfd_link_info *info));
56*3d8817e4Smiod 
57*3d8817e4Smiod static bfd_boolean
sparclinux_bfd_final_link(abfd,info)58*3d8817e4Smiod sparclinux_bfd_final_link (abfd, info)
59*3d8817e4Smiod      bfd *abfd;
60*3d8817e4Smiod      struct bfd_link_info *info;
61*3d8817e4Smiod {
62*3d8817e4Smiod   obj_aout_subformat (abfd) = q_magic_format;
63*3d8817e4Smiod   return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
64*3d8817e4Smiod }
65*3d8817e4Smiod 
66*3d8817e4Smiod #define MY_bfd_final_link sparclinux_bfd_final_link
67*3d8817e4Smiod 
68*3d8817e4Smiod /* Set the machine type correctly.  */
69*3d8817e4Smiod 
70*3d8817e4Smiod static bfd_boolean sparclinux_write_object_contents PARAMS ((bfd *abfd));
71*3d8817e4Smiod 
72*3d8817e4Smiod static bfd_boolean
sparclinux_write_object_contents(abfd)73*3d8817e4Smiod sparclinux_write_object_contents (abfd)
74*3d8817e4Smiod      bfd *abfd;
75*3d8817e4Smiod {
76*3d8817e4Smiod   struct external_exec exec_bytes;
77*3d8817e4Smiod   struct internal_exec *execp = exec_hdr (abfd);
78*3d8817e4Smiod 
79*3d8817e4Smiod   N_SET_MACHTYPE (*execp, M_SPARC);
80*3d8817e4Smiod 
81*3d8817e4Smiod   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
82*3d8817e4Smiod 
83*3d8817e4Smiod   WRITE_HEADERS(abfd, execp);
84*3d8817e4Smiod 
85*3d8817e4Smiod   return TRUE;
86*3d8817e4Smiod }
87*3d8817e4Smiod 
88*3d8817e4Smiod #define MY_write_object_contents sparclinux_write_object_contents
89*3d8817e4Smiod /* Code to link against Linux a.out shared libraries.  */
90*3d8817e4Smiod 
91*3d8817e4Smiod /* See if a symbol name is a reference to the global offset table.  */
92*3d8817e4Smiod 
93*3d8817e4Smiod #ifndef GOT_REF_PREFIX
94*3d8817e4Smiod #define GOT_REF_PREFIX  "__GOT_"
95*3d8817e4Smiod #endif
96*3d8817e4Smiod 
97*3d8817e4Smiod #define IS_GOT_SYM(name) \
98*3d8817e4Smiod   (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0)
99*3d8817e4Smiod 
100*3d8817e4Smiod /* See if a symbol name is a reference to the procedure linkage table.  */
101*3d8817e4Smiod 
102*3d8817e4Smiod #ifndef PLT_REF_PREFIX
103*3d8817e4Smiod #define PLT_REF_PREFIX  "__PLT_"
104*3d8817e4Smiod #endif
105*3d8817e4Smiod 
106*3d8817e4Smiod #define IS_PLT_SYM(name) \
107*3d8817e4Smiod   (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0)
108*3d8817e4Smiod 
109*3d8817e4Smiod /* This string is used to generate specialized error messages.  */
110*3d8817e4Smiod 
111*3d8817e4Smiod #ifndef NEEDS_SHRLIB
112*3d8817e4Smiod #define NEEDS_SHRLIB "__NEEDS_SHRLIB_"
113*3d8817e4Smiod #endif
114*3d8817e4Smiod 
115*3d8817e4Smiod /* This special symbol is a set vector that contains a list of
116*3d8817e4Smiod    pointers to fixup tables.  It will be present in any dynamically
117*3d8817e4Smiod    linked file.  The linker generated fixup table should also be added
118*3d8817e4Smiod    to the list, and it should always appear in the second slot (the
119*3d8817e4Smiod    first one is a dummy with a magic number that is defined in
120*3d8817e4Smiod    crt0.o).  */
121*3d8817e4Smiod 
122*3d8817e4Smiod #ifndef SHARABLE_CONFLICTS
123*3d8817e4Smiod #define SHARABLE_CONFLICTS "__SHARABLE_CONFLICTS__"
124*3d8817e4Smiod #endif
125*3d8817e4Smiod 
126*3d8817e4Smiod /* We keep a list of fixups.  The terminology is a bit strange, but
127*3d8817e4Smiod    each fixup contains two 32 bit numbers.  A regular fixup contains
128*3d8817e4Smiod    an address and a pointer, and at runtime we should store the
129*3d8817e4Smiod    address at the location pointed to by the pointer.  A builtin fixup
130*3d8817e4Smiod    contains two pointers, and we should read the address using one
131*3d8817e4Smiod    pointer and store it at the location pointed to by the other
132*3d8817e4Smiod    pointer.  Builtin fixups come into play when we have duplicate
133*3d8817e4Smiod    __GOT__ symbols for the same variable.  The builtin fixup will copy
134*3d8817e4Smiod    the GOT pointer from one over into the other.  */
135*3d8817e4Smiod 
136*3d8817e4Smiod struct fixup
137*3d8817e4Smiod {
138*3d8817e4Smiod   struct fixup *next;
139*3d8817e4Smiod   struct linux_link_hash_entry *h;
140*3d8817e4Smiod   bfd_vma value;
141*3d8817e4Smiod 
142*3d8817e4Smiod   /* Nonzero if this is a jump instruction that needs to be fixed,
143*3d8817e4Smiod      zero if this is just a pointer */
144*3d8817e4Smiod   char jump;
145*3d8817e4Smiod 
146*3d8817e4Smiod   char builtin;
147*3d8817e4Smiod };
148*3d8817e4Smiod 
149*3d8817e4Smiod /* We don't need a special hash table entry structure, but we do need
150*3d8817e4Smiod    to keep some information between linker passes, so we use a special
151*3d8817e4Smiod    hash table.  */
152*3d8817e4Smiod 
153*3d8817e4Smiod struct linux_link_hash_entry
154*3d8817e4Smiod {
155*3d8817e4Smiod   struct aout_link_hash_entry root;
156*3d8817e4Smiod };
157*3d8817e4Smiod 
158*3d8817e4Smiod struct linux_link_hash_table
159*3d8817e4Smiod {
160*3d8817e4Smiod   struct aout_link_hash_table root;
161*3d8817e4Smiod 
162*3d8817e4Smiod   /* First dynamic object found in link.  */
163*3d8817e4Smiod   bfd *dynobj;
164*3d8817e4Smiod 
165*3d8817e4Smiod   /* Number of fixups.  */
166*3d8817e4Smiod   size_t fixup_count;
167*3d8817e4Smiod 
168*3d8817e4Smiod   /* Number of builtin fixups.  */
169*3d8817e4Smiod   size_t local_builtins;
170*3d8817e4Smiod 
171*3d8817e4Smiod   /* List of fixups.  */
172*3d8817e4Smiod   struct fixup *fixup_list;
173*3d8817e4Smiod };
174*3d8817e4Smiod 
175*3d8817e4Smiod static struct bfd_hash_entry *linux_link_hash_newfunc
176*3d8817e4Smiod   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
177*3d8817e4Smiod static struct bfd_link_hash_table *linux_link_hash_table_create
178*3d8817e4Smiod   PARAMS ((bfd *));
179*3d8817e4Smiod static struct fixup *new_fixup
180*3d8817e4Smiod   PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
181*3d8817e4Smiod 	  bfd_vma, int));
182*3d8817e4Smiod static bfd_boolean linux_link_create_dynamic_sections
183*3d8817e4Smiod   PARAMS ((bfd *, struct bfd_link_info *));
184*3d8817e4Smiod static bfd_boolean linux_add_one_symbol
185*3d8817e4Smiod   PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
186*3d8817e4Smiod 	  bfd_vma, const char *, bfd_boolean, bfd_boolean,
187*3d8817e4Smiod 	  struct bfd_link_hash_entry **));
188*3d8817e4Smiod static bfd_boolean linux_tally_symbols
189*3d8817e4Smiod   PARAMS ((struct linux_link_hash_entry *, PTR));
190*3d8817e4Smiod static bfd_boolean linux_finish_dynamic_link
191*3d8817e4Smiod   PARAMS ((bfd *, struct bfd_link_info *));
192*3d8817e4Smiod 
193*3d8817e4Smiod /* Routine to create an entry in an Linux link hash table.  */
194*3d8817e4Smiod 
195*3d8817e4Smiod static struct bfd_hash_entry *
linux_link_hash_newfunc(entry,table,string)196*3d8817e4Smiod linux_link_hash_newfunc (entry, table, string)
197*3d8817e4Smiod      struct bfd_hash_entry *entry;
198*3d8817e4Smiod      struct bfd_hash_table *table;
199*3d8817e4Smiod      const char *string;
200*3d8817e4Smiod {
201*3d8817e4Smiod   struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
202*3d8817e4Smiod 
203*3d8817e4Smiod   /* Allocate the structure if it has not already been allocated by a
204*3d8817e4Smiod      subclass.  */
205*3d8817e4Smiod   if (ret == (struct linux_link_hash_entry *) NULL)
206*3d8817e4Smiod     ret = ((struct linux_link_hash_entry *)
207*3d8817e4Smiod 	   bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
208*3d8817e4Smiod   if (ret == NULL)
209*3d8817e4Smiod     return (struct bfd_hash_entry *) ret;
210*3d8817e4Smiod 
211*3d8817e4Smiod   /* Call the allocation method of the superclass.  */
212*3d8817e4Smiod   ret = ((struct linux_link_hash_entry *)
213*3d8817e4Smiod 	 NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
214*3d8817e4Smiod 				       table, string));
215*3d8817e4Smiod   if (ret != NULL)
216*3d8817e4Smiod     {
217*3d8817e4Smiod       /* Set local fields; there aren't any.  */
218*3d8817e4Smiod     }
219*3d8817e4Smiod 
220*3d8817e4Smiod   return (struct bfd_hash_entry *) ret;
221*3d8817e4Smiod }
222*3d8817e4Smiod 
223*3d8817e4Smiod /* Create a Linux link hash table.  */
224*3d8817e4Smiod 
225*3d8817e4Smiod static struct bfd_link_hash_table *
linux_link_hash_table_create(abfd)226*3d8817e4Smiod linux_link_hash_table_create (abfd)
227*3d8817e4Smiod      bfd *abfd;
228*3d8817e4Smiod {
229*3d8817e4Smiod   struct linux_link_hash_table *ret;
230*3d8817e4Smiod   bfd_size_type amt = sizeof (struct linux_link_hash_table);
231*3d8817e4Smiod 
232*3d8817e4Smiod   ret = (struct linux_link_hash_table *) bfd_malloc (amt);
233*3d8817e4Smiod   if (ret == (struct linux_link_hash_table *) NULL)
234*3d8817e4Smiod     return (struct bfd_link_hash_table *) NULL;
235*3d8817e4Smiod   if (!NAME(aout,link_hash_table_init) (&ret->root, abfd,
236*3d8817e4Smiod 					linux_link_hash_newfunc,
237*3d8817e4Smiod 					sizeof (struct linux_link_hash_entry)))
238*3d8817e4Smiod     {
239*3d8817e4Smiod       free (ret);
240*3d8817e4Smiod       return (struct bfd_link_hash_table *) NULL;
241*3d8817e4Smiod     }
242*3d8817e4Smiod 
243*3d8817e4Smiod   ret->dynobj = NULL;
244*3d8817e4Smiod   ret->fixup_count = 0;
245*3d8817e4Smiod   ret->local_builtins = 0;
246*3d8817e4Smiod   ret->fixup_list = NULL;
247*3d8817e4Smiod 
248*3d8817e4Smiod   return &ret->root.root;
249*3d8817e4Smiod }
250*3d8817e4Smiod 
251*3d8817e4Smiod /* Look up an entry in a Linux link hash table.  */
252*3d8817e4Smiod 
253*3d8817e4Smiod #define linux_link_hash_lookup(table, string, create, copy, follow) \
254*3d8817e4Smiod   ((struct linux_link_hash_entry *) \
255*3d8817e4Smiod    aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
256*3d8817e4Smiod 			  (follow)))
257*3d8817e4Smiod 
258*3d8817e4Smiod /* Traverse a Linux link hash table.  */
259*3d8817e4Smiod 
260*3d8817e4Smiod #define linux_link_hash_traverse(table, func, info)		       \
261*3d8817e4Smiod   (aout_link_hash_traverse					       \
262*3d8817e4Smiod    (&(table)->root,						       \
263*3d8817e4Smiod     (bfd_boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
264*3d8817e4Smiod     (info)))
265*3d8817e4Smiod 
266*3d8817e4Smiod /* Get the Linux link hash table from the info structure.  This is
267*3d8817e4Smiod    just a cast.  */
268*3d8817e4Smiod 
269*3d8817e4Smiod #define linux_hash_table(p) ((struct linux_link_hash_table *) ((p)->hash))
270*3d8817e4Smiod 
271*3d8817e4Smiod /* Store the information for a new fixup.  */
272*3d8817e4Smiod 
273*3d8817e4Smiod static struct fixup *
new_fixup(info,h,value,builtin)274*3d8817e4Smiod new_fixup (info, h, value, builtin)
275*3d8817e4Smiod      struct bfd_link_info *info;
276*3d8817e4Smiod      struct linux_link_hash_entry *h;
277*3d8817e4Smiod      bfd_vma value;
278*3d8817e4Smiod      int builtin;
279*3d8817e4Smiod {
280*3d8817e4Smiod   struct fixup *f;
281*3d8817e4Smiod 
282*3d8817e4Smiod   f = (struct fixup *) bfd_hash_allocate (&info->hash->table,
283*3d8817e4Smiod 					  sizeof (struct fixup));
284*3d8817e4Smiod   if (f == NULL)
285*3d8817e4Smiod     return f;
286*3d8817e4Smiod   f->next = linux_hash_table (info)->fixup_list;
287*3d8817e4Smiod   linux_hash_table (info)->fixup_list = f;
288*3d8817e4Smiod   f->h = h;
289*3d8817e4Smiod   f->value = value;
290*3d8817e4Smiod   f->builtin = builtin;
291*3d8817e4Smiod   f->jump = 0;
292*3d8817e4Smiod   ++linux_hash_table (info)->fixup_count;
293*3d8817e4Smiod   return f;
294*3d8817e4Smiod }
295*3d8817e4Smiod 
296*3d8817e4Smiod /* We come here once we realize that we are going to link to a shared
297*3d8817e4Smiod    library.  We need to create a special section that contains the
298*3d8817e4Smiod    fixup table, and we ultimately need to add a pointer to this into
299*3d8817e4Smiod    the set vector for SHARABLE_CONFLICTS.  At this point we do not
300*3d8817e4Smiod    know the size of the section, but that's OK - we just need to
301*3d8817e4Smiod    create it for now.  */
302*3d8817e4Smiod 
303*3d8817e4Smiod static bfd_boolean
linux_link_create_dynamic_sections(abfd,info)304*3d8817e4Smiod linux_link_create_dynamic_sections (abfd, info)
305*3d8817e4Smiod      bfd *abfd;
306*3d8817e4Smiod      struct bfd_link_info *info ATTRIBUTE_UNUSED;
307*3d8817e4Smiod {
308*3d8817e4Smiod   flagword flags;
309*3d8817e4Smiod   register asection *s;
310*3d8817e4Smiod 
311*3d8817e4Smiod   /* Note that we set the SEC_IN_MEMORY flag.  */
312*3d8817e4Smiod   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
313*3d8817e4Smiod 
314*3d8817e4Smiod   /* We choose to use the name ".linux-dynamic" for the fixup table.
315*3d8817e4Smiod      Why not?  */
316*3d8817e4Smiod   s = bfd_make_section (abfd, ".linux-dynamic");
317*3d8817e4Smiod   if (s == NULL
318*3d8817e4Smiod       || ! bfd_set_section_flags (abfd, s, flags)
319*3d8817e4Smiod       || ! bfd_set_section_alignment (abfd, s, 2))
320*3d8817e4Smiod     return FALSE;
321*3d8817e4Smiod   s->size = 0;
322*3d8817e4Smiod   s->contents = 0;
323*3d8817e4Smiod 
324*3d8817e4Smiod   return TRUE;
325*3d8817e4Smiod }
326*3d8817e4Smiod 
327*3d8817e4Smiod /* Function to add a single symbol to the linker hash table.  This is
328*3d8817e4Smiod    a wrapper around _bfd_generic_link_add_one_symbol which handles the
329*3d8817e4Smiod    tweaking needed for dynamic linking support.  */
330*3d8817e4Smiod 
331*3d8817e4Smiod static bfd_boolean
linux_add_one_symbol(info,abfd,name,flags,section,value,string,copy,collect,hashp)332*3d8817e4Smiod linux_add_one_symbol (info, abfd, name, flags, section, value, string,
333*3d8817e4Smiod 		      copy, collect, hashp)
334*3d8817e4Smiod      struct bfd_link_info *info;
335*3d8817e4Smiod      bfd *abfd;
336*3d8817e4Smiod      const char *name;
337*3d8817e4Smiod      flagword flags;
338*3d8817e4Smiod      asection *section;
339*3d8817e4Smiod      bfd_vma value;
340*3d8817e4Smiod      const char *string;
341*3d8817e4Smiod      bfd_boolean copy;
342*3d8817e4Smiod      bfd_boolean collect;
343*3d8817e4Smiod      struct bfd_link_hash_entry **hashp;
344*3d8817e4Smiod {
345*3d8817e4Smiod   struct linux_link_hash_entry *h;
346*3d8817e4Smiod   bfd_boolean insert;
347*3d8817e4Smiod 
348*3d8817e4Smiod   /* Look up and see if we already have this symbol in the hash table.
349*3d8817e4Smiod      If we do, and the defining entry is from a shared library, we
350*3d8817e4Smiod      need to create the dynamic sections.
351*3d8817e4Smiod 
352*3d8817e4Smiod      FIXME: What if abfd->xvec != info->hash->creator?  We may want to
353*3d8817e4Smiod      be able to link Linux a.out and ELF objects together, but serious
354*3d8817e4Smiod      confusion is possible.  */
355*3d8817e4Smiod 
356*3d8817e4Smiod   insert = FALSE;
357*3d8817e4Smiod 
358*3d8817e4Smiod   if (! info->relocatable
359*3d8817e4Smiod       && linux_hash_table (info)->dynobj == NULL
360*3d8817e4Smiod       && strcmp (name, SHARABLE_CONFLICTS) == 0
361*3d8817e4Smiod       && (flags & BSF_CONSTRUCTOR) != 0
362*3d8817e4Smiod       && abfd->xvec == info->hash->creator)
363*3d8817e4Smiod     {
364*3d8817e4Smiod       if (! linux_link_create_dynamic_sections (abfd, info))
365*3d8817e4Smiod 	return FALSE;
366*3d8817e4Smiod       linux_hash_table (info)->dynobj = abfd;
367*3d8817e4Smiod       insert = TRUE;
368*3d8817e4Smiod     }
369*3d8817e4Smiod 
370*3d8817e4Smiod   if (bfd_is_abs_section (section)
371*3d8817e4Smiod       && abfd->xvec == info->hash->creator)
372*3d8817e4Smiod     {
373*3d8817e4Smiod       h = linux_link_hash_lookup (linux_hash_table (info), name, FALSE,
374*3d8817e4Smiod 				  FALSE, FALSE);
375*3d8817e4Smiod       if (h != NULL
376*3d8817e4Smiod 	  && (h->root.root.type == bfd_link_hash_defined
377*3d8817e4Smiod 	      || h->root.root.type == bfd_link_hash_defweak))
378*3d8817e4Smiod 	{
379*3d8817e4Smiod 	  struct fixup *f;
380*3d8817e4Smiod 
381*3d8817e4Smiod 	  if (hashp != NULL)
382*3d8817e4Smiod 	    *hashp = (struct bfd_link_hash_entry *) h;
383*3d8817e4Smiod 
384*3d8817e4Smiod 	  f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
385*3d8817e4Smiod 	  if (f == NULL)
386*3d8817e4Smiod 	    return FALSE;
387*3d8817e4Smiod 	  f->jump = IS_PLT_SYM (name);
388*3d8817e4Smiod 
389*3d8817e4Smiod 	  return TRUE;
390*3d8817e4Smiod 	}
391*3d8817e4Smiod     }
392*3d8817e4Smiod 
393*3d8817e4Smiod   /* Do the usual procedure for adding a symbol.  */
394*3d8817e4Smiod   if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
395*3d8817e4Smiod 					  value, string, copy, collect,
396*3d8817e4Smiod 					  hashp))
397*3d8817e4Smiod     return FALSE;
398*3d8817e4Smiod 
399*3d8817e4Smiod   /* Insert a pointer to our table in the set vector.  The dynamic
400*3d8817e4Smiod      linker requires this information.  */
401*3d8817e4Smiod   if (insert)
402*3d8817e4Smiod     {
403*3d8817e4Smiod       asection *s;
404*3d8817e4Smiod 
405*3d8817e4Smiod       /* Here we do our special thing to add the pointer to the
406*3d8817e4Smiod 	 dynamic section in the SHARABLE_CONFLICTS set vector.  */
407*3d8817e4Smiod       s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
408*3d8817e4Smiod 				   ".linux-dynamic");
409*3d8817e4Smiod       BFD_ASSERT (s != NULL);
410*3d8817e4Smiod 
411*3d8817e4Smiod       if (! (_bfd_generic_link_add_one_symbol
412*3d8817e4Smiod 	     (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
413*3d8817e4Smiod 	      BSF_GLOBAL | BSF_CONSTRUCTOR, s, (bfd_vma) 0, NULL,
414*3d8817e4Smiod 	      FALSE, FALSE, NULL)))
415*3d8817e4Smiod 	return FALSE;
416*3d8817e4Smiod     }
417*3d8817e4Smiod 
418*3d8817e4Smiod   return TRUE;
419*3d8817e4Smiod }
420*3d8817e4Smiod 
421*3d8817e4Smiod /* We will crawl the hash table and come here for every global symbol.
422*3d8817e4Smiod    We will examine each entry and see if there are indications that we
423*3d8817e4Smiod    need to add a fixup.  There are two possible cases - one is where
424*3d8817e4Smiod    you have duplicate definitions of PLT or GOT symbols - these will
425*3d8817e4Smiod    have already been caught and added as "builtin" fixups.  If we find
426*3d8817e4Smiod    that the corresponding non PLT/GOT symbol is also present, we
427*3d8817e4Smiod    convert it to a regular fixup instead.
428*3d8817e4Smiod 
429*3d8817e4Smiod    This function is called via linux_link_hash_traverse.  */
430*3d8817e4Smiod 
431*3d8817e4Smiod static bfd_boolean
linux_tally_symbols(h,data)432*3d8817e4Smiod linux_tally_symbols (h, data)
433*3d8817e4Smiod      struct linux_link_hash_entry *h;
434*3d8817e4Smiod      PTR data;
435*3d8817e4Smiod {
436*3d8817e4Smiod   struct bfd_link_info *info = (struct bfd_link_info *) data;
437*3d8817e4Smiod   struct fixup *f, *f1;
438*3d8817e4Smiod   int is_plt;
439*3d8817e4Smiod   struct linux_link_hash_entry *h1, *h2;
440*3d8817e4Smiod   bfd_boolean exists;
441*3d8817e4Smiod 
442*3d8817e4Smiod   if (h->root.root.type == bfd_link_hash_warning)
443*3d8817e4Smiod     h = (struct linux_link_hash_entry *) h->root.root.u.i.link;
444*3d8817e4Smiod 
445*3d8817e4Smiod   if (h->root.root.type == bfd_link_hash_undefined
446*3d8817e4Smiod       && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
447*3d8817e4Smiod 		  sizeof NEEDS_SHRLIB - 1) == 0)
448*3d8817e4Smiod     {
449*3d8817e4Smiod       const char *name;
450*3d8817e4Smiod       char *p;
451*3d8817e4Smiod       char *alloc = NULL;
452*3d8817e4Smiod 
453*3d8817e4Smiod       name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
454*3d8817e4Smiod       p = strrchr (name, '_');
455*3d8817e4Smiod       if (p != NULL)
456*3d8817e4Smiod 	alloc = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 1);
457*3d8817e4Smiod 
458*3d8817e4Smiod       if (p == NULL || alloc == NULL)
459*3d8817e4Smiod 	(*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
460*3d8817e4Smiod 			       name);
461*3d8817e4Smiod       else
462*3d8817e4Smiod 	{
463*3d8817e4Smiod 	  strcpy (alloc, name);
464*3d8817e4Smiod 	  p = strrchr (alloc, '_');
465*3d8817e4Smiod 	  *p++ = '\0';
466*3d8817e4Smiod 	  (*_bfd_error_handler)
467*3d8817e4Smiod 	    (_("Output file requires shared library `%s.so.%s'\n"),
468*3d8817e4Smiod 	     alloc, p);
469*3d8817e4Smiod 	  free (alloc);
470*3d8817e4Smiod 	}
471*3d8817e4Smiod 
472*3d8817e4Smiod       abort ();
473*3d8817e4Smiod     }
474*3d8817e4Smiod 
475*3d8817e4Smiod   /* If this symbol is not a PLT/GOT, we do not even need to look at
476*3d8817e4Smiod      it.  */
477*3d8817e4Smiod   is_plt = IS_PLT_SYM (h->root.root.root.string);
478*3d8817e4Smiod 
479*3d8817e4Smiod   if (is_plt || IS_GOT_SYM (h->root.root.root.string))
480*3d8817e4Smiod     {
481*3d8817e4Smiod       /* Look up this symbol twice.  Once just as a regular lookup,
482*3d8817e4Smiod 	 and then again following all of the indirect links until we
483*3d8817e4Smiod 	 reach a real symbol.  */
484*3d8817e4Smiod       h1 = linux_link_hash_lookup (linux_hash_table (info),
485*3d8817e4Smiod 				   (h->root.root.root.string
486*3d8817e4Smiod 				    + sizeof PLT_REF_PREFIX - 1),
487*3d8817e4Smiod 				   FALSE, FALSE, TRUE);
488*3d8817e4Smiod       /* h2 does not follow indirect symbols.  */
489*3d8817e4Smiod       h2 = linux_link_hash_lookup (linux_hash_table (info),
490*3d8817e4Smiod 				   (h->root.root.root.string
491*3d8817e4Smiod 				    + sizeof PLT_REF_PREFIX - 1),
492*3d8817e4Smiod 				   FALSE, FALSE, FALSE);
493*3d8817e4Smiod 
494*3d8817e4Smiod       /* The real symbol must exist but if it is also an ABS symbol,
495*3d8817e4Smiod 	 there is no need to have a fixup.  This is because they both
496*3d8817e4Smiod 	 came from the same library.  If on the other hand, we had to
497*3d8817e4Smiod 	 use an indirect symbol to get to the real symbol, we add the
498*3d8817e4Smiod 	 fixup anyway, since there are cases where these symbols come
499*3d8817e4Smiod 	 from different shared libraries */
500*3d8817e4Smiod       if (h1 != NULL
501*3d8817e4Smiod 	  && (((h1->root.root.type == bfd_link_hash_defined
502*3d8817e4Smiod 		|| h1->root.root.type == bfd_link_hash_defweak)
503*3d8817e4Smiod 	       && ! bfd_is_abs_section (h1->root.root.u.def.section))
504*3d8817e4Smiod 	      || h2->root.root.type == bfd_link_hash_indirect))
505*3d8817e4Smiod 	{
506*3d8817e4Smiod 	  /* See if there is a "builtin" fixup already present
507*3d8817e4Smiod 	     involving this symbol.  If so, convert it to a regular
508*3d8817e4Smiod 	     fixup.  In the end, this relaxes some of the requirements
509*3d8817e4Smiod 	     about the order of performing fixups.  */
510*3d8817e4Smiod 	  exists = FALSE;
511*3d8817e4Smiod 	  for (f1 = linux_hash_table (info)->fixup_list;
512*3d8817e4Smiod 	       f1 != NULL;
513*3d8817e4Smiod 	       f1 = f1->next)
514*3d8817e4Smiod 	    {
515*3d8817e4Smiod 	      if ((f1->h != h && f1->h != h1)
516*3d8817e4Smiod 		  || (! f1->builtin && ! f1->jump))
517*3d8817e4Smiod 		continue;
518*3d8817e4Smiod 	      if (f1->h == h1)
519*3d8817e4Smiod 		exists = TRUE;
520*3d8817e4Smiod 	      if (! exists
521*3d8817e4Smiod 		  && bfd_is_abs_section (h->root.root.u.def.section))
522*3d8817e4Smiod 		{
523*3d8817e4Smiod 		  f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
524*3d8817e4Smiod 		  f->jump = is_plt;
525*3d8817e4Smiod 		}
526*3d8817e4Smiod 	      f1->h = h1;
527*3d8817e4Smiod 	      f1->jump = is_plt;
528*3d8817e4Smiod 	      f1->builtin = 0;
529*3d8817e4Smiod 	      exists = TRUE;
530*3d8817e4Smiod 	    }
531*3d8817e4Smiod 	  if (! exists
532*3d8817e4Smiod 	      && bfd_is_abs_section (h->root.root.u.def.section))
533*3d8817e4Smiod 	    {
534*3d8817e4Smiod 	      f = new_fixup (info, h1, h->root.root.u.def.value, 0);
535*3d8817e4Smiod 	      if (f == NULL)
536*3d8817e4Smiod 		{
537*3d8817e4Smiod 		  /* FIXME: No way to return error.  */
538*3d8817e4Smiod 		  abort ();
539*3d8817e4Smiod 		}
540*3d8817e4Smiod 	      f->jump = is_plt;
541*3d8817e4Smiod 	    }
542*3d8817e4Smiod 	}
543*3d8817e4Smiod 
544*3d8817e4Smiod       /* Quick and dirty way of stripping these symbols from the
545*3d8817e4Smiod 	 symtab.  */
546*3d8817e4Smiod       if (bfd_is_abs_section (h->root.root.u.def.section))
547*3d8817e4Smiod 	h->root.written = TRUE;
548*3d8817e4Smiod     }
549*3d8817e4Smiod 
550*3d8817e4Smiod   return TRUE;
551*3d8817e4Smiod }
552*3d8817e4Smiod 
553*3d8817e4Smiod /* This is called to set the size of the .linux-dynamic section is.
554*3d8817e4Smiod    It is called by the Linux linker emulation before_allocation
555*3d8817e4Smiod    routine.  We have finished reading all of the input files, and now
556*3d8817e4Smiod    we just scan the hash tables to find out how many additional fixups
557*3d8817e4Smiod    are required.  */
558*3d8817e4Smiod 
559*3d8817e4Smiod bfd_boolean
bfd_sparclinux_size_dynamic_sections(output_bfd,info)560*3d8817e4Smiod bfd_sparclinux_size_dynamic_sections (output_bfd, info)
561*3d8817e4Smiod      bfd *output_bfd;
562*3d8817e4Smiod      struct bfd_link_info *info;
563*3d8817e4Smiod {
564*3d8817e4Smiod   struct fixup *f;
565*3d8817e4Smiod   asection *s;
566*3d8817e4Smiod 
567*3d8817e4Smiod   if (output_bfd->xvec != &MY(vec))
568*3d8817e4Smiod     return TRUE;
569*3d8817e4Smiod 
570*3d8817e4Smiod   /* First find the fixups...  */
571*3d8817e4Smiod   linux_link_hash_traverse (linux_hash_table (info),
572*3d8817e4Smiod 			    linux_tally_symbols,
573*3d8817e4Smiod 			    (PTR) info);
574*3d8817e4Smiod 
575*3d8817e4Smiod   /* If there are builtin fixups, leave room for a marker.  This is
576*3d8817e4Smiod      used by the dynamic linker so that it knows that all that follow
577*3d8817e4Smiod      are builtin fixups instead of regular fixups.  */
578*3d8817e4Smiod   for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
579*3d8817e4Smiod     {
580*3d8817e4Smiod       if (f->builtin)
581*3d8817e4Smiod 	{
582*3d8817e4Smiod 	  ++linux_hash_table (info)->fixup_count;
583*3d8817e4Smiod 	  ++linux_hash_table (info)->local_builtins;
584*3d8817e4Smiod 	  break;
585*3d8817e4Smiod 	}
586*3d8817e4Smiod     }
587*3d8817e4Smiod 
588*3d8817e4Smiod   if (linux_hash_table (info)->dynobj == NULL)
589*3d8817e4Smiod     {
590*3d8817e4Smiod       if (linux_hash_table (info)->fixup_count > 0)
591*3d8817e4Smiod 	abort ();
592*3d8817e4Smiod       return TRUE;
593*3d8817e4Smiod     }
594*3d8817e4Smiod 
595*3d8817e4Smiod   /* Allocate memory for our fixup table.  We will fill it in later.  */
596*3d8817e4Smiod   s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
597*3d8817e4Smiod 			       ".linux-dynamic");
598*3d8817e4Smiod   if (s != NULL)
599*3d8817e4Smiod     {
600*3d8817e4Smiod       s->size = linux_hash_table (info)->fixup_count + 1;
601*3d8817e4Smiod       s->size *= 8;
602*3d8817e4Smiod       s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->size);
603*3d8817e4Smiod       if (s->contents == NULL)
604*3d8817e4Smiod 	return FALSE;
605*3d8817e4Smiod     }
606*3d8817e4Smiod 
607*3d8817e4Smiod   return TRUE;
608*3d8817e4Smiod }
609*3d8817e4Smiod 
610*3d8817e4Smiod /* We come here once we are ready to actually write the fixup table to
611*3d8817e4Smiod    the output file.  Scan the fixup tables and so forth and generate
612*3d8817e4Smiod    the stuff we need.  */
613*3d8817e4Smiod 
614*3d8817e4Smiod static bfd_boolean
linux_finish_dynamic_link(output_bfd,info)615*3d8817e4Smiod linux_finish_dynamic_link (output_bfd, info)
616*3d8817e4Smiod      bfd *output_bfd;
617*3d8817e4Smiod      struct bfd_link_info *info;
618*3d8817e4Smiod {
619*3d8817e4Smiod   asection *s, *os, *is;
620*3d8817e4Smiod   bfd_byte *fixup_table;
621*3d8817e4Smiod   struct linux_link_hash_entry *h;
622*3d8817e4Smiod   struct fixup *f;
623*3d8817e4Smiod   unsigned int new_addr;
624*3d8817e4Smiod   int section_offset;
625*3d8817e4Smiod   unsigned int fixups_written;
626*3d8817e4Smiod 
627*3d8817e4Smiod   if (linux_hash_table (info)->dynobj == NULL)
628*3d8817e4Smiod     return TRUE;
629*3d8817e4Smiod 
630*3d8817e4Smiod   s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
631*3d8817e4Smiod 			       ".linux-dynamic");
632*3d8817e4Smiod   BFD_ASSERT (s != NULL);
633*3d8817e4Smiod   os = s->output_section;
634*3d8817e4Smiod   fixups_written = 0;
635*3d8817e4Smiod 
636*3d8817e4Smiod #ifdef LINUX_LINK_DEBUG
637*3d8817e4Smiod   printf ("Fixup table file offset: %x  VMA: %x\n",
638*3d8817e4Smiod 	  os->filepos + s->output_offset,
639*3d8817e4Smiod 	  os->vma + s->output_offset);
640*3d8817e4Smiod #endif
641*3d8817e4Smiod 
642*3d8817e4Smiod   fixup_table = s->contents;
643*3d8817e4Smiod   bfd_put_32 (output_bfd,
644*3d8817e4Smiod 	      (bfd_vma) linux_hash_table (info)->fixup_count, fixup_table);
645*3d8817e4Smiod   fixup_table += 4;
646*3d8817e4Smiod 
647*3d8817e4Smiod   /* Fill in fixup table.  */
648*3d8817e4Smiod   for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
649*3d8817e4Smiod     {
650*3d8817e4Smiod       if (f->builtin)
651*3d8817e4Smiod 	continue;
652*3d8817e4Smiod 
653*3d8817e4Smiod       if (f->h->root.root.type != bfd_link_hash_defined
654*3d8817e4Smiod 	  && f->h->root.root.type != bfd_link_hash_defweak)
655*3d8817e4Smiod 	{
656*3d8817e4Smiod 	  (*_bfd_error_handler)
657*3d8817e4Smiod 	    (_("Symbol %s not defined for fixups\n"),
658*3d8817e4Smiod 	     f->h->root.root.root.string);
659*3d8817e4Smiod 	  continue;
660*3d8817e4Smiod 	}
661*3d8817e4Smiod 
662*3d8817e4Smiod       is = f->h->root.root.u.def.section;
663*3d8817e4Smiod       section_offset = is->output_section->vma + is->output_offset;
664*3d8817e4Smiod       new_addr = f->h->root.root.u.def.value + section_offset;
665*3d8817e4Smiod 
666*3d8817e4Smiod #ifdef LINUX_LINK_DEBUG
667*3d8817e4Smiod       printf ("Fixup(%d) %s: %x %x\n",f->jump, f->h->root.root.string,
668*3d8817e4Smiod 	      new_addr, f->value);
669*3d8817e4Smiod #endif
670*3d8817e4Smiod 
671*3d8817e4Smiod       if (f->jump)
672*3d8817e4Smiod 	{
673*3d8817e4Smiod 	  /* Relative address */
674*3d8817e4Smiod 	  new_addr = new_addr - (f->value + 5);
675*3d8817e4Smiod 	  bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
676*3d8817e4Smiod 	  fixup_table += 4;
677*3d8817e4Smiod 	  bfd_put_32 (output_bfd, f->value + 1, fixup_table);
678*3d8817e4Smiod 	  fixup_table += 4;
679*3d8817e4Smiod 	}
680*3d8817e4Smiod       else
681*3d8817e4Smiod 	{
682*3d8817e4Smiod 	  bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
683*3d8817e4Smiod 	  fixup_table += 4;
684*3d8817e4Smiod 	  bfd_put_32 (output_bfd, f->value, fixup_table);
685*3d8817e4Smiod 	  fixup_table += 4;
686*3d8817e4Smiod 	}
687*3d8817e4Smiod       ++fixups_written;
688*3d8817e4Smiod     }
689*3d8817e4Smiod 
690*3d8817e4Smiod   if (linux_hash_table (info)->local_builtins != 0)
691*3d8817e4Smiod     {
692*3d8817e4Smiod       /* Special marker so we know to switch to the other type of fixup */
693*3d8817e4Smiod       bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
694*3d8817e4Smiod       fixup_table += 4;
695*3d8817e4Smiod       bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
696*3d8817e4Smiod       fixup_table += 4;
697*3d8817e4Smiod       ++fixups_written;
698*3d8817e4Smiod       for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
699*3d8817e4Smiod 	{
700*3d8817e4Smiod 	  if (! f->builtin)
701*3d8817e4Smiod 	    continue;
702*3d8817e4Smiod 
703*3d8817e4Smiod 	  if (f->h->root.root.type != bfd_link_hash_defined
704*3d8817e4Smiod 	      && f->h->root.root.type != bfd_link_hash_defweak)
705*3d8817e4Smiod 	    {
706*3d8817e4Smiod 	      (*_bfd_error_handler)
707*3d8817e4Smiod 		(_("Symbol %s not defined for fixups\n"),
708*3d8817e4Smiod 		 f->h->root.root.root.string);
709*3d8817e4Smiod 	      continue;
710*3d8817e4Smiod 	    }
711*3d8817e4Smiod 
712*3d8817e4Smiod 	  is = f->h->root.root.u.def.section;
713*3d8817e4Smiod 	  section_offset = is->output_section->vma + is->output_offset;
714*3d8817e4Smiod 	  new_addr = f->h->root.root.u.def.value + section_offset;
715*3d8817e4Smiod 
716*3d8817e4Smiod #ifdef LINUX_LINK_DEBUG
717*3d8817e4Smiod 	  printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
718*3d8817e4Smiod 		  new_addr, f->value);
719*3d8817e4Smiod #endif
720*3d8817e4Smiod 
721*3d8817e4Smiod 	  bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
722*3d8817e4Smiod 	  fixup_table += 4;
723*3d8817e4Smiod 	  bfd_put_32 (output_bfd, f->value, fixup_table);
724*3d8817e4Smiod 	  fixup_table += 4;
725*3d8817e4Smiod 	  ++fixups_written;
726*3d8817e4Smiod 	}
727*3d8817e4Smiod     }
728*3d8817e4Smiod 
729*3d8817e4Smiod   if (linux_hash_table (info)->fixup_count != fixups_written)
730*3d8817e4Smiod     {
731*3d8817e4Smiod       (*_bfd_error_handler) (_("Warning: fixup count mismatch\n"));
732*3d8817e4Smiod       while (linux_hash_table (info)->fixup_count > fixups_written)
733*3d8817e4Smiod 	{
734*3d8817e4Smiod 	  bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
735*3d8817e4Smiod 	  fixup_table += 4;
736*3d8817e4Smiod 	  bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
737*3d8817e4Smiod 	  fixup_table += 4;
738*3d8817e4Smiod 	  ++fixups_written;
739*3d8817e4Smiod 	}
740*3d8817e4Smiod     }
741*3d8817e4Smiod 
742*3d8817e4Smiod   h = linux_link_hash_lookup (linux_hash_table (info),
743*3d8817e4Smiod 			      "__BUILTIN_FIXUPS__",
744*3d8817e4Smiod 			      FALSE, FALSE, FALSE);
745*3d8817e4Smiod 
746*3d8817e4Smiod   if (h != NULL
747*3d8817e4Smiod       && (h->root.root.type == bfd_link_hash_defined
748*3d8817e4Smiod 	  || h->root.root.type == bfd_link_hash_defweak))
749*3d8817e4Smiod     {
750*3d8817e4Smiod       is = h->root.root.u.def.section;
751*3d8817e4Smiod       section_offset = is->output_section->vma + is->output_offset;
752*3d8817e4Smiod       new_addr = h->root.root.u.def.value + section_offset;
753*3d8817e4Smiod 
754*3d8817e4Smiod #ifdef LINUX_LINK_DEBUG
755*3d8817e4Smiod       printf ("Builtin fixup table at %x\n", new_addr);
756*3d8817e4Smiod #endif
757*3d8817e4Smiod 
758*3d8817e4Smiod       bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
759*3d8817e4Smiod     }
760*3d8817e4Smiod   else
761*3d8817e4Smiod     bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
762*3d8817e4Smiod 
763*3d8817e4Smiod   if (bfd_seek (output_bfd, (file_ptr) (os->filepos + s->output_offset),
764*3d8817e4Smiod 		SEEK_SET) != 0)
765*3d8817e4Smiod     return FALSE;
766*3d8817e4Smiod 
767*3d8817e4Smiod   if (bfd_bwrite ((PTR) s->contents, s->size, output_bfd) != s->size)
768*3d8817e4Smiod     return FALSE;
769*3d8817e4Smiod 
770*3d8817e4Smiod   return TRUE;
771*3d8817e4Smiod }
772*3d8817e4Smiod 
773*3d8817e4Smiod #define MY_bfd_link_hash_table_create linux_link_hash_table_create
774*3d8817e4Smiod #define MY_add_one_symbol linux_add_one_symbol
775*3d8817e4Smiod #define MY_finish_dynamic_link linux_finish_dynamic_link
776*3d8817e4Smiod 
777*3d8817e4Smiod #define MY_zmagic_contiguous 1
778*3d8817e4Smiod 
779*3d8817e4Smiod #include "aout-target.h"
780