1 /* BFD backend for SunOS binaries.
2 Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012
4 Free Software Foundation, Inc.
5 Written by Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
24 #define TARGETNAME "a.out-sunos-big"
26 /* Do not "beautify" the CONCAT* macro args. Traditional C will not
27 remove whitespace added here, and thus will fail to concatenate
29 #define MY(OP) CONCAT2 (sunos_big_,OP)
36 /* ??? Where should this go? */
37 #define MACHTYPE_OK(mtype) \
38 (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
39 || ((mtype) == M_SPARCLET \
40 && bfd_lookup_arch (bfd_arch_sparc, bfd_mach_sparc_sparclet) != NULL) \
41 || ((mtype) == M_SPARCLITE_LE \
42 && bfd_lookup_arch (bfd_arch_sparc, bfd_mach_sparc_sparclet) != NULL) \
43 || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
44 && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
46 #define MY_get_dynamic_symtab_upper_bound sunos_get_dynamic_symtab_upper_bound
47 #define MY_canonicalize_dynamic_symtab sunos_canonicalize_dynamic_symtab
48 #define MY_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
49 #define MY_get_dynamic_reloc_upper_bound sunos_get_dynamic_reloc_upper_bound
50 #define MY_canonicalize_dynamic_reloc sunos_canonicalize_dynamic_reloc
51 #define MY_bfd_link_hash_table_create sunos_link_hash_table_create
52 #define MY_add_dynamic_symbols sunos_add_dynamic_symbols
53 #define MY_add_one_symbol sunos_add_one_symbol
54 #define MY_link_dynamic_object sunos_link_dynamic_object
55 #define MY_write_dynamic_symbol sunos_write_dynamic_symbol
56 #define MY_check_dynamic_reloc sunos_check_dynamic_reloc
57 #define MY_finish_dynamic_link sunos_finish_dynamic_link
59 static bfd_boolean
sunos_add_dynamic_symbols (bfd
*, struct bfd_link_info
*, struct external_nlist
**, bfd_size_type
*, char **);
60 static bfd_boolean
sunos_add_one_symbol (struct bfd_link_info
*, bfd
*, const char *, flagword
, asection
*, bfd_vma
, const char *, bfd_boolean
, bfd_boolean
, struct bfd_link_hash_entry
**);
61 static bfd_boolean
sunos_link_dynamic_object (struct bfd_link_info
*, bfd
*);
62 static bfd_boolean
sunos_write_dynamic_symbol (bfd
*, struct bfd_link_info
*, struct aout_link_hash_entry
*);
63 static bfd_boolean
sunos_check_dynamic_reloc (struct bfd_link_info
*, bfd
*, asection
*, struct aout_link_hash_entry
*, void *, bfd_byte
*, bfd_boolean
*, bfd_vma
*);
64 static bfd_boolean
sunos_finish_dynamic_link (bfd
*, struct bfd_link_info
*);
65 static struct bfd_link_hash_table
*sunos_link_hash_table_create (bfd
*);
66 static long sunos_get_dynamic_symtab_upper_bound (bfd
*);
67 static long sunos_canonicalize_dynamic_symtab (bfd
*, asymbol
**);
68 static long sunos_get_dynamic_reloc_upper_bound (bfd
*);
69 static long sunos_canonicalize_dynamic_reloc (bfd
*, arelent
**, asymbol
**);
71 /* Include the usual a.out support. */
74 /* The SunOS 4.1.4 /usr/include/locale.h defines valid as a macro. */
77 /* SunOS shared library support. We store a pointer to this structure
78 in obj_aout_dynamic_info (abfd). */
80 struct sunos_dynamic_info
82 /* Whether we found any dynamic information. */
84 /* Dynamic information. */
85 struct internal_sun4_dynamic_link dyninfo
;
86 /* Number of dynamic symbols. */
87 unsigned long dynsym_count
;
88 /* Read in nlists for dynamic symbols. */
89 struct external_nlist
*dynsym
;
90 /* asymbol structures for dynamic symbols. */
91 aout_symbol_type
*canonical_dynsym
;
92 /* Read in dynamic string table. */
94 /* Number of dynamic relocs. */
95 unsigned long dynrel_count
;
96 /* Read in dynamic relocs. This may be reloc_std_external or
97 reloc_ext_external. */
99 /* arelent structures for dynamic relocs. */
100 arelent
*canonical_dynrel
;
103 /* The hash table of dynamic symbols is composed of two word entries.
104 See include/aout/sun4.h for details. */
106 #define HASH_ENTRY_SIZE (2 * BYTES_IN_WORD)
108 /* Read in the basic dynamic information. This locates the __DYNAMIC
109 structure and uses it to find the dynamic_link structure. It
110 creates and saves a sunos_dynamic_info structure. If it can't find
111 __DYNAMIC, it sets the valid field of the sunos_dynamic_info
112 structure to FALSE to avoid doing this work again. */
115 sunos_read_dynamic_info (bfd
*abfd
)
117 struct sunos_dynamic_info
*info
;
120 struct external_sun4_dynamic dyninfo
;
121 unsigned long dynver
;
122 struct external_sun4_dynamic_link linkinfo
;
125 if (obj_aout_dynamic_info (abfd
) != NULL
)
128 if ((abfd
->flags
& DYNAMIC
) == 0)
130 bfd_set_error (bfd_error_invalid_operation
);
134 amt
= sizeof (struct sunos_dynamic_info
);
135 info
= bfd_zalloc (abfd
, amt
);
141 info
->canonical_dynsym
= NULL
;
143 info
->canonical_dynrel
= NULL
;
144 obj_aout_dynamic_info (abfd
) = (void *) info
;
146 /* This code used to look for the __DYNAMIC symbol to locate the dynamic
148 However this inhibits recovering the dynamic symbols from a
149 stripped object file, so blindly assume that the dynamic linking
150 information is located at the start of the data section.
151 We could verify this assumption later by looking through the dynamic
152 symbols for the __DYNAMIC symbol. */
153 if ((abfd
->flags
& DYNAMIC
) == 0)
155 if (! bfd_get_section_contents (abfd
, obj_datasec (abfd
), (void *) &dyninfo
,
157 (bfd_size_type
) sizeof dyninfo
))
160 dynver
= GET_WORD (abfd
, dyninfo
.ld_version
);
161 if (dynver
!= 2 && dynver
!= 3)
164 dynoff
= GET_WORD (abfd
, dyninfo
.ld
);
166 /* dynoff is a virtual address. It is probably always in the .data
167 section, but this code should work even if it moves. */
168 if (dynoff
< bfd_get_section_vma (abfd
, obj_datasec (abfd
)))
169 dynsec
= obj_textsec (abfd
);
171 dynsec
= obj_datasec (abfd
);
172 dynoff
-= bfd_get_section_vma (abfd
, dynsec
);
173 if (dynoff
> dynsec
->size
)
176 /* This executable appears to be dynamically linked in a way that we
178 if (! bfd_get_section_contents (abfd
, dynsec
, (void *) &linkinfo
,
180 (bfd_size_type
) sizeof linkinfo
))
183 /* Swap in the dynamic link information. */
184 info
->dyninfo
.ld_loaded
= GET_WORD (abfd
, linkinfo
.ld_loaded
);
185 info
->dyninfo
.ld_need
= GET_WORD (abfd
, linkinfo
.ld_need
);
186 info
->dyninfo
.ld_rules
= GET_WORD (abfd
, linkinfo
.ld_rules
);
187 info
->dyninfo
.ld_got
= GET_WORD (abfd
, linkinfo
.ld_got
);
188 info
->dyninfo
.ld_plt
= GET_WORD (abfd
, linkinfo
.ld_plt
);
189 info
->dyninfo
.ld_rel
= GET_WORD (abfd
, linkinfo
.ld_rel
);
190 info
->dyninfo
.ld_hash
= GET_WORD (abfd
, linkinfo
.ld_hash
);
191 info
->dyninfo
.ld_stab
= GET_WORD (abfd
, linkinfo
.ld_stab
);
192 info
->dyninfo
.ld_stab_hash
= GET_WORD (abfd
, linkinfo
.ld_stab_hash
);
193 info
->dyninfo
.ld_buckets
= GET_WORD (abfd
, linkinfo
.ld_buckets
);
194 info
->dyninfo
.ld_symbols
= GET_WORD (abfd
, linkinfo
.ld_symbols
);
195 info
->dyninfo
.ld_symb_size
= GET_WORD (abfd
, linkinfo
.ld_symb_size
);
196 info
->dyninfo
.ld_text
= GET_WORD (abfd
, linkinfo
.ld_text
);
197 info
->dyninfo
.ld_plt_sz
= GET_WORD (abfd
, linkinfo
.ld_plt_sz
);
199 /* Reportedly the addresses need to be offset by the size of the
200 exec header in an NMAGIC file. */
201 if (adata (abfd
).magic
== n_magic
)
203 unsigned long exec_bytes_size
= adata (abfd
).exec_bytes_size
;
205 info
->dyninfo
.ld_need
+= exec_bytes_size
;
206 info
->dyninfo
.ld_rules
+= exec_bytes_size
;
207 info
->dyninfo
.ld_rel
+= exec_bytes_size
;
208 info
->dyninfo
.ld_hash
+= exec_bytes_size
;
209 info
->dyninfo
.ld_stab
+= exec_bytes_size
;
210 info
->dyninfo
.ld_symbols
+= exec_bytes_size
;
213 /* The only way to get the size of the symbol information appears to
214 be to determine the distance between it and the string table. */
215 info
->dynsym_count
= ((info
->dyninfo
.ld_symbols
- info
->dyninfo
.ld_stab
)
216 / EXTERNAL_NLIST_SIZE
);
217 BFD_ASSERT (info
->dynsym_count
* EXTERNAL_NLIST_SIZE
218 == (unsigned long) (info
->dyninfo
.ld_symbols
219 - info
->dyninfo
.ld_stab
));
221 /* Similarly, the relocs end at the hash table. */
222 info
->dynrel_count
= ((info
->dyninfo
.ld_hash
- info
->dyninfo
.ld_rel
)
223 / obj_reloc_entry_size (abfd
));
224 BFD_ASSERT (info
->dynrel_count
* obj_reloc_entry_size (abfd
)
225 == (unsigned long) (info
->dyninfo
.ld_hash
226 - info
->dyninfo
.ld_rel
));
233 /* Return the amount of memory required for the dynamic symbols. */
236 sunos_get_dynamic_symtab_upper_bound (bfd
*abfd
)
238 struct sunos_dynamic_info
*info
;
240 if (! sunos_read_dynamic_info (abfd
))
243 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
246 bfd_set_error (bfd_error_no_symbols
);
250 return (info
->dynsym_count
+ 1) * sizeof (asymbol
*);
253 /* Read the external dynamic symbols. */
256 sunos_slurp_dynamic_symtab (bfd
*abfd
)
258 struct sunos_dynamic_info
*info
;
261 /* Get the general dynamic information. */
262 if (obj_aout_dynamic_info (abfd
) == NULL
)
264 if (! sunos_read_dynamic_info (abfd
))
268 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
271 bfd_set_error (bfd_error_no_symbols
);
275 /* Get the dynamic nlist structures. */
276 if (info
->dynsym
== NULL
)
278 amt
= (bfd_size_type
) info
->dynsym_count
* EXTERNAL_NLIST_SIZE
;
279 info
->dynsym
= bfd_alloc (abfd
, amt
);
280 if (info
->dynsym
== NULL
&& info
->dynsym_count
!= 0)
282 if (bfd_seek (abfd
, (file_ptr
) info
->dyninfo
.ld_stab
, SEEK_SET
) != 0
283 || bfd_bread ((void *) info
->dynsym
, amt
, abfd
) != amt
)
285 if (info
->dynsym
!= NULL
)
287 bfd_release (abfd
, info
->dynsym
);
294 /* Get the dynamic strings. */
295 if (info
->dynstr
== NULL
)
297 amt
= info
->dyninfo
.ld_symb_size
;
298 info
->dynstr
= bfd_alloc (abfd
, amt
);
299 if (info
->dynstr
== NULL
&& info
->dyninfo
.ld_symb_size
!= 0)
301 if (bfd_seek (abfd
, (file_ptr
) info
->dyninfo
.ld_symbols
, SEEK_SET
) != 0
302 || bfd_bread ((void *) info
->dynstr
, amt
, abfd
) != amt
)
304 if (info
->dynstr
!= NULL
)
306 bfd_release (abfd
, info
->dynstr
);
316 /* Read in the dynamic symbols. */
319 sunos_canonicalize_dynamic_symtab (bfd
*abfd
, asymbol
**storage
)
321 struct sunos_dynamic_info
*info
;
324 if (! sunos_slurp_dynamic_symtab (abfd
))
327 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
329 #ifdef CHECK_DYNAMIC_HASH
330 /* Check my understanding of the dynamic hash table by making sure
331 that each symbol can be located in the hash table. */
333 bfd_size_type table_size
;
337 if (info
->dyninfo
.ld_buckets
> info
->dynsym_count
)
339 table_size
= info
->dyninfo
.ld_stab
- info
->dyninfo
.ld_hash
;
340 table
= bfd_malloc (table_size
);
341 if (table
== NULL
&& table_size
!= 0)
343 if (bfd_seek (abfd
, (file_ptr
) info
->dyninfo
.ld_hash
, SEEK_SET
) != 0
344 || bfd_bread ((void *) table
, table_size
, abfd
) != table_size
)
346 for (i
= 0; i
< info
->dynsym_count
; i
++)
351 name
= ((unsigned char *) info
->dynstr
352 + GET_WORD (abfd
, info
->dynsym
[i
].e_strx
));
354 while (*name
!= '\0')
355 hash
= (hash
<< 1) + *name
++;
357 hash
%= info
->dyninfo
.ld_buckets
;
358 while (GET_WORD (abfd
, table
+ hash
* HASH_ENTRY_SIZE
) != i
)
360 hash
= GET_WORD (abfd
,
361 table
+ hash
* HASH_ENTRY_SIZE
+ BYTES_IN_WORD
);
362 if (hash
== 0 || hash
>= table_size
/ HASH_ENTRY_SIZE
)
368 #endif /* CHECK_DYNAMIC_HASH */
370 /* Get the asymbol structures corresponding to the dynamic nlist
372 if (info
->canonical_dynsym
== NULL
)
375 bfd_size_type strsize
= info
->dyninfo
.ld_symb_size
;
377 size
= (bfd_size_type
) info
->dynsym_count
* sizeof (aout_symbol_type
);
378 info
->canonical_dynsym
= bfd_alloc (abfd
, size
);
379 if (info
->canonical_dynsym
== NULL
&& info
->dynsym_count
!= 0)
382 if (! aout_32_translate_symbol_table (abfd
, info
->canonical_dynsym
,
384 (bfd_size_type
) info
->dynsym_count
,
385 info
->dynstr
, strsize
, TRUE
))
387 if (info
->canonical_dynsym
!= NULL
)
389 bfd_release (abfd
, info
->canonical_dynsym
);
390 info
->canonical_dynsym
= NULL
;
396 /* Return pointers to the dynamic asymbol structures. */
397 for (i
= 0; i
< info
->dynsym_count
; i
++)
398 *storage
++ = (asymbol
*) (info
->canonical_dynsym
+ i
);
401 return info
->dynsym_count
;
404 /* Return the amount of memory required for the dynamic relocs. */
407 sunos_get_dynamic_reloc_upper_bound (bfd
*abfd
)
409 struct sunos_dynamic_info
*info
;
411 if (! sunos_read_dynamic_info (abfd
))
414 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
417 bfd_set_error (bfd_error_no_symbols
);
421 return (info
->dynrel_count
+ 1) * sizeof (arelent
*);
424 /* Read in the dynamic relocs. */
427 sunos_canonicalize_dynamic_reloc (bfd
*abfd
, arelent
**storage
, asymbol
**syms
)
429 struct sunos_dynamic_info
*info
;
433 /* Get the general dynamic information. */
434 if (obj_aout_dynamic_info (abfd
) == NULL
)
436 if (! sunos_read_dynamic_info (abfd
))
440 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
443 bfd_set_error (bfd_error_no_symbols
);
447 /* Get the dynamic reloc information. */
448 if (info
->dynrel
== NULL
)
450 size
= (bfd_size_type
) info
->dynrel_count
* obj_reloc_entry_size (abfd
);
451 info
->dynrel
= bfd_alloc (abfd
, size
);
452 if (info
->dynrel
== NULL
&& size
!= 0)
454 if (bfd_seek (abfd
, (file_ptr
) info
->dyninfo
.ld_rel
, SEEK_SET
) != 0
455 || bfd_bread ((void *) info
->dynrel
, size
, abfd
) != size
)
457 if (info
->dynrel
!= NULL
)
459 bfd_release (abfd
, info
->dynrel
);
466 /* Get the arelent structures corresponding to the dynamic reloc
468 if (info
->canonical_dynrel
== NULL
)
472 size
= (bfd_size_type
) info
->dynrel_count
* sizeof (arelent
);
473 info
->canonical_dynrel
= bfd_alloc (abfd
, size
);
474 if (info
->canonical_dynrel
== NULL
&& info
->dynrel_count
!= 0)
477 to
= info
->canonical_dynrel
;
479 if (obj_reloc_entry_size (abfd
) == RELOC_EXT_SIZE
)
481 struct reloc_ext_external
*p
;
482 struct reloc_ext_external
*pend
;
484 p
= (struct reloc_ext_external
*) info
->dynrel
;
485 pend
= p
+ info
->dynrel_count
;
486 for (; p
< pend
; p
++, to
++)
487 NAME (aout
, swap_ext_reloc_in
) (abfd
, p
, to
, syms
,
488 (bfd_size_type
) info
->dynsym_count
);
492 struct reloc_std_external
*p
;
493 struct reloc_std_external
*pend
;
495 p
= (struct reloc_std_external
*) info
->dynrel
;
496 pend
= p
+ info
->dynrel_count
;
497 for (; p
< pend
; p
++, to
++)
498 NAME (aout
, swap_std_reloc_in
) (abfd
, p
, to
, syms
,
499 (bfd_size_type
) info
->dynsym_count
);
503 /* Return pointers to the dynamic arelent structures. */
504 for (i
= 0; i
< info
->dynrel_count
; i
++)
505 *storage
++ = info
->canonical_dynrel
+ i
;
508 return info
->dynrel_count
;
511 /* Code to handle linking of SunOS shared libraries. */
513 /* A SPARC procedure linkage table entry is 12 bytes. The first entry
514 in the table is a jump which is filled in by the runtime linker.
515 The remaining entries are branches back to the first entry,
516 followed by an index into the relocation table encoded to look like
519 #define SPARC_PLT_ENTRY_SIZE (12)
521 static const bfd_byte sparc_plt_first_entry
[SPARC_PLT_ENTRY_SIZE
] =
523 /* sethi %hi(0),%g1; address filled in by runtime linker. */
525 /* jmp %g1; offset filled in by runtime linker. */
531 /* save %sp, -96, %sp */
532 #define SPARC_PLT_ENTRY_WORD0 ((bfd_vma) 0x9de3bfa0)
533 /* call; address filled in later. */
534 #define SPARC_PLT_ENTRY_WORD1 ((bfd_vma) 0x40000000)
535 /* sethi; reloc index filled in later. */
536 #define SPARC_PLT_ENTRY_WORD2 ((bfd_vma) 0x01000000)
538 /* This sequence is used when for the jump table entry to a defined
539 symbol in a complete executable. It is used when linking PIC
540 compiled code which is not being put into a shared library. */
541 /* sethi <address to be filled in later>, %g1 */
542 #define SPARC_PLT_PIC_WORD0 ((bfd_vma) 0x03000000)
543 /* jmp %g1 + <address to be filled in later> */
544 #define SPARC_PLT_PIC_WORD1 ((bfd_vma) 0x81c06000)
546 #define SPARC_PLT_PIC_WORD2 ((bfd_vma) 0x01000000)
548 /* An m68k procedure linkage table entry is 8 bytes. The first entry
549 in the table is a jump which is filled in the by the runtime
550 linker. The remaining entries are branches back to the first
551 entry, followed by a two byte index into the relocation table. */
553 #define M68K_PLT_ENTRY_SIZE (8)
555 static const bfd_byte m68k_plt_first_entry
[M68K_PLT_ENTRY_SIZE
] =
559 /* Filled in by runtime linker with a magic address. */
566 #define M68K_PLT_ENTRY_WORD0 ((bfd_vma) 0x61ff)
567 /* Remaining words filled in later. */
569 /* An entry in the SunOS linker hash table. */
571 struct sunos_link_hash_entry
573 struct aout_link_hash_entry root
;
575 /* If this is a dynamic symbol, this is its index into the dynamic
576 symbol table. This is initialized to -1. As the linker looks at
577 the input files, it changes this to -2 if it will be added to the
578 dynamic symbol table. After all the input files have been seen,
579 the linker will know whether to build a dynamic symbol table; if
580 it does build one, this becomes the index into the table. */
583 /* If this is a dynamic symbol, this is the index of the name in the
584 dynamic symbol string table. */
587 /* The offset into the global offset table used for this symbol. If
588 the symbol does not require a GOT entry, this is 0. */
591 /* The offset into the procedure linkage table used for this symbol.
592 If the symbol does not require a PLT entry, this is 0. */
595 /* Some linker flags. */
597 /* Symbol is referenced by a regular object. */
598 #define SUNOS_REF_REGULAR 01
599 /* Symbol is defined by a regular object. */
600 #define SUNOS_DEF_REGULAR 02
601 /* Symbol is referenced by a dynamic object. */
602 #define SUNOS_REF_DYNAMIC 04
603 /* Symbol is defined by a dynamic object. */
604 #define SUNOS_DEF_DYNAMIC 010
605 /* Symbol is a constructor symbol in a regular object. */
606 #define SUNOS_CONSTRUCTOR 020
609 /* The SunOS linker hash table. */
611 struct sunos_link_hash_table
613 struct aout_link_hash_table root
;
615 /* The object which holds the dynamic sections. */
618 /* Whether we have created the dynamic sections. */
619 bfd_boolean dynamic_sections_created
;
621 /* Whether we need the dynamic sections. */
622 bfd_boolean dynamic_sections_needed
;
624 /* Whether we need the .got table. */
625 bfd_boolean got_needed
;
627 /* The number of dynamic symbols. */
630 /* The number of buckets in the hash table. */
633 /* The list of dynamic objects needed by dynamic objects included in
635 struct bfd_link_needed_list
*needed
;
637 /* The offset of __GLOBAL_OFFSET_TABLE_ into the .got section. */
641 /* Routine to create an entry in an SunOS link hash table. */
643 static struct bfd_hash_entry
*
644 sunos_link_hash_newfunc (struct bfd_hash_entry
*entry
,
645 struct bfd_hash_table
*table
,
648 struct sunos_link_hash_entry
*ret
= (struct sunos_link_hash_entry
*) entry
;
650 /* Allocate the structure if it has not already been allocated by a
653 ret
= bfd_hash_allocate (table
, sizeof (* ret
));
657 /* Call the allocation method of the superclass. */
658 ret
= ((struct sunos_link_hash_entry
*)
659 NAME (aout
, link_hash_newfunc
) ((struct bfd_hash_entry
*) ret
,
663 /* Set local fields. */
665 ret
->dynstr_index
= -1;
671 return (struct bfd_hash_entry
*) ret
;
674 /* Create a SunOS link hash table. */
676 static struct bfd_link_hash_table
*
677 sunos_link_hash_table_create (bfd
*abfd
)
679 struct sunos_link_hash_table
*ret
;
680 bfd_size_type amt
= sizeof (struct sunos_link_hash_table
);
682 ret
= bfd_malloc (amt
);
685 if (!NAME (aout
, link_hash_table_init
) (&ret
->root
, abfd
,
686 sunos_link_hash_newfunc
,
687 sizeof (struct sunos_link_hash_entry
)))
694 ret
->dynamic_sections_created
= FALSE
;
695 ret
->dynamic_sections_needed
= FALSE
;
696 ret
->got_needed
= FALSE
;
697 ret
->dynsymcount
= 0;
698 ret
->bucketcount
= 0;
702 return &ret
->root
.root
;
705 /* Look up an entry in an SunOS link hash table. */
707 #define sunos_link_hash_lookup(table, string, create, copy, follow) \
708 ((struct sunos_link_hash_entry *) \
709 aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
712 /* Traverse a SunOS link hash table. */
714 #define sunos_link_hash_traverse(table, func, info) \
715 (aout_link_hash_traverse \
717 (bfd_boolean (*) (struct aout_link_hash_entry *, void *)) (func), \
720 /* Get the SunOS link hash table from the info structure. This is
723 #define sunos_hash_table(p) ((struct sunos_link_hash_table *) ((p)->hash))
725 /* Create the dynamic sections needed if we are linking against a
726 dynamic object, or if we are linking PIC compiled code. ABFD is a
727 bfd we can attach the dynamic sections to. The linker script will
728 look for these special sections names and put them in the right
729 place in the output file. See include/aout/sun4.h for more details
730 of the dynamic linking information. */
733 sunos_create_dynamic_sections (bfd
*abfd
,
734 struct bfd_link_info
*info
,
739 if (! sunos_hash_table (info
)->dynamic_sections_created
)
743 sunos_hash_table (info
)->dynobj
= abfd
;
745 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
746 | SEC_LINKER_CREATED
);
748 /* The .dynamic section holds the basic dynamic information: the
749 sun4_dynamic structure, the dynamic debugger information, and
750 the sun4_dynamic_link structure. */
751 s
= bfd_make_section_with_flags (abfd
, ".dynamic", flags
);
753 || ! bfd_set_section_alignment (abfd
, s
, 2))
756 /* The .got section holds the global offset table. The address
757 is put in the ld_got field. */
758 s
= bfd_make_section_with_flags (abfd
, ".got", flags
);
760 || ! bfd_set_section_alignment (abfd
, s
, 2))
763 /* The .plt section holds the procedure linkage table. The
764 address is put in the ld_plt field. */
765 s
= bfd_make_section_with_flags (abfd
, ".plt", flags
| SEC_CODE
);
767 || ! bfd_set_section_alignment (abfd
, s
, 2))
770 /* The .dynrel section holds the dynamic relocs. The address is
771 put in the ld_rel field. */
772 s
= bfd_make_section_with_flags (abfd
, ".dynrel", flags
| SEC_READONLY
);
774 || ! bfd_set_section_alignment (abfd
, s
, 2))
777 /* The .hash section holds the dynamic hash table. The address
778 is put in the ld_hash field. */
779 s
= bfd_make_section_with_flags (abfd
, ".hash", flags
| SEC_READONLY
);
781 || ! bfd_set_section_alignment (abfd
, s
, 2))
784 /* The .dynsym section holds the dynamic symbols. The address
785 is put in the ld_stab field. */
786 s
= bfd_make_section_with_flags (abfd
, ".dynsym", flags
| SEC_READONLY
);
788 || ! bfd_set_section_alignment (abfd
, s
, 2))
791 /* The .dynstr section holds the dynamic symbol string table.
792 The address is put in the ld_symbols field. */
793 s
= bfd_make_section_with_flags (abfd
, ".dynstr", flags
| SEC_READONLY
);
795 || ! bfd_set_section_alignment (abfd
, s
, 2))
798 sunos_hash_table (info
)->dynamic_sections_created
= TRUE
;
801 if ((needed
&& ! sunos_hash_table (info
)->dynamic_sections_needed
)
806 dynobj
= sunos_hash_table (info
)->dynobj
;
808 s
= bfd_get_section_by_name (dynobj
, ".got");
810 s
->size
= BYTES_IN_WORD
;
812 sunos_hash_table (info
)->dynamic_sections_needed
= TRUE
;
813 sunos_hash_table (info
)->got_needed
= TRUE
;
819 /* Add dynamic symbols during a link. This is called by the a.out
820 backend linker for each object it encounters. */
823 sunos_add_dynamic_symbols (bfd
*abfd
,
824 struct bfd_link_info
*info
,
825 struct external_nlist
**symsp
,
826 bfd_size_type
*sym_countp
,
830 struct sunos_dynamic_info
*dinfo
;
833 /* Make sure we have all the required sections. */
834 if (info
->output_bfd
->xvec
== abfd
->xvec
)
836 if (! sunos_create_dynamic_sections (abfd
, info
,
837 ((abfd
->flags
& DYNAMIC
) != 0
838 && !info
->relocatable
)))
842 /* There is nothing else to do for a normal object. */
843 if ((abfd
->flags
& DYNAMIC
) == 0)
846 dynobj
= sunos_hash_table (info
)->dynobj
;
848 /* We do not want to include the sections in a dynamic object in the
849 output file. We hack by simply clobbering the list of sections
850 in the BFD. This could be handled more cleanly by, say, a new
851 section flag; the existing SEC_NEVER_LOAD flag is not the one we
852 want, because that one still implies that the section takes up
853 space in the output file. If this is the first object we have
854 seen, we must preserve the dynamic sections we just created. */
856 abfd
->sections
= NULL
;
861 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
863 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
864 bfd_section_list_remove (abfd
, s
);
868 /* The native linker seems to just ignore dynamic objects when -r is
870 if (info
->relocatable
)
873 /* There's no hope of using a dynamic object which does not exactly
874 match the format of the output file. */
875 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
877 bfd_set_error (bfd_error_invalid_operation
);
881 /* Make sure we have a .need and a .rules sections. These are only
882 needed if there really is a dynamic object in the link, so they
883 are not added by sunos_create_dynamic_sections. */
884 if (bfd_get_section_by_name (dynobj
, ".need") == NULL
)
886 /* The .need section holds the list of names of shared objets
887 which must be included at runtime. The address of this
888 section is put in the ld_need field. */
889 flagword flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
890 | SEC_IN_MEMORY
| SEC_READONLY
);
891 asection
*s
= bfd_make_section_with_flags (dynobj
, ".need", flags
);
893 || ! bfd_set_section_alignment (dynobj
, s
, 2))
897 if (bfd_get_section_by_name (dynobj
, ".rules") == NULL
)
899 /* The .rules section holds the path to search for shared
900 objects. The address of this section is put in the ld_rules
902 flagword flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
903 | SEC_IN_MEMORY
| SEC_READONLY
);
904 asection
*s
= bfd_make_section_with_flags (dynobj
, ".rules", flags
);
906 || ! bfd_set_section_alignment (dynobj
, s
, 2))
910 /* Pick up the dynamic symbols and return them to the caller. */
911 if (! sunos_slurp_dynamic_symtab (abfd
))
914 dinfo
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
915 *symsp
= dinfo
->dynsym
;
916 *sym_countp
= dinfo
->dynsym_count
;
917 *stringsp
= dinfo
->dynstr
;
919 /* Record information about any other objects needed by this one. */
920 need
= dinfo
->dyninfo
.ld_need
;
924 unsigned long name
, flags
;
925 unsigned short major_vno
, minor_vno
;
926 struct bfd_link_needed_list
*needed
, **pp
;
932 if (bfd_seek (abfd
, (file_ptr
) need
, SEEK_SET
) != 0
933 || bfd_bread (buf
, (bfd_size_type
) 16, abfd
) != 16)
936 /* For the format of an ld_need entry, see aout/sun4.h. We
937 should probably define structs for this manipulation. */
938 name
= bfd_get_32 (abfd
, buf
);
939 flags
= bfd_get_32 (abfd
, buf
+ 4);
940 major_vno
= (unsigned short) bfd_get_16 (abfd
, buf
+ 8);
941 minor_vno
= (unsigned short) bfd_get_16 (abfd
, buf
+ 10);
942 need
= bfd_get_32 (abfd
, buf
+ 12);
944 alc
= sizeof (struct bfd_link_needed_list
);
945 needed
= bfd_alloc (abfd
, alc
);
950 /* We return the name as [-l]name[.maj][.min]. */
952 namebuf
= bfd_malloc (alc
+ 1);
957 if ((flags
& 0x80000000) != 0)
962 if (bfd_seek (abfd
, (file_ptr
) name
, SEEK_SET
) != 0)
970 if (bfd_bread (&b
, (bfd_size_type
) 1, abfd
) != 1)
976 if ((bfd_size_type
) (p
- namebuf
) >= alc
)
981 n
= bfd_realloc (namebuf
, alc
+ 1);
987 p
= n
+ (p
- namebuf
);
1002 sprintf (majbuf
, ".%d", major_vno
);
1006 sprintf (minbuf
, ".%d", minor_vno
);
1008 if ((p
- namebuf
) + strlen (majbuf
) + strlen (minbuf
) >= alc
)
1012 alc
= (p
- namebuf
) + strlen (majbuf
) + strlen (minbuf
);
1013 n
= bfd_realloc (namebuf
, alc
+ 1);
1019 p
= n
+ (p
- namebuf
);
1027 namecopy
= bfd_alloc (abfd
, (bfd_size_type
) strlen (namebuf
) + 1);
1028 if (namecopy
== NULL
)
1033 strcpy (namecopy
, namebuf
);
1035 needed
->name
= namecopy
;
1037 needed
->next
= NULL
;
1039 for (pp
= &sunos_hash_table (info
)->needed
;
1049 /* Function to add a single symbol to the linker hash table. This is
1050 a wrapper around _bfd_generic_link_add_one_symbol which handles the
1051 tweaking needed for dynamic linking support. */
1054 sunos_add_one_symbol (struct bfd_link_info
*info
,
1062 bfd_boolean collect
,
1063 struct bfd_link_hash_entry
**hashp
)
1065 struct sunos_link_hash_entry
*h
;
1068 if ((flags
& (BSF_INDIRECT
| BSF_WARNING
| BSF_CONSTRUCTOR
)) != 0
1069 || ! bfd_is_und_section (section
))
1070 h
= sunos_link_hash_lookup (sunos_hash_table (info
), name
, TRUE
, copy
,
1073 h
= ((struct sunos_link_hash_entry
*)
1074 bfd_wrapped_link_hash_lookup (abfd
, info
, name
, TRUE
, copy
, FALSE
));
1079 *hashp
= (struct bfd_link_hash_entry
*) h
;
1081 /* Treat a common symbol in a dynamic object as defined in the .bss
1082 section of the dynamic object. We don't want to allocate space
1083 for it in our process image. */
1084 if ((abfd
->flags
& DYNAMIC
) != 0
1085 && bfd_is_com_section (section
))
1086 section
= obj_bsssec (abfd
);
1088 if (! bfd_is_und_section (section
)
1089 && h
->root
.root
.type
!= bfd_link_hash_new
1090 && h
->root
.root
.type
!= bfd_link_hash_undefined
1091 && h
->root
.root
.type
!= bfd_link_hash_defweak
)
1093 /* We are defining the symbol, and it is already defined. This
1094 is a potential multiple definition error. */
1095 if ((abfd
->flags
& DYNAMIC
) != 0)
1097 /* The definition we are adding is from a dynamic object.
1098 We do not want this new definition to override the
1099 existing definition, so we pretend it is just a
1101 section
= bfd_und_section_ptr
;
1103 else if (h
->root
.root
.type
== bfd_link_hash_defined
1104 && h
->root
.root
.u
.def
.section
->owner
!= NULL
1105 && (h
->root
.root
.u
.def
.section
->owner
->flags
& DYNAMIC
) != 0)
1107 /* The existing definition is from a dynamic object. We
1108 want to override it with the definition we just found.
1109 Clobber the existing definition. */
1110 h
->root
.root
.type
= bfd_link_hash_undefined
;
1111 h
->root
.root
.u
.undef
.abfd
= h
->root
.root
.u
.def
.section
->owner
;
1113 else if (h
->root
.root
.type
== bfd_link_hash_common
1114 && (h
->root
.root
.u
.c
.p
->section
->owner
->flags
& DYNAMIC
) != 0)
1116 /* The existing definition is from a dynamic object. We
1117 want to override it with the definition we just found.
1118 Clobber the existing definition. We can't set it to new,
1119 because it is on the undefined list. */
1120 h
->root
.root
.type
= bfd_link_hash_undefined
;
1121 h
->root
.root
.u
.undef
.abfd
= h
->root
.root
.u
.c
.p
->section
->owner
;
1125 if ((abfd
->flags
& DYNAMIC
) != 0
1126 && abfd
->xvec
== info
->output_bfd
->xvec
1127 && (h
->flags
& SUNOS_CONSTRUCTOR
) != 0)
1128 /* The existing symbol is a constructor symbol, and this symbol
1129 is from a dynamic object. A constructor symbol is actually a
1130 definition, although the type will be bfd_link_hash_undefined
1131 at this point. We want to ignore the definition from the
1133 section
= bfd_und_section_ptr
;
1134 else if ((flags
& BSF_CONSTRUCTOR
) != 0
1135 && (abfd
->flags
& DYNAMIC
) == 0
1136 && h
->root
.root
.type
== bfd_link_hash_defined
1137 && h
->root
.root
.u
.def
.section
->owner
!= NULL
1138 && (h
->root
.root
.u
.def
.section
->owner
->flags
& DYNAMIC
) != 0)
1139 /* The existing symbol is defined by a dynamic object, and this
1140 is a constructor symbol. As above, we want to force the use
1141 of the constructor symbol from the regular object. */
1142 h
->root
.root
.type
= bfd_link_hash_new
;
1144 /* Do the usual procedure for adding a symbol. */
1145 if (! _bfd_generic_link_add_one_symbol (info
, abfd
, name
, flags
, section
,
1146 value
, string
, copy
, collect
,
1150 if (abfd
->xvec
== info
->output_bfd
->xvec
)
1152 /* Set a flag in the hash table entry indicating the type of
1153 reference or definition we just found. Keep a count of the
1154 number of dynamic symbols we find. A dynamic symbol is one
1155 which is referenced or defined by both a regular object and a
1157 if ((abfd
->flags
& DYNAMIC
) == 0)
1159 if (bfd_is_und_section (section
))
1160 new_flag
= SUNOS_REF_REGULAR
;
1162 new_flag
= SUNOS_DEF_REGULAR
;
1166 if (bfd_is_und_section (section
))
1167 new_flag
= SUNOS_REF_DYNAMIC
;
1169 new_flag
= SUNOS_DEF_DYNAMIC
;
1171 h
->flags
|= new_flag
;
1173 if (h
->dynindx
== -1
1174 && (h
->flags
& (SUNOS_DEF_REGULAR
| SUNOS_REF_REGULAR
)) != 0)
1176 ++sunos_hash_table (info
)->dynsymcount
;
1180 if ((flags
& BSF_CONSTRUCTOR
) != 0
1181 && (abfd
->flags
& DYNAMIC
) == 0)
1182 h
->flags
|= SUNOS_CONSTRUCTOR
;
1188 extern const bfd_target
MY (vec
);
1190 /* Return the list of objects needed by BFD. */
1192 struct bfd_link_needed_list
*
1193 bfd_sunos_get_needed_list (bfd
*abfd ATTRIBUTE_UNUSED
,
1194 struct bfd_link_info
*info
)
1196 if (info
->output_bfd
->xvec
!= &MY (vec
))
1198 return sunos_hash_table (info
)->needed
;
1201 /* Record an assignment made to a symbol by a linker script. We need
1202 this in case some dynamic object refers to this symbol. */
1205 bfd_sunos_record_link_assignment (bfd
*output_bfd
,
1206 struct bfd_link_info
*info
,
1209 struct sunos_link_hash_entry
*h
;
1211 if (output_bfd
->xvec
!= &MY(vec
))
1214 /* This is called after we have examined all the input objects. If
1215 the symbol does not exist, it merely means that no object refers
1216 to it, and we can just ignore it at this point. */
1217 h
= sunos_link_hash_lookup (sunos_hash_table (info
), name
,
1218 FALSE
, FALSE
, FALSE
);
1222 /* In a shared library, the __DYNAMIC symbol does not appear in the
1223 dynamic symbol table. */
1224 if (! info
->shared
|| strcmp (name
, "__DYNAMIC") != 0)
1226 h
->flags
|= SUNOS_DEF_REGULAR
;
1228 if (h
->dynindx
== -1)
1230 ++sunos_hash_table (info
)->dynsymcount
;
1238 /* Scan the relocs for an input section using standard relocs. We
1239 need to figure out what to do for each reloc against a dynamic
1240 symbol. If the symbol is in the .text section, an entry is made in
1241 the procedure linkage table. Note that this will do the wrong
1242 thing if the symbol is actually data; I don't think the Sun 3
1243 native linker handles this case correctly either. If the symbol is
1244 not in the .text section, we must preserve the reloc as a dynamic
1245 reloc. FIXME: We should also handle the PIC relocs here by
1246 building global offset table entries. */
1249 sunos_scan_std_relocs (struct bfd_link_info
*info
,
1251 asection
*sec ATTRIBUTE_UNUSED
,
1252 const struct reloc_std_external
*relocs
,
1253 bfd_size_type rel_size
)
1256 asection
*splt
= NULL
;
1257 asection
*srel
= NULL
;
1258 struct sunos_link_hash_entry
**sym_hashes
;
1259 const struct reloc_std_external
*rel
, *relend
;
1261 /* We only know how to handle m68k plt entries. */
1262 if (bfd_get_arch (abfd
) != bfd_arch_m68k
)
1264 bfd_set_error (bfd_error_invalid_target
);
1270 sym_hashes
= (struct sunos_link_hash_entry
**) obj_aout_sym_hashes (abfd
);
1272 relend
= relocs
+ rel_size
/ RELOC_STD_SIZE
;
1273 for (rel
= relocs
; rel
< relend
; rel
++)
1276 struct sunos_link_hash_entry
*h
;
1278 /* We only want relocs against external symbols. */
1279 if (bfd_header_big_endian (abfd
))
1281 if ((rel
->r_type
[0] & RELOC_STD_BITS_EXTERN_BIG
) == 0)
1286 if ((rel
->r_type
[0] & RELOC_STD_BITS_EXTERN_LITTLE
) == 0)
1290 /* Get the symbol index. */
1291 if (bfd_header_big_endian (abfd
))
1292 r_index
= ((rel
->r_index
[0] << 16)
1293 | (rel
->r_index
[1] << 8)
1296 r_index
= ((rel
->r_index
[2] << 16)
1297 | (rel
->r_index
[1] << 8)
1300 /* Get the hash table entry. */
1301 h
= sym_hashes
[r_index
];
1303 /* This should not normally happen, but it will in any case
1304 be caught in the relocation phase. */
1307 /* At this point common symbols have already been allocated, so
1308 we don't have to worry about them. We need to consider that
1309 we may have already seen this symbol and marked it undefined;
1310 if the symbol is really undefined, then SUNOS_DEF_DYNAMIC
1312 if (h
->root
.root
.type
!= bfd_link_hash_defined
1313 && h
->root
.root
.type
!= bfd_link_hash_defweak
1314 && h
->root
.root
.type
!= bfd_link_hash_undefined
)
1317 if ((h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
1318 || (h
->flags
& SUNOS_DEF_REGULAR
) != 0)
1325 if (! sunos_create_dynamic_sections (abfd
, info
, FALSE
))
1327 dynobj
= sunos_hash_table (info
)->dynobj
;
1328 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1329 srel
= bfd_get_section_by_name (dynobj
, ".dynrel");
1330 BFD_ASSERT (splt
!= NULL
&& srel
!= NULL
);
1332 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1333 BFD_ASSERT (sgot
!= NULL
);
1334 if (sgot
->size
== 0)
1335 sgot
->size
= BYTES_IN_WORD
;
1336 sunos_hash_table (info
)->got_needed
= TRUE
;
1339 BFD_ASSERT ((h
->flags
& SUNOS_REF_REGULAR
) != 0);
1340 BFD_ASSERT (h
->plt_offset
!= 0
1341 || ((h
->root
.root
.type
== bfd_link_hash_defined
1342 || h
->root
.root
.type
== bfd_link_hash_defweak
)
1343 ? (h
->root
.root
.u
.def
.section
->owner
->flags
1345 : (h
->root
.root
.u
.undef
.abfd
->flags
& DYNAMIC
) != 0));
1347 /* This reloc is against a symbol defined only by a dynamic
1349 if (h
->root
.root
.type
== bfd_link_hash_undefined
)
1350 /* Presumably this symbol was marked as being undefined by
1351 an earlier reloc. */
1352 srel
->size
+= RELOC_STD_SIZE
;
1353 else if ((h
->root
.root
.u
.def
.section
->flags
& SEC_CODE
) == 0)
1357 /* This reloc is not in the .text section. It must be
1358 copied into the dynamic relocs. We mark the symbol as
1360 srel
->size
+= RELOC_STD_SIZE
;
1361 sub
= h
->root
.root
.u
.def
.section
->owner
;
1362 h
->root
.root
.type
= bfd_link_hash_undefined
;
1363 h
->root
.root
.u
.undef
.abfd
= sub
;
1367 /* This symbol is in the .text section. We must give it an
1368 entry in the procedure linkage table, if we have not
1369 already done so. We change the definition of the symbol
1370 to the .plt section; this will cause relocs against it to
1371 be handled correctly. */
1372 if (h
->plt_offset
== 0)
1374 if (splt
->size
== 0)
1375 splt
->size
= M68K_PLT_ENTRY_SIZE
;
1376 h
->plt_offset
= splt
->size
;
1378 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1380 h
->root
.root
.u
.def
.section
= splt
;
1381 h
->root
.root
.u
.def
.value
= splt
->size
;
1384 splt
->size
+= M68K_PLT_ENTRY_SIZE
;
1386 /* We may also need a dynamic reloc entry. */
1387 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1388 srel
->size
+= RELOC_STD_SIZE
;
1396 /* Scan the relocs for an input section using extended relocs. We
1397 need to figure out what to do for each reloc against a dynamic
1398 symbol. If the reloc is a WDISP30, and the symbol is in the .text
1399 section, an entry is made in the procedure linkage table.
1400 Otherwise, we must preserve the reloc as a dynamic reloc. */
1403 sunos_scan_ext_relocs (struct bfd_link_info
*info
,
1405 asection
*sec ATTRIBUTE_UNUSED
,
1406 const struct reloc_ext_external
*relocs
,
1407 bfd_size_type rel_size
)
1410 struct sunos_link_hash_entry
**sym_hashes
;
1411 const struct reloc_ext_external
*rel
, *relend
;
1412 asection
*splt
= NULL
;
1413 asection
*sgot
= NULL
;
1414 asection
*srel
= NULL
;
1417 /* We only know how to handle SPARC plt entries. */
1418 if (bfd_get_arch (abfd
) != bfd_arch_sparc
)
1420 bfd_set_error (bfd_error_invalid_target
);
1426 sym_hashes
= (struct sunos_link_hash_entry
**) obj_aout_sym_hashes (abfd
);
1428 relend
= relocs
+ rel_size
/ RELOC_EXT_SIZE
;
1429 for (rel
= relocs
; rel
< relend
; rel
++)
1431 unsigned int r_index
;
1434 struct sunos_link_hash_entry
*h
= NULL
;
1436 /* Swap in the reloc information. */
1437 if (bfd_header_big_endian (abfd
))
1439 r_index
= ((rel
->r_index
[0] << 16)
1440 | (rel
->r_index
[1] << 8)
1442 r_extern
= (0 != (rel
->r_type
[0] & RELOC_EXT_BITS_EXTERN_BIG
));
1443 r_type
= ((rel
->r_type
[0] & RELOC_EXT_BITS_TYPE_BIG
)
1444 >> RELOC_EXT_BITS_TYPE_SH_BIG
);
1448 r_index
= ((rel
->r_index
[2] << 16)
1449 | (rel
->r_index
[1] << 8)
1451 r_extern
= (0 != (rel
->r_type
[0] & RELOC_EXT_BITS_EXTERN_LITTLE
));
1452 r_type
= ((rel
->r_type
[0] & RELOC_EXT_BITS_TYPE_LITTLE
)
1453 >> RELOC_EXT_BITS_TYPE_SH_LITTLE
);
1458 h
= sym_hashes
[r_index
];
1461 /* This should not normally happen, but it will in any
1462 case be caught in the relocation phase. */
1467 /* If this is a base relative reloc, we need to make an entry in
1468 the .got section. */
1469 if (r_type
== RELOC_BASE10
1470 || r_type
== RELOC_BASE13
1471 || r_type
== RELOC_BASE22
)
1475 if (! sunos_create_dynamic_sections (abfd
, info
, FALSE
))
1477 dynobj
= sunos_hash_table (info
)->dynobj
;
1478 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1479 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1480 srel
= bfd_get_section_by_name (dynobj
, ".dynrel");
1481 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
1483 /* Make sure we have an initial entry in the .got table. */
1484 if (sgot
->size
== 0)
1485 sgot
->size
= BYTES_IN_WORD
;
1486 sunos_hash_table (info
)->got_needed
= TRUE
;
1491 if (h
->got_offset
!= 0)
1494 h
->got_offset
= sgot
->size
;
1498 if (r_index
>= bfd_get_symcount (abfd
))
1499 /* This is abnormal, but should be caught in the
1500 relocation phase. */
1503 if (adata (abfd
).local_got_offsets
== NULL
)
1505 amt
= bfd_get_symcount (abfd
);
1506 amt
*= sizeof (bfd_vma
);
1507 adata (abfd
).local_got_offsets
= bfd_zalloc (abfd
, amt
);
1508 if (adata (abfd
).local_got_offsets
== NULL
)
1512 if (adata (abfd
).local_got_offsets
[r_index
] != 0)
1515 adata (abfd
).local_got_offsets
[r_index
] = sgot
->size
;
1518 sgot
->size
+= BYTES_IN_WORD
;
1520 /* If we are making a shared library, or if the symbol is
1521 defined by a dynamic object, we will need a dynamic reloc
1525 && (h
->flags
& SUNOS_DEF_DYNAMIC
) != 0
1526 && (h
->flags
& SUNOS_DEF_REGULAR
) == 0))
1527 srel
->size
+= RELOC_EXT_SIZE
;
1532 /* Otherwise, we are only interested in relocs against symbols
1533 defined in dynamic objects but not in regular objects. We
1534 only need to consider relocs against external symbols. */
1537 /* But, if we are creating a shared library, we need to
1538 generate an absolute reloc. */
1543 if (! sunos_create_dynamic_sections (abfd
, info
, TRUE
))
1545 dynobj
= sunos_hash_table (info
)->dynobj
;
1546 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1547 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1548 srel
= bfd_get_section_by_name (dynobj
, ".dynrel");
1549 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
1552 srel
->size
+= RELOC_EXT_SIZE
;
1558 /* At this point common symbols have already been allocated, so
1559 we don't have to worry about them. We need to consider that
1560 we may have already seen this symbol and marked it undefined;
1561 if the symbol is really undefined, then SUNOS_DEF_DYNAMIC
1563 if (h
->root
.root
.type
!= bfd_link_hash_defined
1564 && h
->root
.root
.type
!= bfd_link_hash_defweak
1565 && h
->root
.root
.type
!= bfd_link_hash_undefined
)
1568 if (r_type
!= RELOC_JMP_TBL
1570 && ((h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
1571 || (h
->flags
& SUNOS_DEF_REGULAR
) != 0))
1574 if (r_type
== RELOC_JMP_TBL
1576 && (h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
1577 && (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1579 /* This symbol is apparently undefined. Don't do anything
1580 here; just let the relocation routine report an undefined
1585 if (strcmp (h
->root
.root
.root
.string
, "__GLOBAL_OFFSET_TABLE_") == 0)
1590 if (! sunos_create_dynamic_sections (abfd
, info
, FALSE
))
1592 dynobj
= sunos_hash_table (info
)->dynobj
;
1593 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1594 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1595 srel
= bfd_get_section_by_name (dynobj
, ".dynrel");
1596 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
1598 /* Make sure we have an initial entry in the .got table. */
1599 if (sgot
->size
== 0)
1600 sgot
->size
= BYTES_IN_WORD
;
1601 sunos_hash_table (info
)->got_needed
= TRUE
;
1604 BFD_ASSERT (r_type
== RELOC_JMP_TBL
1606 || (h
->flags
& SUNOS_REF_REGULAR
) != 0);
1607 BFD_ASSERT (r_type
== RELOC_JMP_TBL
1609 || h
->plt_offset
!= 0
1610 || ((h
->root
.root
.type
== bfd_link_hash_defined
1611 || h
->root
.root
.type
== bfd_link_hash_defweak
)
1612 ? (h
->root
.root
.u
.def
.section
->owner
->flags
1614 : (h
->root
.root
.u
.undef
.abfd
->flags
& DYNAMIC
) != 0));
1616 /* This reloc is against a symbol defined only by a dynamic
1617 object, or it is a jump table reloc from PIC compiled code. */
1619 if (r_type
!= RELOC_JMP_TBL
1620 && h
->root
.root
.type
== bfd_link_hash_undefined
)
1621 /* Presumably this symbol was marked as being undefined by
1622 an earlier reloc. */
1623 srel
->size
+= RELOC_EXT_SIZE
;
1625 else if (r_type
!= RELOC_JMP_TBL
1626 && (h
->root
.root
.u
.def
.section
->flags
& SEC_CODE
) == 0)
1630 /* This reloc is not in the .text section. It must be
1631 copied into the dynamic relocs. We mark the symbol as
1633 srel
->size
+= RELOC_EXT_SIZE
;
1634 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1636 sub
= h
->root
.root
.u
.def
.section
->owner
;
1637 h
->root
.root
.type
= bfd_link_hash_undefined
;
1638 h
->root
.root
.u
.undef
.abfd
= sub
;
1643 /* This symbol is in the .text section. We must give it an
1644 entry in the procedure linkage table, if we have not
1645 already done so. We change the definition of the symbol
1646 to the .plt section; this will cause relocs against it to
1647 be handled correctly. */
1648 if (h
->plt_offset
== 0)
1650 if (splt
->size
== 0)
1651 splt
->size
= SPARC_PLT_ENTRY_SIZE
;
1652 h
->plt_offset
= splt
->size
;
1654 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1656 if (h
->root
.root
.type
== bfd_link_hash_undefined
)
1657 h
->root
.root
.type
= bfd_link_hash_defined
;
1658 h
->root
.root
.u
.def
.section
= splt
;
1659 h
->root
.root
.u
.def
.value
= splt
->size
;
1662 splt
->size
+= SPARC_PLT_ENTRY_SIZE
;
1664 /* We will also need a dynamic reloc entry, unless this
1665 is a JMP_TBL reloc produced by linking PIC compiled
1666 code, and we are not making a shared library. */
1667 if (info
->shared
|| (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1668 srel
->size
+= RELOC_EXT_SIZE
;
1671 /* If we are creating a shared library, we need to copy over
1672 any reloc other than a jump table reloc. */
1673 if (info
->shared
&& r_type
!= RELOC_JMP_TBL
)
1674 srel
->size
+= RELOC_EXT_SIZE
;
1681 /* Scan the relocs for an input section. */
1684 sunos_scan_relocs (struct bfd_link_info
*info
,
1687 bfd_size_type rel_size
)
1690 void * free_relocs
= NULL
;
1695 if (! info
->keep_memory
)
1696 relocs
= free_relocs
= bfd_malloc (rel_size
);
1699 struct aout_section_data_struct
*n
;
1700 bfd_size_type amt
= sizeof (struct aout_section_data_struct
);
1702 n
= bfd_alloc (abfd
, amt
);
1707 set_aout_section_data (sec
, n
);
1708 relocs
= bfd_malloc (rel_size
);
1709 aout_section_data (sec
)->relocs
= relocs
;
1715 if (bfd_seek (abfd
, sec
->rel_filepos
, SEEK_SET
) != 0
1716 || bfd_bread (relocs
, rel_size
, abfd
) != rel_size
)
1719 if (obj_reloc_entry_size (abfd
) == RELOC_STD_SIZE
)
1721 if (! sunos_scan_std_relocs (info
, abfd
, sec
,
1722 (struct reloc_std_external
*) relocs
,
1728 if (! sunos_scan_ext_relocs (info
, abfd
, sec
,
1729 (struct reloc_ext_external
*) relocs
,
1734 if (free_relocs
!= NULL
)
1740 if (free_relocs
!= NULL
)
1745 /* Build the hash table of dynamic symbols, and to mark as written all
1746 symbols from dynamic objects which we do not plan to write out. */
1749 sunos_scan_dynamic_symbol (struct sunos_link_hash_entry
*h
, void * data
)
1751 struct bfd_link_info
*info
= (struct bfd_link_info
*) data
;
1753 /* Set the written flag for symbols we do not want to write out as
1754 part of the regular symbol table. This is all symbols which are
1755 not defined in a regular object file. For some reason symbols
1756 which are referenced by a regular object and defined by a dynamic
1757 object do not seem to show up in the regular symbol table. It is
1758 possible for a symbol to have only SUNOS_REF_REGULAR set here, it
1759 is an undefined symbol which was turned into a common symbol
1760 because it was found in an archive object which was not included
1762 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0
1763 && (h
->flags
& SUNOS_DEF_DYNAMIC
) != 0
1764 && strcmp (h
->root
.root
.root
.string
, "__DYNAMIC") != 0)
1765 h
->root
.written
= TRUE
;
1767 /* If this symbol is defined by a dynamic object and referenced by a
1768 regular object, see whether we gave it a reasonable value while
1769 scanning the relocs. */
1770 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0
1771 && (h
->flags
& SUNOS_DEF_DYNAMIC
) != 0
1772 && (h
->flags
& SUNOS_REF_REGULAR
) != 0)
1774 if ((h
->root
.root
.type
== bfd_link_hash_defined
1775 || h
->root
.root
.type
== bfd_link_hash_defweak
)
1776 && ((h
->root
.root
.u
.def
.section
->owner
->flags
& DYNAMIC
) != 0)
1777 && h
->root
.root
.u
.def
.section
->output_section
== NULL
)
1781 /* This symbol is currently defined in a dynamic section
1782 which is not being put into the output file. This
1783 implies that there is no reloc against the symbol. I'm
1784 not sure why this case would ever occur. In any case, we
1785 change the symbol to be undefined. */
1786 sub
= h
->root
.root
.u
.def
.section
->owner
;
1787 h
->root
.root
.type
= bfd_link_hash_undefined
;
1788 h
->root
.root
.u
.undef
.abfd
= sub
;
1792 /* If this symbol is defined or referenced by a regular file, add it
1793 to the dynamic symbols. */
1794 if ((h
->flags
& (SUNOS_DEF_REGULAR
| SUNOS_REF_REGULAR
)) != 0)
1799 unsigned char *name
;
1803 BFD_ASSERT (h
->dynindx
== -2);
1805 dynobj
= sunos_hash_table (info
)->dynobj
;
1807 h
->dynindx
= sunos_hash_table (info
)->dynsymcount
;
1808 ++sunos_hash_table (info
)->dynsymcount
;
1810 len
= strlen (h
->root
.root
.root
.string
);
1812 /* We don't bother to construct a BFD hash table for the strings
1813 which are the names of the dynamic symbols. Using a hash
1814 table for the regular symbols is beneficial, because the
1815 regular symbols includes the debugging symbols, which have
1816 long names and are often duplicated in several object files.
1817 There are no debugging symbols in the dynamic symbols. */
1818 s
= bfd_get_section_by_name (dynobj
, ".dynstr");
1819 BFD_ASSERT (s
!= NULL
);
1820 contents
= bfd_realloc (s
->contents
, s
->size
+ len
+ 1);
1821 if (contents
== NULL
)
1823 s
->contents
= contents
;
1825 h
->dynstr_index
= s
->size
;
1826 strcpy ((char *) contents
+ s
->size
, h
->root
.root
.root
.string
);
1829 /* Add it to the dynamic hash table. */
1830 name
= (unsigned char *) h
->root
.root
.root
.string
;
1832 while (*name
!= '\0')
1833 hash
= (hash
<< 1) + *name
++;
1835 hash
%= sunos_hash_table (info
)->bucketcount
;
1837 s
= bfd_get_section_by_name (dynobj
, ".hash");
1838 BFD_ASSERT (s
!= NULL
);
1840 if (GET_SWORD (dynobj
, s
->contents
+ hash
* HASH_ENTRY_SIZE
) == -1)
1841 PUT_WORD (dynobj
, h
->dynindx
, s
->contents
+ hash
* HASH_ENTRY_SIZE
);
1846 next
= GET_WORD (dynobj
,
1848 + hash
* HASH_ENTRY_SIZE
1850 PUT_WORD (dynobj
, s
->size
/ HASH_ENTRY_SIZE
,
1851 s
->contents
+ hash
* HASH_ENTRY_SIZE
+ BYTES_IN_WORD
);
1852 PUT_WORD (dynobj
, h
->dynindx
, s
->contents
+ s
->size
);
1853 PUT_WORD (dynobj
, next
, s
->contents
+ s
->size
+ BYTES_IN_WORD
);
1854 s
->size
+= HASH_ENTRY_SIZE
;
1861 /* Set up the sizes and contents of the dynamic sections created in
1862 sunos_add_dynamic_symbols. This is called by the SunOS linker
1863 emulation before_allocation routine. We must set the sizes of the
1864 sections before the linker sets the addresses of the various
1865 sections. This unfortunately requires reading all the relocs so
1866 that we can work out which ones need to become dynamic relocs. If
1867 info->keep_memory is TRUE, we keep the relocs in memory; otherwise,
1868 we discard them, and will read them again later. */
1871 bfd_sunos_size_dynamic_sections (bfd
*output_bfd
,
1872 struct bfd_link_info
*info
,
1874 asection
**sneedptr
,
1875 asection
**srulesptr
)
1878 bfd_size_type dynsymcount
;
1879 struct sunos_link_hash_entry
*h
;
1882 bfd_size_type hashalloc
;
1890 if (info
->relocatable
)
1893 if (output_bfd
->xvec
!= &MY(vec
))
1896 /* Look through all the input BFD's and read their relocs. It would
1897 be better if we didn't have to do this, but there is no other way
1898 to determine the number of dynamic relocs we need, and, more
1899 importantly, there is no other way to know which symbols should
1900 get an entry in the procedure linkage table. */
1901 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
1903 if ((sub
->flags
& DYNAMIC
) == 0
1904 && sub
->xvec
== output_bfd
->xvec
)
1906 if (! sunos_scan_relocs (info
, sub
, obj_textsec (sub
),
1907 exec_hdr (sub
)->a_trsize
)
1908 || ! sunos_scan_relocs (info
, sub
, obj_datasec (sub
),
1909 exec_hdr (sub
)->a_drsize
))
1914 dynobj
= sunos_hash_table (info
)->dynobj
;
1915 dynsymcount
= sunos_hash_table (info
)->dynsymcount
;
1917 /* If there were no dynamic objects in the link, and we don't need
1918 to build a global offset table, there is nothing to do here. */
1919 if (! sunos_hash_table (info
)->dynamic_sections_needed
1920 && ! sunos_hash_table (info
)->got_needed
)
1923 /* If __GLOBAL_OFFSET_TABLE_ was mentioned, define it. */
1924 h
= sunos_link_hash_lookup (sunos_hash_table (info
),
1925 "__GLOBAL_OFFSET_TABLE_", FALSE
, FALSE
, FALSE
);
1926 if (h
!= NULL
&& (h
->flags
& SUNOS_REF_REGULAR
) != 0)
1928 h
->flags
|= SUNOS_DEF_REGULAR
;
1929 if (h
->dynindx
== -1)
1931 ++sunos_hash_table (info
)->dynsymcount
;
1934 h
->root
.root
.type
= bfd_link_hash_defined
;
1935 h
->root
.root
.u
.def
.section
= bfd_get_section_by_name (dynobj
, ".got");
1937 /* If the .got section is more than 0x1000 bytes, we set
1938 __GLOBAL_OFFSET_TABLE_ to be 0x1000 bytes into the section,
1939 so that 13 bit relocations have a greater chance of working. */
1940 s
= bfd_get_section_by_name (dynobj
, ".got");
1941 BFD_ASSERT (s
!= NULL
);
1942 if (s
->size
>= 0x1000)
1943 h
->root
.root
.u
.def
.value
= 0x1000;
1945 h
->root
.root
.u
.def
.value
= 0;
1947 sunos_hash_table (info
)->got_base
= h
->root
.root
.u
.def
.value
;
1950 /* If there are any shared objects in the link, then we need to set
1951 up the dynamic linking information. */
1952 if (sunos_hash_table (info
)->dynamic_sections_needed
)
1954 *sdynptr
= bfd_get_section_by_name (dynobj
, ".dynamic");
1956 /* The .dynamic section is always the same size. */
1958 BFD_ASSERT (s
!= NULL
);
1959 s
->size
= (sizeof (struct external_sun4_dynamic
)
1960 + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE
1961 + sizeof (struct external_sun4_dynamic_link
));
1963 /* Set the size of the .dynsym and .hash sections. We counted
1964 the number of dynamic symbols as we read the input files. We
1965 will build the dynamic symbol table (.dynsym) and the hash
1966 table (.hash) when we build the final symbol table, because
1967 until then we do not know the correct value to give the
1968 symbols. We build the dynamic symbol string table (.dynstr)
1969 in a traversal of the symbol table using
1970 sunos_scan_dynamic_symbol. */
1971 s
= bfd_get_section_by_name (dynobj
, ".dynsym");
1972 BFD_ASSERT (s
!= NULL
);
1973 s
->size
= dynsymcount
* sizeof (struct external_nlist
);
1974 s
->contents
= bfd_alloc (output_bfd
, s
->size
);
1975 if (s
->contents
== NULL
&& s
->size
!= 0)
1978 /* The number of buckets is just the number of symbols divided
1979 by four. To compute the final size of the hash table, we
1980 must actually compute the hash table. Normally we need
1981 exactly as many entries in the hash table as there are
1982 dynamic symbols, but if some of the buckets are not used we
1983 will need additional entries. In the worst case, every
1984 symbol will hash to the same bucket, and we will need
1985 BUCKETCOUNT - 1 extra entries. */
1986 if (dynsymcount
>= 4)
1987 bucketcount
= dynsymcount
/ 4;
1988 else if (dynsymcount
> 0)
1989 bucketcount
= dynsymcount
;
1992 s
= bfd_get_section_by_name (dynobj
, ".hash");
1993 BFD_ASSERT (s
!= NULL
);
1994 hashalloc
= (dynsymcount
+ bucketcount
- 1) * HASH_ENTRY_SIZE
;
1995 s
->contents
= bfd_zalloc (dynobj
, hashalloc
);
1996 if (s
->contents
== NULL
&& dynsymcount
> 0)
1998 for (i
= 0; i
< bucketcount
; i
++)
1999 PUT_WORD (output_bfd
, (bfd_vma
) -1, s
->contents
+ i
* HASH_ENTRY_SIZE
);
2000 s
->size
= bucketcount
* HASH_ENTRY_SIZE
;
2002 sunos_hash_table (info
)->bucketcount
= bucketcount
;
2004 /* Scan all the symbols, place them in the dynamic symbol table,
2005 and build the dynamic hash table. We reuse dynsymcount as a
2006 counter for the number of symbols we have added so far. */
2007 sunos_hash_table (info
)->dynsymcount
= 0;
2008 sunos_link_hash_traverse (sunos_hash_table (info
),
2009 sunos_scan_dynamic_symbol
,
2011 BFD_ASSERT (sunos_hash_table (info
)->dynsymcount
== dynsymcount
);
2013 /* The SunOS native linker seems to align the total size of the
2014 symbol strings to a multiple of 8. I don't know if this is
2015 important, but it can't hurt much. */
2016 s
= bfd_get_section_by_name (dynobj
, ".dynstr");
2017 BFD_ASSERT (s
!= NULL
);
2018 if ((s
->size
& 7) != 0)
2023 add
= 8 - (s
->size
& 7);
2024 contents
= bfd_realloc (s
->contents
, s
->size
+ add
);
2025 if (contents
== NULL
)
2027 memset (contents
+ s
->size
, 0, (size_t) add
);
2028 s
->contents
= contents
;
2033 /* Now that we have worked out the sizes of the procedure linkage
2034 table and the dynamic relocs, allocate storage for them. */
2035 s
= bfd_get_section_by_name (dynobj
, ".plt");
2036 BFD_ASSERT (s
!= NULL
);
2039 s
->contents
= bfd_alloc (dynobj
, s
->size
);
2040 if (s
->contents
== NULL
)
2043 /* Fill in the first entry in the table. */
2044 switch (bfd_get_arch (dynobj
))
2046 case bfd_arch_sparc
:
2047 memcpy (s
->contents
, sparc_plt_first_entry
, SPARC_PLT_ENTRY_SIZE
);
2051 memcpy (s
->contents
, m68k_plt_first_entry
, M68K_PLT_ENTRY_SIZE
);
2059 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2062 s
->contents
= bfd_alloc (dynobj
, s
->size
);
2063 if (s
->contents
== NULL
)
2066 /* We use the reloc_count field to keep track of how many of the
2067 relocs we have output so far. */
2070 /* Make space for the global offset table. */
2071 s
= bfd_get_section_by_name (dynobj
, ".got");
2072 s
->contents
= bfd_alloc (dynobj
, s
->size
);
2073 if (s
->contents
== NULL
)
2076 *sneedptr
= bfd_get_section_by_name (dynobj
, ".need");
2077 *srulesptr
= bfd_get_section_by_name (dynobj
, ".rules");
2082 /* Link a dynamic object. We actually don't have anything to do at
2083 this point. This entry point exists to prevent the regular linker
2084 code from doing anything with the object. */
2087 sunos_link_dynamic_object (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
2088 bfd
*abfd ATTRIBUTE_UNUSED
)
2093 /* Write out a dynamic symbol. This is called by the final traversal
2094 over the symbol table. */
2097 sunos_write_dynamic_symbol (bfd
*output_bfd
,
2098 struct bfd_link_info
*info
,
2099 struct aout_link_hash_entry
*harg
)
2101 struct sunos_link_hash_entry
*h
= (struct sunos_link_hash_entry
*) harg
;
2105 struct external_nlist
*outsym
;
2107 /* If this symbol is in the procedure linkage table, fill in the
2109 if (h
->plt_offset
!= 0)
2116 dynobj
= sunos_hash_table (info
)->dynobj
;
2117 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2118 p
= splt
->contents
+ h
->plt_offset
;
2120 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2122 r_address
= (splt
->output_section
->vma
2123 + splt
->output_offset
2126 switch (bfd_get_arch (output_bfd
))
2128 case bfd_arch_sparc
:
2129 if (info
->shared
|| (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
2131 bfd_put_32 (output_bfd
, SPARC_PLT_ENTRY_WORD0
, p
);
2132 bfd_put_32 (output_bfd
,
2133 (SPARC_PLT_ENTRY_WORD1
2134 + (((- (h
->plt_offset
+ 4) >> 2)
2137 bfd_put_32 (output_bfd
, SPARC_PLT_ENTRY_WORD2
+ s
->reloc_count
,
2142 val
= (h
->root
.root
.u
.def
.section
->output_section
->vma
2143 + h
->root
.root
.u
.def
.section
->output_offset
2144 + h
->root
.root
.u
.def
.value
);
2145 bfd_put_32 (output_bfd
,
2146 SPARC_PLT_PIC_WORD0
+ ((val
>> 10) & 0x3fffff),
2148 bfd_put_32 (output_bfd
,
2149 SPARC_PLT_PIC_WORD1
+ (val
& 0x3ff),
2151 bfd_put_32 (output_bfd
, SPARC_PLT_PIC_WORD2
, p
+ 8);
2156 if (! info
->shared
&& (h
->flags
& SUNOS_DEF_REGULAR
) != 0)
2158 bfd_put_16 (output_bfd
, M68K_PLT_ENTRY_WORD0
, p
);
2159 bfd_put_32 (output_bfd
, (- (h
->plt_offset
+ 2)), p
+ 2);
2160 bfd_put_16 (output_bfd
, (bfd_vma
) s
->reloc_count
, p
+ 6);
2168 /* We also need to add a jump table reloc, unless this is the
2169 result of a JMP_TBL reloc from PIC compiled code. */
2170 if (info
->shared
|| (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
2172 BFD_ASSERT (h
->dynindx
>= 0);
2173 BFD_ASSERT (s
->reloc_count
* obj_reloc_entry_size (dynobj
)
2175 p
= s
->contents
+ s
->reloc_count
* obj_reloc_entry_size (output_bfd
);
2176 if (obj_reloc_entry_size (output_bfd
) == RELOC_STD_SIZE
)
2178 struct reloc_std_external
*srel
;
2180 srel
= (struct reloc_std_external
*) p
;
2181 PUT_WORD (output_bfd
, r_address
, srel
->r_address
);
2182 if (bfd_header_big_endian (output_bfd
))
2184 srel
->r_index
[0] = (bfd_byte
) (h
->dynindx
>> 16);
2185 srel
->r_index
[1] = (bfd_byte
) (h
->dynindx
>> 8);
2186 srel
->r_index
[2] = (bfd_byte
) (h
->dynindx
);
2187 srel
->r_type
[0] = (RELOC_STD_BITS_EXTERN_BIG
2188 | RELOC_STD_BITS_JMPTABLE_BIG
);
2192 srel
->r_index
[2] = (bfd_byte
) (h
->dynindx
>> 16);
2193 srel
->r_index
[1] = (bfd_byte
) (h
->dynindx
>> 8);
2194 srel
->r_index
[0] = (bfd_byte
)h
->dynindx
;
2195 srel
->r_type
[0] = (RELOC_STD_BITS_EXTERN_LITTLE
2196 | RELOC_STD_BITS_JMPTABLE_LITTLE
);
2201 struct reloc_ext_external
*erel
;
2203 erel
= (struct reloc_ext_external
*) p
;
2204 PUT_WORD (output_bfd
, r_address
, erel
->r_address
);
2205 if (bfd_header_big_endian (output_bfd
))
2207 erel
->r_index
[0] = (bfd_byte
) (h
->dynindx
>> 16);
2208 erel
->r_index
[1] = (bfd_byte
) (h
->dynindx
>> 8);
2209 erel
->r_index
[2] = (bfd_byte
)h
->dynindx
;
2211 (RELOC_EXT_BITS_EXTERN_BIG
2212 | (RELOC_JMP_SLOT
<< RELOC_EXT_BITS_TYPE_SH_BIG
));
2216 erel
->r_index
[2] = (bfd_byte
) (h
->dynindx
>> 16);
2217 erel
->r_index
[1] = (bfd_byte
) (h
->dynindx
>> 8);
2218 erel
->r_index
[0] = (bfd_byte
)h
->dynindx
;
2220 (RELOC_EXT_BITS_EXTERN_LITTLE
2221 | (RELOC_JMP_SLOT
<< RELOC_EXT_BITS_TYPE_SH_LITTLE
));
2223 PUT_WORD (output_bfd
, (bfd_vma
) 0, erel
->r_addend
);
2230 /* If this is not a dynamic symbol, we don't have to do anything
2231 else. We only check this after handling the PLT entry, because
2232 we can have a PLT entry for a nondynamic symbol when linking PIC
2233 compiled code from a regular object. */
2237 switch (h
->root
.root
.type
)
2240 case bfd_link_hash_new
:
2242 /* Avoid variable not initialized warnings. */
2244 case bfd_link_hash_undefined
:
2245 type
= N_UNDF
| N_EXT
;
2248 case bfd_link_hash_defined
:
2249 case bfd_link_hash_defweak
:
2252 asection
*output_section
;
2254 sec
= h
->root
.root
.u
.def
.section
;
2255 output_section
= sec
->output_section
;
2256 BFD_ASSERT (bfd_is_abs_section (output_section
)
2257 || output_section
->owner
== output_bfd
);
2258 if (h
->plt_offset
!= 0
2259 && (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
2261 type
= N_UNDF
| N_EXT
;
2266 if (output_section
== obj_textsec (output_bfd
))
2267 type
= (h
->root
.root
.type
== bfd_link_hash_defined
2270 else if (output_section
== obj_datasec (output_bfd
))
2271 type
= (h
->root
.root
.type
== bfd_link_hash_defined
2274 else if (output_section
== obj_bsssec (output_bfd
))
2275 type
= (h
->root
.root
.type
== bfd_link_hash_defined
2279 type
= (h
->root
.root
.type
== bfd_link_hash_defined
2283 val
= (h
->root
.root
.u
.def
.value
2284 + output_section
->vma
2285 + sec
->output_offset
);
2289 case bfd_link_hash_common
:
2290 type
= N_UNDF
| N_EXT
;
2291 val
= h
->root
.root
.u
.c
.size
;
2293 case bfd_link_hash_undefweak
:
2297 case bfd_link_hash_indirect
:
2298 case bfd_link_hash_warning
:
2299 /* FIXME: Ignore these for now. The circumstances under which
2300 they should be written out are not clear to me. */
2304 s
= bfd_get_section_by_name (sunos_hash_table (info
)->dynobj
, ".dynsym");
2305 BFD_ASSERT (s
!= NULL
);
2306 outsym
= ((struct external_nlist
*)
2307 (s
->contents
+ h
->dynindx
* EXTERNAL_NLIST_SIZE
));
2309 H_PUT_8 (output_bfd
, type
, outsym
->e_type
);
2310 H_PUT_8 (output_bfd
, 0, outsym
->e_other
);
2312 /* FIXME: The native linker doesn't use 0 for desc. It seems to use
2313 one less than the desc value in the shared library, although that
2315 H_PUT_16 (output_bfd
, 0, outsym
->e_desc
);
2317 PUT_WORD (output_bfd
, h
->dynstr_index
, outsym
->e_strx
);
2318 PUT_WORD (output_bfd
, val
, outsym
->e_value
);
2323 /* This is called for each reloc against an external symbol. If this
2324 is a reloc which are are going to copy as a dynamic reloc, then
2325 copy it over, and tell the caller to not bother processing this
2329 sunos_check_dynamic_reloc (struct bfd_link_info
*info
,
2331 asection
*input_section
,
2332 struct aout_link_hash_entry
*harg
,
2334 bfd_byte
*contents ATTRIBUTE_UNUSED
,
2336 bfd_vma
*relocationp
)
2338 struct sunos_link_hash_entry
*h
= (struct sunos_link_hash_entry
*) harg
;
2340 bfd_boolean baserel
;
2349 dynobj
= sunos_hash_table (info
)->dynobj
;
2352 && h
->plt_offset
!= 0
2354 || (h
->flags
& SUNOS_DEF_REGULAR
) == 0))
2358 /* Redirect the relocation to the PLT entry. */
2359 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2360 *relocationp
= (splt
->output_section
->vma
2361 + splt
->output_offset
2365 if (obj_reloc_entry_size (input_bfd
) == RELOC_STD_SIZE
)
2367 struct reloc_std_external
*srel
;
2369 srel
= (struct reloc_std_external
*) reloc
;
2370 if (bfd_header_big_endian (input_bfd
))
2372 baserel
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_BASEREL_BIG
));
2373 jmptbl
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_JMPTABLE_BIG
));
2374 pcrel
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_PCREL_BIG
));
2378 baserel
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_BASEREL_LITTLE
));
2379 jmptbl
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_JMPTABLE_LITTLE
));
2380 pcrel
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_PCREL_LITTLE
));
2385 struct reloc_ext_external
*erel
;
2388 erel
= (struct reloc_ext_external
*) reloc
;
2389 if (bfd_header_big_endian (input_bfd
))
2390 r_type
= ((erel
->r_type
[0] & RELOC_EXT_BITS_TYPE_BIG
)
2391 >> RELOC_EXT_BITS_TYPE_SH_BIG
);
2393 r_type
= ((erel
->r_type
[0] & RELOC_EXT_BITS_TYPE_LITTLE
)
2394 >> RELOC_EXT_BITS_TYPE_SH_LITTLE
);
2395 baserel
= (r_type
== RELOC_BASE10
2396 || r_type
== RELOC_BASE13
2397 || r_type
== RELOC_BASE22
);
2398 jmptbl
= r_type
== RELOC_JMP_TBL
;
2399 pcrel
= (r_type
== RELOC_DISP8
2400 || r_type
== RELOC_DISP16
2401 || r_type
== RELOC_DISP32
2402 || r_type
== RELOC_WDISP30
2403 || r_type
== RELOC_WDISP22
);
2404 /* We don't consider the PC10 and PC22 types to be PC relative,
2405 because they are pcrel_offset. */
2410 bfd_vma
*got_offsetp
;
2414 got_offsetp
= &h
->got_offset
;
2415 else if (adata (input_bfd
).local_got_offsets
== NULL
)
2419 struct reloc_std_external
*srel
;
2422 srel
= (struct reloc_std_external
*) reloc
;
2423 if (obj_reloc_entry_size (input_bfd
) == RELOC_STD_SIZE
)
2425 if (bfd_header_big_endian (input_bfd
))
2426 r_index
= ((srel
->r_index
[0] << 16)
2427 | (srel
->r_index
[1] << 8)
2428 | srel
->r_index
[2]);
2430 r_index
= ((srel
->r_index
[2] << 16)
2431 | (srel
->r_index
[1] << 8)
2432 | srel
->r_index
[0]);
2436 struct reloc_ext_external
*erel
;
2438 erel
= (struct reloc_ext_external
*) reloc
;
2439 if (bfd_header_big_endian (input_bfd
))
2440 r_index
= ((erel
->r_index
[0] << 16)
2441 | (erel
->r_index
[1] << 8)
2442 | erel
->r_index
[2]);
2444 r_index
= ((erel
->r_index
[2] << 16)
2445 | (erel
->r_index
[1] << 8)
2446 | erel
->r_index
[0]);
2449 got_offsetp
= adata (input_bfd
).local_got_offsets
+ r_index
;
2452 BFD_ASSERT (got_offsetp
!= NULL
&& *got_offsetp
!= 0);
2454 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2456 /* We set the least significant bit to indicate whether we have
2457 already initialized the GOT entry. */
2458 if ((*got_offsetp
& 1) == 0)
2462 && ((h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
2463 || (h
->flags
& SUNOS_DEF_REGULAR
) != 0)))
2464 PUT_WORD (dynobj
, *relocationp
, sgot
->contents
+ *got_offsetp
);
2466 PUT_WORD (dynobj
, 0, sgot
->contents
+ *got_offsetp
);
2470 && (h
->flags
& SUNOS_DEF_DYNAMIC
) != 0
2471 && (h
->flags
& SUNOS_DEF_REGULAR
) == 0))
2473 /* We need to create a GLOB_DAT or 32 reloc to tell the
2474 dynamic linker to fill in this entry in the table. */
2476 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2477 BFD_ASSERT (s
!= NULL
);
2478 BFD_ASSERT (s
->reloc_count
* obj_reloc_entry_size (dynobj
)
2482 + s
->reloc_count
* obj_reloc_entry_size (dynobj
));
2489 if (obj_reloc_entry_size (dynobj
) == RELOC_STD_SIZE
)
2491 struct reloc_std_external
*srel
;
2493 srel
= (struct reloc_std_external
*) p
;
2496 + sgot
->output_section
->vma
2497 + sgot
->output_offset
),
2499 if (bfd_header_big_endian (dynobj
))
2501 srel
->r_index
[0] = (bfd_byte
) (indx
>> 16);
2502 srel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2503 srel
->r_index
[2] = (bfd_byte
)indx
;
2505 srel
->r_type
[0] = 2 << RELOC_STD_BITS_LENGTH_SH_BIG
;
2508 (RELOC_STD_BITS_EXTERN_BIG
2509 | RELOC_STD_BITS_BASEREL_BIG
2510 | RELOC_STD_BITS_RELATIVE_BIG
2511 | (2 << RELOC_STD_BITS_LENGTH_SH_BIG
));
2515 srel
->r_index
[2] = (bfd_byte
) (indx
>> 16);
2516 srel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2517 srel
->r_index
[0] = (bfd_byte
)indx
;
2519 srel
->r_type
[0] = 2 << RELOC_STD_BITS_LENGTH_SH_LITTLE
;
2522 (RELOC_STD_BITS_EXTERN_LITTLE
2523 | RELOC_STD_BITS_BASEREL_LITTLE
2524 | RELOC_STD_BITS_RELATIVE_LITTLE
2525 | (2 << RELOC_STD_BITS_LENGTH_SH_LITTLE
));
2530 struct reloc_ext_external
*erel
;
2532 erel
= (struct reloc_ext_external
*) p
;
2535 + sgot
->output_section
->vma
2536 + sgot
->output_offset
),
2538 if (bfd_header_big_endian (dynobj
))
2540 erel
->r_index
[0] = (bfd_byte
) (indx
>> 16);
2541 erel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2542 erel
->r_index
[2] = (bfd_byte
)indx
;
2545 RELOC_32
<< RELOC_EXT_BITS_TYPE_SH_BIG
;
2548 (RELOC_EXT_BITS_EXTERN_BIG
2549 | (RELOC_GLOB_DAT
<< RELOC_EXT_BITS_TYPE_SH_BIG
));
2553 erel
->r_index
[2] = (bfd_byte
) (indx
>> 16);
2554 erel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2555 erel
->r_index
[0] = (bfd_byte
)indx
;
2558 RELOC_32
<< RELOC_EXT_BITS_TYPE_SH_LITTLE
;
2561 (RELOC_EXT_BITS_EXTERN_LITTLE
2563 << RELOC_EXT_BITS_TYPE_SH_LITTLE
));
2565 PUT_WORD (dynobj
, 0, erel
->r_addend
);
2574 *relocationp
= (sgot
->vma
2575 + (*got_offsetp
&~ (bfd_vma
) 1)
2576 - sunos_hash_table (info
)->got_base
);
2578 /* There is nothing else to do for a base relative reloc. */
2582 if (! sunos_hash_table (info
)->dynamic_sections_needed
)
2588 || h
->root
.root
.type
!= bfd_link_hash_undefined
2589 || (h
->flags
& SUNOS_DEF_REGULAR
) != 0
2590 || (h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
2591 || (h
->root
.root
.u
.undef
.abfd
->flags
& DYNAMIC
) == 0)
2597 && (h
->dynindx
== -1
2599 || strcmp (h
->root
.root
.root
.string
,
2600 "__GLOBAL_OFFSET_TABLE_") == 0))
2604 /* It looks like this is a reloc we are supposed to copy. */
2606 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2607 BFD_ASSERT (s
!= NULL
);
2608 BFD_ASSERT (s
->reloc_count
* obj_reloc_entry_size (dynobj
) < s
->size
);
2610 p
= s
->contents
+ s
->reloc_count
* obj_reloc_entry_size (dynobj
);
2612 /* Copy the reloc over. */
2613 memcpy (p
, reloc
, obj_reloc_entry_size (dynobj
));
2620 /* Adjust the address and symbol index. */
2621 if (obj_reloc_entry_size (dynobj
) == RELOC_STD_SIZE
)
2623 struct reloc_std_external
*srel
;
2625 srel
= (struct reloc_std_external
*) p
;
2627 (GET_WORD (dynobj
, srel
->r_address
)
2628 + input_section
->output_section
->vma
2629 + input_section
->output_offset
),
2631 if (bfd_header_big_endian (dynobj
))
2633 srel
->r_index
[0] = (bfd_byte
) (indx
>> 16);
2634 srel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2635 srel
->r_index
[2] = (bfd_byte
)indx
;
2639 srel
->r_index
[2] = (bfd_byte
) (indx
>> 16);
2640 srel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2641 srel
->r_index
[0] = (bfd_byte
)indx
;
2643 /* FIXME: We may have to change the addend for a PC relative
2648 struct reloc_ext_external
*erel
;
2650 erel
= (struct reloc_ext_external
*) p
;
2652 (GET_WORD (dynobj
, erel
->r_address
)
2653 + input_section
->output_section
->vma
2654 + input_section
->output_offset
),
2656 if (bfd_header_big_endian (dynobj
))
2658 erel
->r_index
[0] = (bfd_byte
) (indx
>> 16);
2659 erel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2660 erel
->r_index
[2] = (bfd_byte
)indx
;
2664 erel
->r_index
[2] = (bfd_byte
) (indx
>> 16);
2665 erel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2666 erel
->r_index
[0] = (bfd_byte
)indx
;
2668 if (pcrel
&& h
!= NULL
)
2670 /* Adjust the addend for the change in address. */
2672 (GET_WORD (dynobj
, erel
->r_addend
)
2673 - (input_section
->output_section
->vma
2674 + input_section
->output_offset
2675 - input_section
->vma
)),
2688 /* Finish up the dynamic linking information. */
2691 sunos_finish_dynamic_link (bfd
*abfd
, struct bfd_link_info
*info
)
2698 if (! sunos_hash_table (info
)->dynamic_sections_needed
2699 && ! sunos_hash_table (info
)->got_needed
)
2702 dynobj
= sunos_hash_table (info
)->dynobj
;
2704 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
2705 BFD_ASSERT (sdyn
!= NULL
);
2707 /* Finish up the .need section. The linker emulation code filled it
2708 in, but with offsets from the start of the section instead of
2709 real addresses. Now that we know the section location, we can
2710 fill in the final values. */
2711 s
= bfd_get_section_by_name (dynobj
, ".need");
2712 if (s
!= NULL
&& s
->size
!= 0)
2717 filepos
= s
->output_section
->filepos
+ s
->output_offset
;
2723 PUT_WORD (dynobj
, GET_WORD (dynobj
, p
) + filepos
, p
);
2724 val
= GET_WORD (dynobj
, p
+ 12);
2727 PUT_WORD (dynobj
, val
+ filepos
, p
+ 12);
2732 /* The first entry in the .got section is the address of the
2733 dynamic information, unless this is a shared library. */
2734 s
= bfd_get_section_by_name (dynobj
, ".got");
2735 BFD_ASSERT (s
!= NULL
);
2736 if (info
->shared
|| sdyn
->size
== 0)
2737 PUT_WORD (dynobj
, 0, s
->contents
);
2739 PUT_WORD (dynobj
, sdyn
->output_section
->vma
+ sdyn
->output_offset
,
2742 for (o
= dynobj
->sections
; o
!= NULL
; o
= o
->next
)
2744 if ((o
->flags
& SEC_HAS_CONTENTS
) != 0
2745 && o
->contents
!= NULL
)
2747 BFD_ASSERT (o
->output_section
!= NULL
2748 && o
->output_section
->owner
== abfd
);
2749 if (! bfd_set_section_contents (abfd
, o
->output_section
,
2751 (file_ptr
) o
->output_offset
,
2759 struct external_sun4_dynamic esd
;
2760 struct external_sun4_dynamic_link esdl
;
2763 /* Finish up the dynamic link information. */
2764 PUT_WORD (dynobj
, (bfd_vma
) 3, esd
.ld_version
);
2766 sdyn
->output_section
->vma
+ sdyn
->output_offset
+ sizeof esd
,
2769 (sdyn
->output_section
->vma
2770 + sdyn
->output_offset
2772 + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE
),
2775 if (! bfd_set_section_contents (abfd
, sdyn
->output_section
, &esd
,
2776 (file_ptr
) sdyn
->output_offset
,
2777 (bfd_size_type
) sizeof esd
))
2780 PUT_WORD (dynobj
, (bfd_vma
) 0, esdl
.ld_loaded
);
2782 s
= bfd_get_section_by_name (dynobj
, ".need");
2783 if (s
== NULL
|| s
->size
== 0)
2784 PUT_WORD (dynobj
, (bfd_vma
) 0, esdl
.ld_need
);
2786 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2789 s
= bfd_get_section_by_name (dynobj
, ".rules");
2790 if (s
== NULL
|| s
->size
== 0)
2791 PUT_WORD (dynobj
, (bfd_vma
) 0, esdl
.ld_rules
);
2793 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2796 s
= bfd_get_section_by_name (dynobj
, ".got");
2797 BFD_ASSERT (s
!= NULL
);
2798 PUT_WORD (dynobj
, s
->output_section
->vma
+ s
->output_offset
,
2801 s
= bfd_get_section_by_name (dynobj
, ".plt");
2802 BFD_ASSERT (s
!= NULL
);
2803 PUT_WORD (dynobj
, s
->output_section
->vma
+ s
->output_offset
,
2805 PUT_WORD (dynobj
, s
->size
, esdl
.ld_plt_sz
);
2807 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2808 BFD_ASSERT (s
!= NULL
);
2809 BFD_ASSERT (s
->reloc_count
* obj_reloc_entry_size (dynobj
)
2811 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2814 s
= bfd_get_section_by_name (dynobj
, ".hash");
2815 BFD_ASSERT (s
!= NULL
);
2816 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2819 s
= bfd_get_section_by_name (dynobj
, ".dynsym");
2820 BFD_ASSERT (s
!= NULL
);
2821 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2824 PUT_WORD (dynobj
, (bfd_vma
) 0, esdl
.ld_stab_hash
);
2826 PUT_WORD (dynobj
, (bfd_vma
) sunos_hash_table (info
)->bucketcount
,
2829 s
= bfd_get_section_by_name (dynobj
, ".dynstr");
2830 BFD_ASSERT (s
!= NULL
);
2831 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2833 PUT_WORD (dynobj
, s
->size
, esdl
.ld_symb_size
);
2835 /* The size of the text area is the size of the .text section
2836 rounded up to a page boundary. FIXME: Should the page size be
2837 conditional on something? */
2839 BFD_ALIGN (obj_textsec (abfd
)->size
, 0x2000),
2842 pos
= sdyn
->output_offset
;
2843 pos
+= sizeof esd
+ EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE
;
2844 if (! bfd_set_section_contents (abfd
, sdyn
->output_section
, &esdl
,
2845 pos
, (bfd_size_type
) sizeof esdl
))
2848 abfd
->flags
|= DYNAMIC
;