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