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
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)
35 /* ??? Where should this go? */
36 #define MACHTYPE_OK(mtype) \
37 (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
38 || ((mtype) == M_SPARCLET \
39 && bfd_lookup_arch (bfd_arch_sparc, bfd_mach_sparc_sparclet) != NULL) \
40 || ((mtype) == M_SPARCLITE_LE \
41 && bfd_lookup_arch (bfd_arch_sparc, bfd_mach_sparc_sparclet) != NULL) \
42 || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
43 && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
45 #define MY_get_dynamic_symtab_upper_bound sunos_get_dynamic_symtab_upper_bound
46 #define MY_canonicalize_dynamic_symtab sunos_canonicalize_dynamic_symtab
47 #define MY_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
48 #define MY_get_dynamic_reloc_upper_bound sunos_get_dynamic_reloc_upper_bound
49 #define MY_canonicalize_dynamic_reloc sunos_canonicalize_dynamic_reloc
50 #define MY_bfd_link_hash_table_create sunos_link_hash_table_create
51 #define MY_add_dynamic_symbols sunos_add_dynamic_symbols
52 #define MY_add_one_symbol sunos_add_one_symbol
53 #define MY_link_dynamic_object sunos_link_dynamic_object
54 #define MY_write_dynamic_symbol sunos_write_dynamic_symbol
55 #define MY_check_dynamic_reloc sunos_check_dynamic_reloc
56 #define MY_finish_dynamic_link sunos_finish_dynamic_link
58 static bfd_boolean
sunos_add_dynamic_symbols (bfd
*, struct bfd_link_info
*, struct external_nlist
**, bfd_size_type
*, char **);
59 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
**);
60 static bfd_boolean
sunos_link_dynamic_object (struct bfd_link_info
*, bfd
*);
61 static bfd_boolean
sunos_write_dynamic_symbol (bfd
*, struct bfd_link_info
*, struct aout_link_hash_entry
*);
62 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
*);
63 static bfd_boolean
sunos_finish_dynamic_link (bfd
*, struct bfd_link_info
*);
64 static struct bfd_link_hash_table
*sunos_link_hash_table_create (bfd
*);
65 static long sunos_get_dynamic_symtab_upper_bound (bfd
*);
66 static long sunos_canonicalize_dynamic_symtab (bfd
*, asymbol
**);
67 static long sunos_get_dynamic_reloc_upper_bound (bfd
*);
68 static long sunos_canonicalize_dynamic_reloc (bfd
*, arelent
**, asymbol
**);
70 /* Include the usual a.out support. */
73 /* The SunOS 4.1.4 /usr/include/locale.h defines valid as a macro. */
76 /* SunOS shared library support. We store a pointer to this structure
77 in obj_aout_dynamic_info (abfd). */
79 struct sunos_dynamic_info
81 /* Whether we found any dynamic information. */
83 /* Dynamic information. */
84 struct internal_sun4_dynamic_link dyninfo
;
85 /* Number of dynamic symbols. */
86 unsigned long dynsym_count
;
87 /* Read in nlists for dynamic symbols. */
88 struct external_nlist
*dynsym
;
89 /* asymbol structures for dynamic symbols. */
90 aout_symbol_type
*canonical_dynsym
;
91 /* Read in dynamic string table. */
93 /* Number of dynamic relocs. */
94 unsigned long dynrel_count
;
95 /* Read in dynamic relocs. This may be reloc_std_external or
96 reloc_ext_external. */
98 /* arelent structures for dynamic relocs. */
99 arelent
*canonical_dynrel
;
102 /* The hash table of dynamic symbols is composed of two word entries.
103 See include/aout/sun4.h for details. */
105 #define HASH_ENTRY_SIZE (2 * BYTES_IN_WORD)
107 /* Read in the basic dynamic information. This locates the __DYNAMIC
108 structure and uses it to find the dynamic_link structure. It
109 creates and saves a sunos_dynamic_info structure. If it can't find
110 __DYNAMIC, it sets the valid field of the sunos_dynamic_info
111 structure to FALSE to avoid doing this work again. */
114 sunos_read_dynamic_info (bfd
*abfd
)
116 struct sunos_dynamic_info
*info
;
119 struct external_sun4_dynamic dyninfo
;
120 unsigned long dynver
;
121 struct external_sun4_dynamic_link linkinfo
;
124 if (obj_aout_dynamic_info (abfd
) != NULL
)
127 if ((abfd
->flags
& DYNAMIC
) == 0)
129 bfd_set_error (bfd_error_invalid_operation
);
133 amt
= sizeof (struct sunos_dynamic_info
);
134 info
= bfd_zalloc (abfd
, amt
);
140 info
->canonical_dynsym
= NULL
;
142 info
->canonical_dynrel
= NULL
;
143 obj_aout_dynamic_info (abfd
) = (void *) info
;
145 /* This code used to look for the __DYNAMIC symbol to locate the dynamic
147 However this inhibits recovering the dynamic symbols from a
148 stripped object file, so blindly assume that the dynamic linking
149 information is located at the start of the data section.
150 We could verify this assumption later by looking through the dynamic
151 symbols for the __DYNAMIC symbol. */
152 if ((abfd
->flags
& DYNAMIC
) == 0)
154 if (! bfd_get_section_contents (abfd
, obj_datasec (abfd
), (void *) &dyninfo
,
156 (bfd_size_type
) sizeof dyninfo
))
159 dynver
= GET_WORD (abfd
, dyninfo
.ld_version
);
160 if (dynver
!= 2 && dynver
!= 3)
163 dynoff
= GET_WORD (abfd
, dyninfo
.ld
);
165 /* dynoff is a virtual address. It is probably always in the .data
166 section, but this code should work even if it moves. */
167 if (dynoff
< bfd_get_section_vma (abfd
, obj_datasec (abfd
)))
168 dynsec
= obj_textsec (abfd
);
170 dynsec
= obj_datasec (abfd
);
171 dynoff
-= bfd_get_section_vma (abfd
, dynsec
);
172 if (dynoff
> dynsec
->size
)
175 /* This executable appears to be dynamically linked in a way that we
177 if (! bfd_get_section_contents (abfd
, dynsec
, (void *) &linkinfo
,
179 (bfd_size_type
) sizeof linkinfo
))
182 /* Swap in the dynamic link information. */
183 info
->dyninfo
.ld_loaded
= GET_WORD (abfd
, linkinfo
.ld_loaded
);
184 info
->dyninfo
.ld_need
= GET_WORD (abfd
, linkinfo
.ld_need
);
185 info
->dyninfo
.ld_rules
= GET_WORD (abfd
, linkinfo
.ld_rules
);
186 info
->dyninfo
.ld_got
= GET_WORD (abfd
, linkinfo
.ld_got
);
187 info
->dyninfo
.ld_plt
= GET_WORD (abfd
, linkinfo
.ld_plt
);
188 info
->dyninfo
.ld_rel
= GET_WORD (abfd
, linkinfo
.ld_rel
);
189 info
->dyninfo
.ld_hash
= GET_WORD (abfd
, linkinfo
.ld_hash
);
190 info
->dyninfo
.ld_stab
= GET_WORD (abfd
, linkinfo
.ld_stab
);
191 info
->dyninfo
.ld_stab_hash
= GET_WORD (abfd
, linkinfo
.ld_stab_hash
);
192 info
->dyninfo
.ld_buckets
= GET_WORD (abfd
, linkinfo
.ld_buckets
);
193 info
->dyninfo
.ld_symbols
= GET_WORD (abfd
, linkinfo
.ld_symbols
);
194 info
->dyninfo
.ld_symb_size
= GET_WORD (abfd
, linkinfo
.ld_symb_size
);
195 info
->dyninfo
.ld_text
= GET_WORD (abfd
, linkinfo
.ld_text
);
196 info
->dyninfo
.ld_plt_sz
= GET_WORD (abfd
, linkinfo
.ld_plt_sz
);
198 /* Reportedly the addresses need to be offset by the size of the
199 exec header in an NMAGIC file. */
200 if (adata (abfd
).magic
== n_magic
)
202 unsigned long exec_bytes_size
= adata (abfd
).exec_bytes_size
;
204 info
->dyninfo
.ld_need
+= exec_bytes_size
;
205 info
->dyninfo
.ld_rules
+= exec_bytes_size
;
206 info
->dyninfo
.ld_rel
+= exec_bytes_size
;
207 info
->dyninfo
.ld_hash
+= exec_bytes_size
;
208 info
->dyninfo
.ld_stab
+= exec_bytes_size
;
209 info
->dyninfo
.ld_symbols
+= exec_bytes_size
;
212 /* The only way to get the size of the symbol information appears to
213 be to determine the distance between it and the string table. */
214 info
->dynsym_count
= ((info
->dyninfo
.ld_symbols
- info
->dyninfo
.ld_stab
)
215 / EXTERNAL_NLIST_SIZE
);
216 BFD_ASSERT (info
->dynsym_count
* EXTERNAL_NLIST_SIZE
217 == (unsigned long) (info
->dyninfo
.ld_symbols
218 - info
->dyninfo
.ld_stab
));
220 /* Similarly, the relocs end at the hash table. */
221 info
->dynrel_count
= ((info
->dyninfo
.ld_hash
- info
->dyninfo
.ld_rel
)
222 / obj_reloc_entry_size (abfd
));
223 BFD_ASSERT (info
->dynrel_count
* obj_reloc_entry_size (abfd
)
224 == (unsigned long) (info
->dyninfo
.ld_hash
225 - info
->dyninfo
.ld_rel
));
232 /* Return the amount of memory required for the dynamic symbols. */
235 sunos_get_dynamic_symtab_upper_bound (bfd
*abfd
)
237 struct sunos_dynamic_info
*info
;
239 if (! sunos_read_dynamic_info (abfd
))
242 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
245 bfd_set_error (bfd_error_no_symbols
);
249 return (info
->dynsym_count
+ 1) * sizeof (asymbol
*);
252 /* Read the external dynamic symbols. */
255 sunos_slurp_dynamic_symtab (bfd
*abfd
)
257 struct sunos_dynamic_info
*info
;
260 /* Get the general dynamic information. */
261 if (obj_aout_dynamic_info (abfd
) == NULL
)
263 if (! sunos_read_dynamic_info (abfd
))
267 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
270 bfd_set_error (bfd_error_no_symbols
);
274 /* Get the dynamic nlist structures. */
275 if (info
->dynsym
== NULL
)
277 amt
= (bfd_size_type
) info
->dynsym_count
* EXTERNAL_NLIST_SIZE
;
278 info
->dynsym
= bfd_alloc (abfd
, amt
);
279 if (info
->dynsym
== NULL
&& info
->dynsym_count
!= 0)
281 if (bfd_seek (abfd
, (file_ptr
) info
->dyninfo
.ld_stab
, SEEK_SET
) != 0
282 || bfd_bread ((void *) info
->dynsym
, amt
, abfd
) != amt
)
284 if (info
->dynsym
!= NULL
)
286 bfd_release (abfd
, info
->dynsym
);
293 /* Get the dynamic strings. */
294 if (info
->dynstr
== NULL
)
296 amt
= info
->dyninfo
.ld_symb_size
;
297 info
->dynstr
= bfd_alloc (abfd
, amt
);
298 if (info
->dynstr
== NULL
&& info
->dyninfo
.ld_symb_size
!= 0)
300 if (bfd_seek (abfd
, (file_ptr
) info
->dyninfo
.ld_symbols
, SEEK_SET
) != 0
301 || bfd_bread ((void *) info
->dynstr
, amt
, abfd
) != amt
)
303 if (info
->dynstr
!= NULL
)
305 bfd_release (abfd
, info
->dynstr
);
315 /* Read in the dynamic symbols. */
318 sunos_canonicalize_dynamic_symtab (bfd
*abfd
, asymbol
**storage
)
320 struct sunos_dynamic_info
*info
;
323 if (! sunos_slurp_dynamic_symtab (abfd
))
326 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
328 #ifdef CHECK_DYNAMIC_HASH
329 /* Check my understanding of the dynamic hash table by making sure
330 that each symbol can be located in the hash table. */
332 bfd_size_type table_size
;
336 if (info
->dyninfo
.ld_buckets
> info
->dynsym_count
)
338 table_size
= info
->dyninfo
.ld_stab
- info
->dyninfo
.ld_hash
;
339 table
= bfd_malloc (table_size
);
340 if (table
== NULL
&& table_size
!= 0)
342 if (bfd_seek (abfd
, (file_ptr
) info
->dyninfo
.ld_hash
, SEEK_SET
) != 0
343 || bfd_bread ((void *) table
, table_size
, abfd
) != table_size
)
345 for (i
= 0; i
< info
->dynsym_count
; i
++)
350 name
= ((unsigned char *) info
->dynstr
351 + GET_WORD (abfd
, info
->dynsym
[i
].e_strx
));
353 while (*name
!= '\0')
354 hash
= (hash
<< 1) + *name
++;
356 hash
%= info
->dyninfo
.ld_buckets
;
357 while (GET_WORD (abfd
, table
+ hash
* HASH_ENTRY_SIZE
) != i
)
359 hash
= GET_WORD (abfd
,
360 table
+ hash
* HASH_ENTRY_SIZE
+ BYTES_IN_WORD
);
361 if (hash
== 0 || hash
>= table_size
/ HASH_ENTRY_SIZE
)
367 #endif /* CHECK_DYNAMIC_HASH */
369 /* Get the asymbol structures corresponding to the dynamic nlist
371 if (info
->canonical_dynsym
== NULL
)
374 bfd_size_type strsize
= info
->dyninfo
.ld_symb_size
;
376 size
= (bfd_size_type
) info
->dynsym_count
* sizeof (aout_symbol_type
);
377 info
->canonical_dynsym
= bfd_alloc (abfd
, size
);
378 if (info
->canonical_dynsym
== NULL
&& info
->dynsym_count
!= 0)
381 if (! aout_32_translate_symbol_table (abfd
, info
->canonical_dynsym
,
383 (bfd_size_type
) info
->dynsym_count
,
384 info
->dynstr
, strsize
, TRUE
))
386 if (info
->canonical_dynsym
!= NULL
)
388 bfd_release (abfd
, info
->canonical_dynsym
);
389 info
->canonical_dynsym
= NULL
;
395 /* Return pointers to the dynamic asymbol structures. */
396 for (i
= 0; i
< info
->dynsym_count
; i
++)
397 *storage
++ = (asymbol
*) (info
->canonical_dynsym
+ i
);
400 return info
->dynsym_count
;
403 /* Return the amount of memory required for the dynamic relocs. */
406 sunos_get_dynamic_reloc_upper_bound (bfd
*abfd
)
408 struct sunos_dynamic_info
*info
;
410 if (! sunos_read_dynamic_info (abfd
))
413 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
416 bfd_set_error (bfd_error_no_symbols
);
420 return (info
->dynrel_count
+ 1) * sizeof (arelent
*);
423 /* Read in the dynamic relocs. */
426 sunos_canonicalize_dynamic_reloc (bfd
*abfd
, arelent
**storage
, asymbol
**syms
)
428 struct sunos_dynamic_info
*info
;
432 /* Get the general dynamic information. */
433 if (obj_aout_dynamic_info (abfd
) == NULL
)
435 if (! sunos_read_dynamic_info (abfd
))
439 info
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
442 bfd_set_error (bfd_error_no_symbols
);
446 /* Get the dynamic reloc information. */
447 if (info
->dynrel
== NULL
)
449 size
= (bfd_size_type
) info
->dynrel_count
* obj_reloc_entry_size (abfd
);
450 info
->dynrel
= bfd_alloc (abfd
, size
);
451 if (info
->dynrel
== NULL
&& size
!= 0)
453 if (bfd_seek (abfd
, (file_ptr
) info
->dyninfo
.ld_rel
, SEEK_SET
) != 0
454 || bfd_bread ((void *) info
->dynrel
, size
, abfd
) != size
)
456 if (info
->dynrel
!= NULL
)
458 bfd_release (abfd
, info
->dynrel
);
465 /* Get the arelent structures corresponding to the dynamic reloc
467 if (info
->canonical_dynrel
== NULL
)
471 size
= (bfd_size_type
) info
->dynrel_count
* sizeof (arelent
);
472 info
->canonical_dynrel
= bfd_alloc (abfd
, size
);
473 if (info
->canonical_dynrel
== NULL
&& info
->dynrel_count
!= 0)
476 to
= info
->canonical_dynrel
;
478 if (obj_reloc_entry_size (abfd
) == RELOC_EXT_SIZE
)
480 struct reloc_ext_external
*p
;
481 struct reloc_ext_external
*pend
;
483 p
= (struct reloc_ext_external
*) info
->dynrel
;
484 pend
= p
+ info
->dynrel_count
;
485 for (; p
< pend
; p
++, to
++)
486 NAME (aout
, swap_ext_reloc_in
) (abfd
, p
, to
, syms
,
487 (bfd_size_type
) info
->dynsym_count
);
491 struct reloc_std_external
*p
;
492 struct reloc_std_external
*pend
;
494 p
= (struct reloc_std_external
*) info
->dynrel
;
495 pend
= p
+ info
->dynrel_count
;
496 for (; p
< pend
; p
++, to
++)
497 NAME (aout
, swap_std_reloc_in
) (abfd
, p
, to
, syms
,
498 (bfd_size_type
) info
->dynsym_count
);
502 /* Return pointers to the dynamic arelent structures. */
503 for (i
= 0; i
< info
->dynrel_count
; i
++)
504 *storage
++ = info
->canonical_dynrel
+ i
;
507 return info
->dynrel_count
;
510 /* Code to handle linking of SunOS shared libraries. */
512 /* A SPARC procedure linkage table entry is 12 bytes. The first entry
513 in the table is a jump which is filled in by the runtime linker.
514 The remaining entries are branches back to the first entry,
515 followed by an index into the relocation table encoded to look like
518 #define SPARC_PLT_ENTRY_SIZE (12)
520 static const bfd_byte sparc_plt_first_entry
[SPARC_PLT_ENTRY_SIZE
] =
522 /* sethi %hi(0),%g1; address filled in by runtime linker. */
524 /* jmp %g1; offset filled in by runtime linker. */
530 /* save %sp, -96, %sp */
531 #define SPARC_PLT_ENTRY_WORD0 ((bfd_vma) 0x9de3bfa0)
532 /* call; address filled in later. */
533 #define SPARC_PLT_ENTRY_WORD1 ((bfd_vma) 0x40000000)
534 /* sethi; reloc index filled in later. */
535 #define SPARC_PLT_ENTRY_WORD2 ((bfd_vma) 0x01000000)
537 /* This sequence is used when for the jump table entry to a defined
538 symbol in a complete executable. It is used when linking PIC
539 compiled code which is not being put into a shared library. */
540 /* sethi <address to be filled in later>, %g1 */
541 #define SPARC_PLT_PIC_WORD0 ((bfd_vma) 0x03000000)
542 /* jmp %g1 + <address to be filled in later> */
543 #define SPARC_PLT_PIC_WORD1 ((bfd_vma) 0x81c06000)
545 #define SPARC_PLT_PIC_WORD2 ((bfd_vma) 0x01000000)
547 /* An m68k procedure linkage table entry is 8 bytes. The first entry
548 in the table is a jump which is filled in the by the runtime
549 linker. The remaining entries are branches back to the first
550 entry, followed by a two byte index into the relocation table. */
552 #define M68K_PLT_ENTRY_SIZE (8)
554 static const bfd_byte m68k_plt_first_entry
[M68K_PLT_ENTRY_SIZE
] =
558 /* Filled in by runtime linker with a magic address. */
565 #define M68K_PLT_ENTRY_WORD0 ((bfd_vma) 0x61ff)
566 /* Remaining words filled in later. */
568 /* An entry in the SunOS linker hash table. */
570 struct sunos_link_hash_entry
572 struct aout_link_hash_entry root
;
574 /* If this is a dynamic symbol, this is its index into the dynamic
575 symbol table. This is initialized to -1. As the linker looks at
576 the input files, it changes this to -2 if it will be added to the
577 dynamic symbol table. After all the input files have been seen,
578 the linker will know whether to build a dynamic symbol table; if
579 it does build one, this becomes the index into the table. */
582 /* If this is a dynamic symbol, this is the index of the name in the
583 dynamic symbol string table. */
586 /* The offset into the global offset table used for this symbol. If
587 the symbol does not require a GOT entry, this is 0. */
590 /* The offset into the procedure linkage table used for this symbol.
591 If the symbol does not require a PLT entry, this is 0. */
594 /* Some linker flags. */
596 /* Symbol is referenced by a regular object. */
597 #define SUNOS_REF_REGULAR 01
598 /* Symbol is defined by a regular object. */
599 #define SUNOS_DEF_REGULAR 02
600 /* Symbol is referenced by a dynamic object. */
601 #define SUNOS_REF_DYNAMIC 04
602 /* Symbol is defined by a dynamic object. */
603 #define SUNOS_DEF_DYNAMIC 010
604 /* Symbol is a constructor symbol in a regular object. */
605 #define SUNOS_CONSTRUCTOR 020
608 /* The SunOS linker hash table. */
610 struct sunos_link_hash_table
612 struct aout_link_hash_table root
;
614 /* The object which holds the dynamic sections. */
617 /* Whether we have created the dynamic sections. */
618 bfd_boolean dynamic_sections_created
;
620 /* Whether we need the dynamic sections. */
621 bfd_boolean dynamic_sections_needed
;
623 /* Whether we need the .got table. */
624 bfd_boolean got_needed
;
626 /* The number of dynamic symbols. */
629 /* The number of buckets in the hash table. */
632 /* The list of dynamic objects needed by dynamic objects included in
634 struct bfd_link_needed_list
*needed
;
636 /* The offset of __GLOBAL_OFFSET_TABLE_ into the .got section. */
640 /* Routine to create an entry in an SunOS link hash table. */
642 static struct bfd_hash_entry
*
643 sunos_link_hash_newfunc (struct bfd_hash_entry
*entry
,
644 struct bfd_hash_table
*table
,
647 struct sunos_link_hash_entry
*ret
= (struct sunos_link_hash_entry
*) entry
;
649 /* Allocate the structure if it has not already been allocated by a
652 ret
= bfd_hash_allocate (table
, sizeof (* ret
));
656 /* Call the allocation method of the superclass. */
657 ret
= ((struct sunos_link_hash_entry
*)
658 NAME (aout
, link_hash_newfunc
) ((struct bfd_hash_entry
*) ret
,
662 /* Set local fields. */
664 ret
->dynstr_index
= -1;
670 return (struct bfd_hash_entry
*) ret
;
673 /* Create a SunOS link hash table. */
675 static struct bfd_link_hash_table
*
676 sunos_link_hash_table_create (bfd
*abfd
)
678 struct sunos_link_hash_table
*ret
;
679 bfd_size_type amt
= sizeof (struct sunos_link_hash_table
);
681 ret
= bfd_malloc (amt
);
684 if (!NAME (aout
, link_hash_table_init
) (&ret
->root
, abfd
,
685 sunos_link_hash_newfunc
,
686 sizeof (struct sunos_link_hash_entry
)))
693 ret
->dynamic_sections_created
= FALSE
;
694 ret
->dynamic_sections_needed
= FALSE
;
695 ret
->got_needed
= FALSE
;
696 ret
->dynsymcount
= 0;
697 ret
->bucketcount
= 0;
701 return &ret
->root
.root
;
704 /* Look up an entry in an SunOS link hash table. */
706 #define sunos_link_hash_lookup(table, string, create, copy, follow) \
707 ((struct sunos_link_hash_entry *) \
708 aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
711 /* Traverse a SunOS link hash table. */
713 #define sunos_link_hash_traverse(table, func, info) \
714 (aout_link_hash_traverse \
716 (bfd_boolean (*) (struct aout_link_hash_entry *, void *)) (func), \
719 /* Get the SunOS link hash table from the info structure. This is
722 #define sunos_hash_table(p) ((struct sunos_link_hash_table *) ((p)->hash))
724 /* Create the dynamic sections needed if we are linking against a
725 dynamic object, or if we are linking PIC compiled code. ABFD is a
726 bfd we can attach the dynamic sections to. The linker script will
727 look for these special sections names and put them in the right
728 place in the output file. See include/aout/sun4.h for more details
729 of the dynamic linking information. */
732 sunos_create_dynamic_sections (bfd
*abfd
,
733 struct bfd_link_info
*info
,
738 if (! sunos_hash_table (info
)->dynamic_sections_created
)
742 sunos_hash_table (info
)->dynobj
= abfd
;
744 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
745 | SEC_LINKER_CREATED
);
747 /* The .dynamic section holds the basic dynamic information: the
748 sun4_dynamic structure, the dynamic debugger information, and
749 the sun4_dynamic_link structure. */
750 s
= bfd_make_section_with_flags (abfd
, ".dynamic", flags
);
752 || ! bfd_set_section_alignment (abfd
, s
, 2))
755 /* The .got section holds the global offset table. The address
756 is put in the ld_got field. */
757 s
= bfd_make_section_with_flags (abfd
, ".got", flags
);
759 || ! bfd_set_section_alignment (abfd
, s
, 2))
762 /* The .plt section holds the procedure linkage table. The
763 address is put in the ld_plt field. */
764 s
= bfd_make_section_with_flags (abfd
, ".plt", flags
| SEC_CODE
);
766 || ! bfd_set_section_alignment (abfd
, s
, 2))
769 /* The .dynrel section holds the dynamic relocs. The address is
770 put in the ld_rel field. */
771 s
= bfd_make_section_with_flags (abfd
, ".dynrel", flags
| SEC_READONLY
);
773 || ! bfd_set_section_alignment (abfd
, s
, 2))
776 /* The .hash section holds the dynamic hash table. The address
777 is put in the ld_hash field. */
778 s
= bfd_make_section_with_flags (abfd
, ".hash", flags
| SEC_READONLY
);
780 || ! bfd_set_section_alignment (abfd
, s
, 2))
783 /* The .dynsym section holds the dynamic symbols. The address
784 is put in the ld_stab field. */
785 s
= bfd_make_section_with_flags (abfd
, ".dynsym", flags
| SEC_READONLY
);
787 || ! bfd_set_section_alignment (abfd
, s
, 2))
790 /* The .dynstr section holds the dynamic symbol string table.
791 The address is put in the ld_symbols field. */
792 s
= bfd_make_section_with_flags (abfd
, ".dynstr", flags
| SEC_READONLY
);
794 || ! bfd_set_section_alignment (abfd
, s
, 2))
797 sunos_hash_table (info
)->dynamic_sections_created
= TRUE
;
800 if ((needed
&& ! sunos_hash_table (info
)->dynamic_sections_needed
)
805 dynobj
= sunos_hash_table (info
)->dynobj
;
807 s
= bfd_get_section_by_name (dynobj
, ".got");
809 s
->size
= BYTES_IN_WORD
;
811 sunos_hash_table (info
)->dynamic_sections_needed
= TRUE
;
812 sunos_hash_table (info
)->got_needed
= TRUE
;
818 /* Add dynamic symbols during a link. This is called by the a.out
819 backend linker for each object it encounters. */
822 sunos_add_dynamic_symbols (bfd
*abfd
,
823 struct bfd_link_info
*info
,
824 struct external_nlist
**symsp
,
825 bfd_size_type
*sym_countp
,
829 struct sunos_dynamic_info
*dinfo
;
832 /* Make sure we have all the required sections. */
833 if (info
->output_bfd
->xvec
== abfd
->xvec
)
835 if (! sunos_create_dynamic_sections (abfd
, info
,
836 ((abfd
->flags
& DYNAMIC
) != 0
837 && !info
->relocatable
)))
841 /* There is nothing else to do for a normal object. */
842 if ((abfd
->flags
& DYNAMIC
) == 0)
845 dynobj
= sunos_hash_table (info
)->dynobj
;
847 /* We do not want to include the sections in a dynamic object in the
848 output file. We hack by simply clobbering the list of sections
849 in the BFD. This could be handled more cleanly by, say, a new
850 section flag; the existing SEC_NEVER_LOAD flag is not the one we
851 want, because that one still implies that the section takes up
852 space in the output file. If this is the first object we have
853 seen, we must preserve the dynamic sections we just created. */
855 abfd
->sections
= NULL
;
860 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
862 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
863 bfd_section_list_remove (abfd
, s
);
867 /* The native linker seems to just ignore dynamic objects when -r is
869 if (info
->relocatable
)
872 /* There's no hope of using a dynamic object which does not exactly
873 match the format of the output file. */
874 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
876 bfd_set_error (bfd_error_invalid_operation
);
880 /* Make sure we have a .need and a .rules sections. These are only
881 needed if there really is a dynamic object in the link, so they
882 are not added by sunos_create_dynamic_sections. */
883 if (bfd_get_section_by_name (dynobj
, ".need") == NULL
)
885 /* The .need section holds the list of names of shared objets
886 which must be included at runtime. The address of this
887 section is put in the ld_need field. */
888 flagword flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
889 | SEC_IN_MEMORY
| SEC_READONLY
);
890 asection
*s
= bfd_make_section_with_flags (dynobj
, ".need", flags
);
892 || ! bfd_set_section_alignment (dynobj
, s
, 2))
896 if (bfd_get_section_by_name (dynobj
, ".rules") == NULL
)
898 /* The .rules section holds the path to search for shared
899 objects. The address of this section is put in the ld_rules
901 flagword flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
902 | SEC_IN_MEMORY
| SEC_READONLY
);
903 asection
*s
= bfd_make_section_with_flags (dynobj
, ".rules", flags
);
905 || ! bfd_set_section_alignment (dynobj
, s
, 2))
909 /* Pick up the dynamic symbols and return them to the caller. */
910 if (! sunos_slurp_dynamic_symtab (abfd
))
913 dinfo
= (struct sunos_dynamic_info
*) obj_aout_dynamic_info (abfd
);
914 *symsp
= dinfo
->dynsym
;
915 *sym_countp
= dinfo
->dynsym_count
;
916 *stringsp
= dinfo
->dynstr
;
918 /* Record information about any other objects needed by this one. */
919 need
= dinfo
->dyninfo
.ld_need
;
923 unsigned long name
, flags
;
924 unsigned short major_vno
, minor_vno
;
925 struct bfd_link_needed_list
*needed
, **pp
;
931 if (bfd_seek (abfd
, (file_ptr
) need
, SEEK_SET
) != 0
932 || bfd_bread (buf
, (bfd_size_type
) 16, abfd
) != 16)
935 /* For the format of an ld_need entry, see aout/sun4.h. We
936 should probably define structs for this manipulation. */
937 name
= bfd_get_32 (abfd
, buf
);
938 flags
= bfd_get_32 (abfd
, buf
+ 4);
939 major_vno
= (unsigned short) bfd_get_16 (abfd
, buf
+ 8);
940 minor_vno
= (unsigned short) bfd_get_16 (abfd
, buf
+ 10);
941 need
= bfd_get_32 (abfd
, buf
+ 12);
943 alc
= sizeof (struct bfd_link_needed_list
);
944 needed
= bfd_alloc (abfd
, alc
);
949 /* We return the name as [-l]name[.maj][.min]. */
951 namebuf
= bfd_malloc (alc
+ 1);
956 if ((flags
& 0x80000000) != 0)
961 if (bfd_seek (abfd
, (file_ptr
) name
, SEEK_SET
) != 0)
969 if (bfd_bread (&b
, (bfd_size_type
) 1, abfd
) != 1)
975 if ((bfd_size_type
) (p
- namebuf
) >= alc
)
980 n
= bfd_realloc (namebuf
, alc
+ 1);
986 p
= n
+ (p
- namebuf
);
1001 sprintf (majbuf
, ".%d", major_vno
);
1005 sprintf (minbuf
, ".%d", minor_vno
);
1007 if ((p
- namebuf
) + strlen (majbuf
) + strlen (minbuf
) >= alc
)
1011 alc
= (p
- namebuf
) + strlen (majbuf
) + strlen (minbuf
);
1012 n
= bfd_realloc (namebuf
, alc
+ 1);
1018 p
= n
+ (p
- namebuf
);
1026 namecopy
= bfd_alloc (abfd
, (bfd_size_type
) strlen (namebuf
) + 1);
1027 if (namecopy
== NULL
)
1032 strcpy (namecopy
, namebuf
);
1034 needed
->name
= namecopy
;
1036 needed
->next
= NULL
;
1038 for (pp
= &sunos_hash_table (info
)->needed
;
1048 /* Function to add a single symbol to the linker hash table. This is
1049 a wrapper around _bfd_generic_link_add_one_symbol which handles the
1050 tweaking needed for dynamic linking support. */
1053 sunos_add_one_symbol (struct bfd_link_info
*info
,
1061 bfd_boolean collect
,
1062 struct bfd_link_hash_entry
**hashp
)
1064 struct sunos_link_hash_entry
*h
;
1067 if ((flags
& (BSF_INDIRECT
| BSF_WARNING
| BSF_CONSTRUCTOR
)) != 0
1068 || ! bfd_is_und_section (section
))
1069 h
= sunos_link_hash_lookup (sunos_hash_table (info
), name
, TRUE
, copy
,
1072 h
= ((struct sunos_link_hash_entry
*)
1073 bfd_wrapped_link_hash_lookup (abfd
, info
, name
, TRUE
, copy
, FALSE
));
1078 *hashp
= (struct bfd_link_hash_entry
*) h
;
1080 /* Treat a common symbol in a dynamic object as defined in the .bss
1081 section of the dynamic object. We don't want to allocate space
1082 for it in our process image. */
1083 if ((abfd
->flags
& DYNAMIC
) != 0
1084 && bfd_is_com_section (section
))
1085 section
= obj_bsssec (abfd
);
1087 if (! bfd_is_und_section (section
)
1088 && h
->root
.root
.type
!= bfd_link_hash_new
1089 && h
->root
.root
.type
!= bfd_link_hash_undefined
1090 && h
->root
.root
.type
!= bfd_link_hash_defweak
)
1092 /* We are defining the symbol, and it is already defined. This
1093 is a potential multiple definition error. */
1094 if ((abfd
->flags
& DYNAMIC
) != 0)
1096 /* The definition we are adding is from a dynamic object.
1097 We do not want this new definition to override the
1098 existing definition, so we pretend it is just a
1100 section
= bfd_und_section_ptr
;
1102 else if (h
->root
.root
.type
== bfd_link_hash_defined
1103 && h
->root
.root
.u
.def
.section
->owner
!= NULL
1104 && (h
->root
.root
.u
.def
.section
->owner
->flags
& DYNAMIC
) != 0)
1106 /* The existing definition is from a dynamic object. We
1107 want to override it with the definition we just found.
1108 Clobber the existing definition. */
1109 h
->root
.root
.type
= bfd_link_hash_undefined
;
1110 h
->root
.root
.u
.undef
.abfd
= h
->root
.root
.u
.def
.section
->owner
;
1112 else if (h
->root
.root
.type
== bfd_link_hash_common
1113 && (h
->root
.root
.u
.c
.p
->section
->owner
->flags
& DYNAMIC
) != 0)
1115 /* The existing definition is from a dynamic object. We
1116 want to override it with the definition we just found.
1117 Clobber the existing definition. We can't set it to new,
1118 because it is on the undefined list. */
1119 h
->root
.root
.type
= bfd_link_hash_undefined
;
1120 h
->root
.root
.u
.undef
.abfd
= h
->root
.root
.u
.c
.p
->section
->owner
;
1124 if ((abfd
->flags
& DYNAMIC
) != 0
1125 && abfd
->xvec
== info
->output_bfd
->xvec
1126 && (h
->flags
& SUNOS_CONSTRUCTOR
) != 0)
1127 /* The existing symbol is a constructor symbol, and this symbol
1128 is from a dynamic object. A constructor symbol is actually a
1129 definition, although the type will be bfd_link_hash_undefined
1130 at this point. We want to ignore the definition from the
1132 section
= bfd_und_section_ptr
;
1133 else if ((flags
& BSF_CONSTRUCTOR
) != 0
1134 && (abfd
->flags
& DYNAMIC
) == 0
1135 && h
->root
.root
.type
== bfd_link_hash_defined
1136 && h
->root
.root
.u
.def
.section
->owner
!= NULL
1137 && (h
->root
.root
.u
.def
.section
->owner
->flags
& DYNAMIC
) != 0)
1138 /* The existing symbol is defined by a dynamic object, and this
1139 is a constructor symbol. As above, we want to force the use
1140 of the constructor symbol from the regular object. */
1141 h
->root
.root
.type
= bfd_link_hash_new
;
1143 /* Do the usual procedure for adding a symbol. */
1144 if (! _bfd_generic_link_add_one_symbol (info
, abfd
, name
, flags
, section
,
1145 value
, string
, copy
, collect
,
1149 if (abfd
->xvec
== info
->output_bfd
->xvec
)
1151 /* Set a flag in the hash table entry indicating the type of
1152 reference or definition we just found. Keep a count of the
1153 number of dynamic symbols we find. A dynamic symbol is one
1154 which is referenced or defined by both a regular object and a
1156 if ((abfd
->flags
& DYNAMIC
) == 0)
1158 if (bfd_is_und_section (section
))
1159 new_flag
= SUNOS_REF_REGULAR
;
1161 new_flag
= SUNOS_DEF_REGULAR
;
1165 if (bfd_is_und_section (section
))
1166 new_flag
= SUNOS_REF_DYNAMIC
;
1168 new_flag
= SUNOS_DEF_DYNAMIC
;
1170 h
->flags
|= new_flag
;
1172 if (h
->dynindx
== -1
1173 && (h
->flags
& (SUNOS_DEF_REGULAR
| SUNOS_REF_REGULAR
)) != 0)
1175 ++sunos_hash_table (info
)->dynsymcount
;
1179 if ((flags
& BSF_CONSTRUCTOR
) != 0
1180 && (abfd
->flags
& DYNAMIC
) == 0)
1181 h
->flags
|= SUNOS_CONSTRUCTOR
;
1187 extern const bfd_target
MY (vec
);
1189 /* Return the list of objects needed by BFD. */
1191 struct bfd_link_needed_list
*
1192 bfd_sunos_get_needed_list (bfd
*abfd ATTRIBUTE_UNUSED
,
1193 struct bfd_link_info
*info
)
1195 if (info
->output_bfd
->xvec
!= &MY (vec
))
1197 return sunos_hash_table (info
)->needed
;
1200 /* Record an assignment made to a symbol by a linker script. We need
1201 this in case some dynamic object refers to this symbol. */
1204 bfd_sunos_record_link_assignment (bfd
*output_bfd
,
1205 struct bfd_link_info
*info
,
1208 struct sunos_link_hash_entry
*h
;
1210 if (output_bfd
->xvec
!= &MY(vec
))
1213 /* This is called after we have examined all the input objects. If
1214 the symbol does not exist, it merely means that no object refers
1215 to it, and we can just ignore it at this point. */
1216 h
= sunos_link_hash_lookup (sunos_hash_table (info
), name
,
1217 FALSE
, FALSE
, FALSE
);
1221 /* In a shared library, the __DYNAMIC symbol does not appear in the
1222 dynamic symbol table. */
1223 if (! info
->shared
|| strcmp (name
, "__DYNAMIC") != 0)
1225 h
->flags
|= SUNOS_DEF_REGULAR
;
1227 if (h
->dynindx
== -1)
1229 ++sunos_hash_table (info
)->dynsymcount
;
1237 /* Scan the relocs for an input section using standard relocs. We
1238 need to figure out what to do for each reloc against a dynamic
1239 symbol. If the symbol is in the .text section, an entry is made in
1240 the procedure linkage table. Note that this will do the wrong
1241 thing if the symbol is actually data; I don't think the Sun 3
1242 native linker handles this case correctly either. If the symbol is
1243 not in the .text section, we must preserve the reloc as a dynamic
1244 reloc. FIXME: We should also handle the PIC relocs here by
1245 building global offset table entries. */
1248 sunos_scan_std_relocs (struct bfd_link_info
*info
,
1250 asection
*sec ATTRIBUTE_UNUSED
,
1251 const struct reloc_std_external
*relocs
,
1252 bfd_size_type rel_size
)
1255 asection
*splt
= NULL
;
1256 asection
*srel
= NULL
;
1257 struct sunos_link_hash_entry
**sym_hashes
;
1258 const struct reloc_std_external
*rel
, *relend
;
1260 /* We only know how to handle m68k plt entries. */
1261 if (bfd_get_arch (abfd
) != bfd_arch_m68k
)
1263 bfd_set_error (bfd_error_invalid_target
);
1269 sym_hashes
= (struct sunos_link_hash_entry
**) obj_aout_sym_hashes (abfd
);
1271 relend
= relocs
+ rel_size
/ RELOC_STD_SIZE
;
1272 for (rel
= relocs
; rel
< relend
; rel
++)
1275 struct sunos_link_hash_entry
*h
;
1277 /* We only want relocs against external symbols. */
1278 if (bfd_header_big_endian (abfd
))
1280 if ((rel
->r_type
[0] & RELOC_STD_BITS_EXTERN_BIG
) == 0)
1285 if ((rel
->r_type
[0] & RELOC_STD_BITS_EXTERN_LITTLE
) == 0)
1289 /* Get the symbol index. */
1290 if (bfd_header_big_endian (abfd
))
1291 r_index
= ((rel
->r_index
[0] << 16)
1292 | (rel
->r_index
[1] << 8)
1295 r_index
= ((rel
->r_index
[2] << 16)
1296 | (rel
->r_index
[1] << 8)
1299 /* Get the hash table entry. */
1300 h
= sym_hashes
[r_index
];
1302 /* This should not normally happen, but it will in any case
1303 be caught in the relocation phase. */
1306 /* At this point common symbols have already been allocated, so
1307 we don't have to worry about them. We need to consider that
1308 we may have already seen this symbol and marked it undefined;
1309 if the symbol is really undefined, then SUNOS_DEF_DYNAMIC
1311 if (h
->root
.root
.type
!= bfd_link_hash_defined
1312 && h
->root
.root
.type
!= bfd_link_hash_defweak
1313 && h
->root
.root
.type
!= bfd_link_hash_undefined
)
1316 if ((h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
1317 || (h
->flags
& SUNOS_DEF_REGULAR
) != 0)
1324 if (! sunos_create_dynamic_sections (abfd
, info
, FALSE
))
1326 dynobj
= sunos_hash_table (info
)->dynobj
;
1327 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1328 srel
= bfd_get_section_by_name (dynobj
, ".dynrel");
1329 BFD_ASSERT (splt
!= NULL
&& srel
!= NULL
);
1331 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1332 BFD_ASSERT (sgot
!= NULL
);
1333 if (sgot
->size
== 0)
1334 sgot
->size
= BYTES_IN_WORD
;
1335 sunos_hash_table (info
)->got_needed
= TRUE
;
1338 BFD_ASSERT ((h
->flags
& SUNOS_REF_REGULAR
) != 0);
1339 BFD_ASSERT (h
->plt_offset
!= 0
1340 || ((h
->root
.root
.type
== bfd_link_hash_defined
1341 || h
->root
.root
.type
== bfd_link_hash_defweak
)
1342 ? (h
->root
.root
.u
.def
.section
->owner
->flags
1344 : (h
->root
.root
.u
.undef
.abfd
->flags
& DYNAMIC
) != 0));
1346 /* This reloc is against a symbol defined only by a dynamic
1348 if (h
->root
.root
.type
== bfd_link_hash_undefined
)
1349 /* Presumably this symbol was marked as being undefined by
1350 an earlier reloc. */
1351 srel
->size
+= RELOC_STD_SIZE
;
1352 else if ((h
->root
.root
.u
.def
.section
->flags
& SEC_CODE
) == 0)
1356 /* This reloc is not in the .text section. It must be
1357 copied into the dynamic relocs. We mark the symbol as
1359 srel
->size
+= RELOC_STD_SIZE
;
1360 sub
= h
->root
.root
.u
.def
.section
->owner
;
1361 h
->root
.root
.type
= bfd_link_hash_undefined
;
1362 h
->root
.root
.u
.undef
.abfd
= sub
;
1366 /* This symbol is in the .text section. We must give it an
1367 entry in the procedure linkage table, if we have not
1368 already done so. We change the definition of the symbol
1369 to the .plt section; this will cause relocs against it to
1370 be handled correctly. */
1371 if (h
->plt_offset
== 0)
1373 if (splt
->size
== 0)
1374 splt
->size
= M68K_PLT_ENTRY_SIZE
;
1375 h
->plt_offset
= splt
->size
;
1377 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1379 h
->root
.root
.u
.def
.section
= splt
;
1380 h
->root
.root
.u
.def
.value
= splt
->size
;
1383 splt
->size
+= M68K_PLT_ENTRY_SIZE
;
1385 /* We may also need a dynamic reloc entry. */
1386 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1387 srel
->size
+= RELOC_STD_SIZE
;
1395 /* Scan the relocs for an input section using extended relocs. We
1396 need to figure out what to do for each reloc against a dynamic
1397 symbol. If the reloc is a WDISP30, and the symbol is in the .text
1398 section, an entry is made in the procedure linkage table.
1399 Otherwise, we must preserve the reloc as a dynamic reloc. */
1402 sunos_scan_ext_relocs (struct bfd_link_info
*info
,
1404 asection
*sec ATTRIBUTE_UNUSED
,
1405 const struct reloc_ext_external
*relocs
,
1406 bfd_size_type rel_size
)
1409 struct sunos_link_hash_entry
**sym_hashes
;
1410 const struct reloc_ext_external
*rel
, *relend
;
1411 asection
*splt
= NULL
;
1412 asection
*sgot
= NULL
;
1413 asection
*srel
= NULL
;
1416 /* We only know how to handle SPARC plt entries. */
1417 if (bfd_get_arch (abfd
) != bfd_arch_sparc
)
1419 bfd_set_error (bfd_error_invalid_target
);
1425 sym_hashes
= (struct sunos_link_hash_entry
**) obj_aout_sym_hashes (abfd
);
1427 relend
= relocs
+ rel_size
/ RELOC_EXT_SIZE
;
1428 for (rel
= relocs
; rel
< relend
; rel
++)
1430 unsigned int r_index
;
1433 struct sunos_link_hash_entry
*h
= NULL
;
1435 /* Swap in the reloc information. */
1436 if (bfd_header_big_endian (abfd
))
1438 r_index
= ((rel
->r_index
[0] << 16)
1439 | (rel
->r_index
[1] << 8)
1441 r_extern
= (0 != (rel
->r_type
[0] & RELOC_EXT_BITS_EXTERN_BIG
));
1442 r_type
= ((rel
->r_type
[0] & RELOC_EXT_BITS_TYPE_BIG
)
1443 >> RELOC_EXT_BITS_TYPE_SH_BIG
);
1447 r_index
= ((rel
->r_index
[2] << 16)
1448 | (rel
->r_index
[1] << 8)
1450 r_extern
= (0 != (rel
->r_type
[0] & RELOC_EXT_BITS_EXTERN_LITTLE
));
1451 r_type
= ((rel
->r_type
[0] & RELOC_EXT_BITS_TYPE_LITTLE
)
1452 >> RELOC_EXT_BITS_TYPE_SH_LITTLE
);
1457 h
= sym_hashes
[r_index
];
1460 /* This should not normally happen, but it will in any
1461 case be caught in the relocation phase. */
1466 /* If this is a base relative reloc, we need to make an entry in
1467 the .got section. */
1468 if (r_type
== RELOC_BASE10
1469 || r_type
== RELOC_BASE13
1470 || r_type
== RELOC_BASE22
)
1474 if (! sunos_create_dynamic_sections (abfd
, info
, FALSE
))
1476 dynobj
= sunos_hash_table (info
)->dynobj
;
1477 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1478 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1479 srel
= bfd_get_section_by_name (dynobj
, ".dynrel");
1480 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
1482 /* Make sure we have an initial entry in the .got table. */
1483 if (sgot
->size
== 0)
1484 sgot
->size
= BYTES_IN_WORD
;
1485 sunos_hash_table (info
)->got_needed
= TRUE
;
1490 if (h
->got_offset
!= 0)
1493 h
->got_offset
= sgot
->size
;
1497 if (r_index
>= bfd_get_symcount (abfd
))
1498 /* This is abnormal, but should be caught in the
1499 relocation phase. */
1502 if (adata (abfd
).local_got_offsets
== NULL
)
1504 amt
= bfd_get_symcount (abfd
);
1505 amt
*= sizeof (bfd_vma
);
1506 adata (abfd
).local_got_offsets
= bfd_zalloc (abfd
, amt
);
1507 if (adata (abfd
).local_got_offsets
== NULL
)
1511 if (adata (abfd
).local_got_offsets
[r_index
] != 0)
1514 adata (abfd
).local_got_offsets
[r_index
] = sgot
->size
;
1517 sgot
->size
+= BYTES_IN_WORD
;
1519 /* If we are making a shared library, or if the symbol is
1520 defined by a dynamic object, we will need a dynamic reloc
1524 && (h
->flags
& SUNOS_DEF_DYNAMIC
) != 0
1525 && (h
->flags
& SUNOS_DEF_REGULAR
) == 0))
1526 srel
->size
+= RELOC_EXT_SIZE
;
1531 /* Otherwise, we are only interested in relocs against symbols
1532 defined in dynamic objects but not in regular objects. We
1533 only need to consider relocs against external symbols. */
1536 /* But, if we are creating a shared library, we need to
1537 generate an absolute reloc. */
1542 if (! sunos_create_dynamic_sections (abfd
, info
, TRUE
))
1544 dynobj
= sunos_hash_table (info
)->dynobj
;
1545 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1546 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1547 srel
= bfd_get_section_by_name (dynobj
, ".dynrel");
1548 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
1551 srel
->size
+= RELOC_EXT_SIZE
;
1557 /* At this point common symbols have already been allocated, so
1558 we don't have to worry about them. We need to consider that
1559 we may have already seen this symbol and marked it undefined;
1560 if the symbol is really undefined, then SUNOS_DEF_DYNAMIC
1562 if (h
->root
.root
.type
!= bfd_link_hash_defined
1563 && h
->root
.root
.type
!= bfd_link_hash_defweak
1564 && h
->root
.root
.type
!= bfd_link_hash_undefined
)
1567 if (r_type
!= RELOC_JMP_TBL
1569 && ((h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
1570 || (h
->flags
& SUNOS_DEF_REGULAR
) != 0))
1573 if (r_type
== RELOC_JMP_TBL
1575 && (h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
1576 && (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1578 /* This symbol is apparently undefined. Don't do anything
1579 here; just let the relocation routine report an undefined
1584 if (strcmp (h
->root
.root
.root
.string
, "__GLOBAL_OFFSET_TABLE_") == 0)
1589 if (! sunos_create_dynamic_sections (abfd
, info
, FALSE
))
1591 dynobj
= sunos_hash_table (info
)->dynobj
;
1592 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1593 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1594 srel
= bfd_get_section_by_name (dynobj
, ".dynrel");
1595 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
1597 /* Make sure we have an initial entry in the .got table. */
1598 if (sgot
->size
== 0)
1599 sgot
->size
= BYTES_IN_WORD
;
1600 sunos_hash_table (info
)->got_needed
= TRUE
;
1603 BFD_ASSERT (r_type
== RELOC_JMP_TBL
1605 || (h
->flags
& SUNOS_REF_REGULAR
) != 0);
1606 BFD_ASSERT (r_type
== RELOC_JMP_TBL
1608 || h
->plt_offset
!= 0
1609 || ((h
->root
.root
.type
== bfd_link_hash_defined
1610 || h
->root
.root
.type
== bfd_link_hash_defweak
)
1611 ? (h
->root
.root
.u
.def
.section
->owner
->flags
1613 : (h
->root
.root
.u
.undef
.abfd
->flags
& DYNAMIC
) != 0));
1615 /* This reloc is against a symbol defined only by a dynamic
1616 object, or it is a jump table reloc from PIC compiled code. */
1618 if (r_type
!= RELOC_JMP_TBL
1619 && h
->root
.root
.type
== bfd_link_hash_undefined
)
1620 /* Presumably this symbol was marked as being undefined by
1621 an earlier reloc. */
1622 srel
->size
+= RELOC_EXT_SIZE
;
1624 else if (r_type
!= RELOC_JMP_TBL
1625 && (h
->root
.root
.u
.def
.section
->flags
& SEC_CODE
) == 0)
1629 /* This reloc is not in the .text section. It must be
1630 copied into the dynamic relocs. We mark the symbol as
1632 srel
->size
+= RELOC_EXT_SIZE
;
1633 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1635 sub
= h
->root
.root
.u
.def
.section
->owner
;
1636 h
->root
.root
.type
= bfd_link_hash_undefined
;
1637 h
->root
.root
.u
.undef
.abfd
= sub
;
1642 /* This symbol is in the .text section. We must give it an
1643 entry in the procedure linkage table, if we have not
1644 already done so. We change the definition of the symbol
1645 to the .plt section; this will cause relocs against it to
1646 be handled correctly. */
1647 if (h
->plt_offset
== 0)
1649 if (splt
->size
== 0)
1650 splt
->size
= SPARC_PLT_ENTRY_SIZE
;
1651 h
->plt_offset
= splt
->size
;
1653 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1655 if (h
->root
.root
.type
== bfd_link_hash_undefined
)
1656 h
->root
.root
.type
= bfd_link_hash_defined
;
1657 h
->root
.root
.u
.def
.section
= splt
;
1658 h
->root
.root
.u
.def
.value
= splt
->size
;
1661 splt
->size
+= SPARC_PLT_ENTRY_SIZE
;
1663 /* We will also need a dynamic reloc entry, unless this
1664 is a JMP_TBL reloc produced by linking PIC compiled
1665 code, and we are not making a shared library. */
1666 if (info
->shared
|| (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
1667 srel
->size
+= RELOC_EXT_SIZE
;
1670 /* If we are creating a shared library, we need to copy over
1671 any reloc other than a jump table reloc. */
1672 if (info
->shared
&& r_type
!= RELOC_JMP_TBL
)
1673 srel
->size
+= RELOC_EXT_SIZE
;
1680 /* Scan the relocs for an input section. */
1683 sunos_scan_relocs (struct bfd_link_info
*info
,
1686 bfd_size_type rel_size
)
1689 void * free_relocs
= NULL
;
1694 if (! info
->keep_memory
)
1695 relocs
= free_relocs
= bfd_malloc (rel_size
);
1698 struct aout_section_data_struct
*n
;
1699 bfd_size_type amt
= sizeof (struct aout_section_data_struct
);
1701 n
= bfd_alloc (abfd
, amt
);
1706 set_aout_section_data (sec
, n
);
1707 relocs
= bfd_malloc (rel_size
);
1708 aout_section_data (sec
)->relocs
= relocs
;
1714 if (bfd_seek (abfd
, sec
->rel_filepos
, SEEK_SET
) != 0
1715 || bfd_bread (relocs
, rel_size
, abfd
) != rel_size
)
1718 if (obj_reloc_entry_size (abfd
) == RELOC_STD_SIZE
)
1720 if (! sunos_scan_std_relocs (info
, abfd
, sec
,
1721 (struct reloc_std_external
*) relocs
,
1727 if (! sunos_scan_ext_relocs (info
, abfd
, sec
,
1728 (struct reloc_ext_external
*) relocs
,
1733 if (free_relocs
!= NULL
)
1739 if (free_relocs
!= NULL
)
1744 /* Build the hash table of dynamic symbols, and to mark as written all
1745 symbols from dynamic objects which we do not plan to write out. */
1748 sunos_scan_dynamic_symbol (struct sunos_link_hash_entry
*h
, void * data
)
1750 struct bfd_link_info
*info
= (struct bfd_link_info
*) data
;
1752 /* Set the written flag for symbols we do not want to write out as
1753 part of the regular symbol table. This is all symbols which are
1754 not defined in a regular object file. For some reason symbols
1755 which are referenced by a regular object and defined by a dynamic
1756 object do not seem to show up in the regular symbol table. It is
1757 possible for a symbol to have only SUNOS_REF_REGULAR set here, it
1758 is an undefined symbol which was turned into a common symbol
1759 because it was found in an archive object which was not included
1761 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0
1762 && (h
->flags
& SUNOS_DEF_DYNAMIC
) != 0
1763 && strcmp (h
->root
.root
.root
.string
, "__DYNAMIC") != 0)
1764 h
->root
.written
= TRUE
;
1766 /* If this symbol is defined by a dynamic object and referenced by a
1767 regular object, see whether we gave it a reasonable value while
1768 scanning the relocs. */
1769 if ((h
->flags
& SUNOS_DEF_REGULAR
) == 0
1770 && (h
->flags
& SUNOS_DEF_DYNAMIC
) != 0
1771 && (h
->flags
& SUNOS_REF_REGULAR
) != 0)
1773 if ((h
->root
.root
.type
== bfd_link_hash_defined
1774 || h
->root
.root
.type
== bfd_link_hash_defweak
)
1775 && ((h
->root
.root
.u
.def
.section
->owner
->flags
& DYNAMIC
) != 0)
1776 && h
->root
.root
.u
.def
.section
->output_section
== NULL
)
1780 /* This symbol is currently defined in a dynamic section
1781 which is not being put into the output file. This
1782 implies that there is no reloc against the symbol. I'm
1783 not sure why this case would ever occur. In any case, we
1784 change the symbol to be undefined. */
1785 sub
= h
->root
.root
.u
.def
.section
->owner
;
1786 h
->root
.root
.type
= bfd_link_hash_undefined
;
1787 h
->root
.root
.u
.undef
.abfd
= sub
;
1791 /* If this symbol is defined or referenced by a regular file, add it
1792 to the dynamic symbols. */
1793 if ((h
->flags
& (SUNOS_DEF_REGULAR
| SUNOS_REF_REGULAR
)) != 0)
1798 unsigned char *name
;
1802 BFD_ASSERT (h
->dynindx
== -2);
1804 dynobj
= sunos_hash_table (info
)->dynobj
;
1806 h
->dynindx
= sunos_hash_table (info
)->dynsymcount
;
1807 ++sunos_hash_table (info
)->dynsymcount
;
1809 len
= strlen (h
->root
.root
.root
.string
);
1811 /* We don't bother to construct a BFD hash table for the strings
1812 which are the names of the dynamic symbols. Using a hash
1813 table for the regular symbols is beneficial, because the
1814 regular symbols includes the debugging symbols, which have
1815 long names and are often duplicated in several object files.
1816 There are no debugging symbols in the dynamic symbols. */
1817 s
= bfd_get_section_by_name (dynobj
, ".dynstr");
1818 BFD_ASSERT (s
!= NULL
);
1819 contents
= bfd_realloc (s
->contents
, s
->size
+ len
+ 1);
1820 if (contents
== NULL
)
1822 s
->contents
= contents
;
1824 h
->dynstr_index
= s
->size
;
1825 strcpy ((char *) contents
+ s
->size
, h
->root
.root
.root
.string
);
1828 /* Add it to the dynamic hash table. */
1829 name
= (unsigned char *) h
->root
.root
.root
.string
;
1831 while (*name
!= '\0')
1832 hash
= (hash
<< 1) + *name
++;
1834 hash
%= sunos_hash_table (info
)->bucketcount
;
1836 s
= bfd_get_section_by_name (dynobj
, ".hash");
1837 BFD_ASSERT (s
!= NULL
);
1839 if (GET_SWORD (dynobj
, s
->contents
+ hash
* HASH_ENTRY_SIZE
) == -1)
1840 PUT_WORD (dynobj
, h
->dynindx
, s
->contents
+ hash
* HASH_ENTRY_SIZE
);
1845 next
= GET_WORD (dynobj
,
1847 + hash
* HASH_ENTRY_SIZE
1849 PUT_WORD (dynobj
, s
->size
/ HASH_ENTRY_SIZE
,
1850 s
->contents
+ hash
* HASH_ENTRY_SIZE
+ BYTES_IN_WORD
);
1851 PUT_WORD (dynobj
, h
->dynindx
, s
->contents
+ s
->size
);
1852 PUT_WORD (dynobj
, next
, s
->contents
+ s
->size
+ BYTES_IN_WORD
);
1853 s
->size
+= HASH_ENTRY_SIZE
;
1860 /* Set up the sizes and contents of the dynamic sections created in
1861 sunos_add_dynamic_symbols. This is called by the SunOS linker
1862 emulation before_allocation routine. We must set the sizes of the
1863 sections before the linker sets the addresses of the various
1864 sections. This unfortunately requires reading all the relocs so
1865 that we can work out which ones need to become dynamic relocs. If
1866 info->keep_memory is TRUE, we keep the relocs in memory; otherwise,
1867 we discard them, and will read them again later. */
1870 bfd_sunos_size_dynamic_sections (bfd
*output_bfd
,
1871 struct bfd_link_info
*info
,
1873 asection
**sneedptr
,
1874 asection
**srulesptr
)
1877 bfd_size_type dynsymcount
;
1878 struct sunos_link_hash_entry
*h
;
1881 bfd_size_type hashalloc
;
1889 if (info
->relocatable
)
1892 if (output_bfd
->xvec
!= &MY(vec
))
1895 /* Look through all the input BFD's and read their relocs. It would
1896 be better if we didn't have to do this, but there is no other way
1897 to determine the number of dynamic relocs we need, and, more
1898 importantly, there is no other way to know which symbols should
1899 get an entry in the procedure linkage table. */
1900 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
1902 if ((sub
->flags
& DYNAMIC
) == 0
1903 && sub
->xvec
== output_bfd
->xvec
)
1905 if (! sunos_scan_relocs (info
, sub
, obj_textsec (sub
),
1906 exec_hdr (sub
)->a_trsize
)
1907 || ! sunos_scan_relocs (info
, sub
, obj_datasec (sub
),
1908 exec_hdr (sub
)->a_drsize
))
1913 dynobj
= sunos_hash_table (info
)->dynobj
;
1914 dynsymcount
= sunos_hash_table (info
)->dynsymcount
;
1916 /* If there were no dynamic objects in the link, and we don't need
1917 to build a global offset table, there is nothing to do here. */
1918 if (! sunos_hash_table (info
)->dynamic_sections_needed
1919 && ! sunos_hash_table (info
)->got_needed
)
1922 /* If __GLOBAL_OFFSET_TABLE_ was mentioned, define it. */
1923 h
= sunos_link_hash_lookup (sunos_hash_table (info
),
1924 "__GLOBAL_OFFSET_TABLE_", FALSE
, FALSE
, FALSE
);
1925 if (h
!= NULL
&& (h
->flags
& SUNOS_REF_REGULAR
) != 0)
1927 h
->flags
|= SUNOS_DEF_REGULAR
;
1928 if (h
->dynindx
== -1)
1930 ++sunos_hash_table (info
)->dynsymcount
;
1933 h
->root
.root
.type
= bfd_link_hash_defined
;
1934 h
->root
.root
.u
.def
.section
= bfd_get_section_by_name (dynobj
, ".got");
1936 /* If the .got section is more than 0x1000 bytes, we set
1937 __GLOBAL_OFFSET_TABLE_ to be 0x1000 bytes into the section,
1938 so that 13 bit relocations have a greater chance of working. */
1939 s
= bfd_get_section_by_name (dynobj
, ".got");
1940 BFD_ASSERT (s
!= NULL
);
1941 if (s
->size
>= 0x1000)
1942 h
->root
.root
.u
.def
.value
= 0x1000;
1944 h
->root
.root
.u
.def
.value
= 0;
1946 sunos_hash_table (info
)->got_base
= h
->root
.root
.u
.def
.value
;
1949 /* If there are any shared objects in the link, then we need to set
1950 up the dynamic linking information. */
1951 if (sunos_hash_table (info
)->dynamic_sections_needed
)
1953 *sdynptr
= bfd_get_section_by_name (dynobj
, ".dynamic");
1955 /* The .dynamic section is always the same size. */
1957 BFD_ASSERT (s
!= NULL
);
1958 s
->size
= (sizeof (struct external_sun4_dynamic
)
1959 + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE
1960 + sizeof (struct external_sun4_dynamic_link
));
1962 /* Set the size of the .dynsym and .hash sections. We counted
1963 the number of dynamic symbols as we read the input files. We
1964 will build the dynamic symbol table (.dynsym) and the hash
1965 table (.hash) when we build the final symbol table, because
1966 until then we do not know the correct value to give the
1967 symbols. We build the dynamic symbol string table (.dynstr)
1968 in a traversal of the symbol table using
1969 sunos_scan_dynamic_symbol. */
1970 s
= bfd_get_section_by_name (dynobj
, ".dynsym");
1971 BFD_ASSERT (s
!= NULL
);
1972 s
->size
= dynsymcount
* sizeof (struct external_nlist
);
1973 s
->contents
= bfd_alloc (output_bfd
, s
->size
);
1974 if (s
->contents
== NULL
&& s
->size
!= 0)
1977 /* The number of buckets is just the number of symbols divided
1978 by four. To compute the final size of the hash table, we
1979 must actually compute the hash table. Normally we need
1980 exactly as many entries in the hash table as there are
1981 dynamic symbols, but if some of the buckets are not used we
1982 will need additional entries. In the worst case, every
1983 symbol will hash to the same bucket, and we will need
1984 BUCKETCOUNT - 1 extra entries. */
1985 if (dynsymcount
>= 4)
1986 bucketcount
= dynsymcount
/ 4;
1987 else if (dynsymcount
> 0)
1988 bucketcount
= dynsymcount
;
1991 s
= bfd_get_section_by_name (dynobj
, ".hash");
1992 BFD_ASSERT (s
!= NULL
);
1993 hashalloc
= (dynsymcount
+ bucketcount
- 1) * HASH_ENTRY_SIZE
;
1994 s
->contents
= bfd_zalloc (dynobj
, hashalloc
);
1995 if (s
->contents
== NULL
&& dynsymcount
> 0)
1997 for (i
= 0; i
< bucketcount
; i
++)
1998 PUT_WORD (output_bfd
, (bfd_vma
) -1, s
->contents
+ i
* HASH_ENTRY_SIZE
);
1999 s
->size
= bucketcount
* HASH_ENTRY_SIZE
;
2001 sunos_hash_table (info
)->bucketcount
= bucketcount
;
2003 /* Scan all the symbols, place them in the dynamic symbol table,
2004 and build the dynamic hash table. We reuse dynsymcount as a
2005 counter for the number of symbols we have added so far. */
2006 sunos_hash_table (info
)->dynsymcount
= 0;
2007 sunos_link_hash_traverse (sunos_hash_table (info
),
2008 sunos_scan_dynamic_symbol
,
2010 BFD_ASSERT (sunos_hash_table (info
)->dynsymcount
== dynsymcount
);
2012 /* The SunOS native linker seems to align the total size of the
2013 symbol strings to a multiple of 8. I don't know if this is
2014 important, but it can't hurt much. */
2015 s
= bfd_get_section_by_name (dynobj
, ".dynstr");
2016 BFD_ASSERT (s
!= NULL
);
2017 if ((s
->size
& 7) != 0)
2022 add
= 8 - (s
->size
& 7);
2023 contents
= bfd_realloc (s
->contents
, s
->size
+ add
);
2024 if (contents
== NULL
)
2026 memset (contents
+ s
->size
, 0, (size_t) add
);
2027 s
->contents
= contents
;
2032 /* Now that we have worked out the sizes of the procedure linkage
2033 table and the dynamic relocs, allocate storage for them. */
2034 s
= bfd_get_section_by_name (dynobj
, ".plt");
2035 BFD_ASSERT (s
!= NULL
);
2038 s
->contents
= bfd_alloc (dynobj
, s
->size
);
2039 if (s
->contents
== NULL
)
2042 /* Fill in the first entry in the table. */
2043 switch (bfd_get_arch (dynobj
))
2045 case bfd_arch_sparc
:
2046 memcpy (s
->contents
, sparc_plt_first_entry
, SPARC_PLT_ENTRY_SIZE
);
2050 memcpy (s
->contents
, m68k_plt_first_entry
, M68K_PLT_ENTRY_SIZE
);
2058 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2061 s
->contents
= bfd_alloc (dynobj
, s
->size
);
2062 if (s
->contents
== NULL
)
2065 /* We use the reloc_count field to keep track of how many of the
2066 relocs we have output so far. */
2069 /* Make space for the global offset table. */
2070 s
= bfd_get_section_by_name (dynobj
, ".got");
2071 s
->contents
= bfd_alloc (dynobj
, s
->size
);
2072 if (s
->contents
== NULL
)
2075 *sneedptr
= bfd_get_section_by_name (dynobj
, ".need");
2076 *srulesptr
= bfd_get_section_by_name (dynobj
, ".rules");
2081 /* Link a dynamic object. We actually don't have anything to do at
2082 this point. This entry point exists to prevent the regular linker
2083 code from doing anything with the object. */
2086 sunos_link_dynamic_object (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
2087 bfd
*abfd ATTRIBUTE_UNUSED
)
2092 /* Write out a dynamic symbol. This is called by the final traversal
2093 over the symbol table. */
2096 sunos_write_dynamic_symbol (bfd
*output_bfd
,
2097 struct bfd_link_info
*info
,
2098 struct aout_link_hash_entry
*harg
)
2100 struct sunos_link_hash_entry
*h
= (struct sunos_link_hash_entry
*) harg
;
2104 struct external_nlist
*outsym
;
2106 /* If this symbol is in the procedure linkage table, fill in the
2108 if (h
->plt_offset
!= 0)
2115 dynobj
= sunos_hash_table (info
)->dynobj
;
2116 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2117 p
= splt
->contents
+ h
->plt_offset
;
2119 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2121 r_address
= (splt
->output_section
->vma
2122 + splt
->output_offset
2125 switch (bfd_get_arch (output_bfd
))
2127 case bfd_arch_sparc
:
2128 if (info
->shared
|| (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
2130 bfd_put_32 (output_bfd
, SPARC_PLT_ENTRY_WORD0
, p
);
2131 bfd_put_32 (output_bfd
,
2132 (SPARC_PLT_ENTRY_WORD1
2133 + (((- (h
->plt_offset
+ 4) >> 2)
2136 bfd_put_32 (output_bfd
, SPARC_PLT_ENTRY_WORD2
+ s
->reloc_count
,
2141 val
= (h
->root
.root
.u
.def
.section
->output_section
->vma
2142 + h
->root
.root
.u
.def
.section
->output_offset
2143 + h
->root
.root
.u
.def
.value
);
2144 bfd_put_32 (output_bfd
,
2145 SPARC_PLT_PIC_WORD0
+ ((val
>> 10) & 0x3fffff),
2147 bfd_put_32 (output_bfd
,
2148 SPARC_PLT_PIC_WORD1
+ (val
& 0x3ff),
2150 bfd_put_32 (output_bfd
, SPARC_PLT_PIC_WORD2
, p
+ 8);
2155 if (! info
->shared
&& (h
->flags
& SUNOS_DEF_REGULAR
) != 0)
2157 bfd_put_16 (output_bfd
, M68K_PLT_ENTRY_WORD0
, p
);
2158 bfd_put_32 (output_bfd
, (- (h
->plt_offset
+ 2)), p
+ 2);
2159 bfd_put_16 (output_bfd
, (bfd_vma
) s
->reloc_count
, p
+ 6);
2167 /* We also need to add a jump table reloc, unless this is the
2168 result of a JMP_TBL reloc from PIC compiled code. */
2169 if (info
->shared
|| (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
2171 BFD_ASSERT (h
->dynindx
>= 0);
2172 BFD_ASSERT (s
->reloc_count
* obj_reloc_entry_size (dynobj
)
2174 p
= s
->contents
+ s
->reloc_count
* obj_reloc_entry_size (output_bfd
);
2175 if (obj_reloc_entry_size (output_bfd
) == RELOC_STD_SIZE
)
2177 struct reloc_std_external
*srel
;
2179 srel
= (struct reloc_std_external
*) p
;
2180 PUT_WORD (output_bfd
, r_address
, srel
->r_address
);
2181 if (bfd_header_big_endian (output_bfd
))
2183 srel
->r_index
[0] = (bfd_byte
) (h
->dynindx
>> 16);
2184 srel
->r_index
[1] = (bfd_byte
) (h
->dynindx
>> 8);
2185 srel
->r_index
[2] = (bfd_byte
) (h
->dynindx
);
2186 srel
->r_type
[0] = (RELOC_STD_BITS_EXTERN_BIG
2187 | RELOC_STD_BITS_JMPTABLE_BIG
);
2191 srel
->r_index
[2] = (bfd_byte
) (h
->dynindx
>> 16);
2192 srel
->r_index
[1] = (bfd_byte
) (h
->dynindx
>> 8);
2193 srel
->r_index
[0] = (bfd_byte
)h
->dynindx
;
2194 srel
->r_type
[0] = (RELOC_STD_BITS_EXTERN_LITTLE
2195 | RELOC_STD_BITS_JMPTABLE_LITTLE
);
2200 struct reloc_ext_external
*erel
;
2202 erel
= (struct reloc_ext_external
*) p
;
2203 PUT_WORD (output_bfd
, r_address
, erel
->r_address
);
2204 if (bfd_header_big_endian (output_bfd
))
2206 erel
->r_index
[0] = (bfd_byte
) (h
->dynindx
>> 16);
2207 erel
->r_index
[1] = (bfd_byte
) (h
->dynindx
>> 8);
2208 erel
->r_index
[2] = (bfd_byte
)h
->dynindx
;
2210 (RELOC_EXT_BITS_EXTERN_BIG
2211 | (RELOC_JMP_SLOT
<< RELOC_EXT_BITS_TYPE_SH_BIG
));
2215 erel
->r_index
[2] = (bfd_byte
) (h
->dynindx
>> 16);
2216 erel
->r_index
[1] = (bfd_byte
) (h
->dynindx
>> 8);
2217 erel
->r_index
[0] = (bfd_byte
)h
->dynindx
;
2219 (RELOC_EXT_BITS_EXTERN_LITTLE
2220 | (RELOC_JMP_SLOT
<< RELOC_EXT_BITS_TYPE_SH_LITTLE
));
2222 PUT_WORD (output_bfd
, (bfd_vma
) 0, erel
->r_addend
);
2229 /* If this is not a dynamic symbol, we don't have to do anything
2230 else. We only check this after handling the PLT entry, because
2231 we can have a PLT entry for a nondynamic symbol when linking PIC
2232 compiled code from a regular object. */
2236 switch (h
->root
.root
.type
)
2239 case bfd_link_hash_new
:
2241 /* Avoid variable not initialized warnings. */
2243 case bfd_link_hash_undefined
:
2244 type
= N_UNDF
| N_EXT
;
2247 case bfd_link_hash_defined
:
2248 case bfd_link_hash_defweak
:
2251 asection
*output_section
;
2253 sec
= h
->root
.root
.u
.def
.section
;
2254 output_section
= sec
->output_section
;
2255 BFD_ASSERT (bfd_is_abs_section (output_section
)
2256 || output_section
->owner
== output_bfd
);
2257 if (h
->plt_offset
!= 0
2258 && (h
->flags
& SUNOS_DEF_REGULAR
) == 0)
2260 type
= N_UNDF
| N_EXT
;
2265 if (output_section
== obj_textsec (output_bfd
))
2266 type
= (h
->root
.root
.type
== bfd_link_hash_defined
2269 else if (output_section
== obj_datasec (output_bfd
))
2270 type
= (h
->root
.root
.type
== bfd_link_hash_defined
2273 else if (output_section
== obj_bsssec (output_bfd
))
2274 type
= (h
->root
.root
.type
== bfd_link_hash_defined
2278 type
= (h
->root
.root
.type
== bfd_link_hash_defined
2282 val
= (h
->root
.root
.u
.def
.value
2283 + output_section
->vma
2284 + sec
->output_offset
);
2288 case bfd_link_hash_common
:
2289 type
= N_UNDF
| N_EXT
;
2290 val
= h
->root
.root
.u
.c
.size
;
2292 case bfd_link_hash_undefweak
:
2296 case bfd_link_hash_indirect
:
2297 case bfd_link_hash_warning
:
2298 /* FIXME: Ignore these for now. The circumstances under which
2299 they should be written out are not clear to me. */
2303 s
= bfd_get_section_by_name (sunos_hash_table (info
)->dynobj
, ".dynsym");
2304 BFD_ASSERT (s
!= NULL
);
2305 outsym
= ((struct external_nlist
*)
2306 (s
->contents
+ h
->dynindx
* EXTERNAL_NLIST_SIZE
));
2308 H_PUT_8 (output_bfd
, type
, outsym
->e_type
);
2309 H_PUT_8 (output_bfd
, 0, outsym
->e_other
);
2311 /* FIXME: The native linker doesn't use 0 for desc. It seems to use
2312 one less than the desc value in the shared library, although that
2314 H_PUT_16 (output_bfd
, 0, outsym
->e_desc
);
2316 PUT_WORD (output_bfd
, h
->dynstr_index
, outsym
->e_strx
);
2317 PUT_WORD (output_bfd
, val
, outsym
->e_value
);
2322 /* This is called for each reloc against an external symbol. If this
2323 is a reloc which are are going to copy as a dynamic reloc, then
2324 copy it over, and tell the caller to not bother processing this
2328 sunos_check_dynamic_reloc (struct bfd_link_info
*info
,
2330 asection
*input_section
,
2331 struct aout_link_hash_entry
*harg
,
2333 bfd_byte
*contents ATTRIBUTE_UNUSED
,
2335 bfd_vma
*relocationp
)
2337 struct sunos_link_hash_entry
*h
= (struct sunos_link_hash_entry
*) harg
;
2339 bfd_boolean baserel
;
2348 dynobj
= sunos_hash_table (info
)->dynobj
;
2351 && h
->plt_offset
!= 0
2353 || (h
->flags
& SUNOS_DEF_REGULAR
) == 0))
2357 /* Redirect the relocation to the PLT entry. */
2358 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2359 *relocationp
= (splt
->output_section
->vma
2360 + splt
->output_offset
2364 if (obj_reloc_entry_size (input_bfd
) == RELOC_STD_SIZE
)
2366 struct reloc_std_external
*srel
;
2368 srel
= (struct reloc_std_external
*) reloc
;
2369 if (bfd_header_big_endian (input_bfd
))
2371 baserel
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_BASEREL_BIG
));
2372 jmptbl
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_JMPTABLE_BIG
));
2373 pcrel
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_PCREL_BIG
));
2377 baserel
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_BASEREL_LITTLE
));
2378 jmptbl
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_JMPTABLE_LITTLE
));
2379 pcrel
= (0 != (srel
->r_type
[0] & RELOC_STD_BITS_PCREL_LITTLE
));
2384 struct reloc_ext_external
*erel
;
2387 erel
= (struct reloc_ext_external
*) reloc
;
2388 if (bfd_header_big_endian (input_bfd
))
2389 r_type
= ((erel
->r_type
[0] & RELOC_EXT_BITS_TYPE_BIG
)
2390 >> RELOC_EXT_BITS_TYPE_SH_BIG
);
2392 r_type
= ((erel
->r_type
[0] & RELOC_EXT_BITS_TYPE_LITTLE
)
2393 >> RELOC_EXT_BITS_TYPE_SH_LITTLE
);
2394 baserel
= (r_type
== RELOC_BASE10
2395 || r_type
== RELOC_BASE13
2396 || r_type
== RELOC_BASE22
);
2397 jmptbl
= r_type
== RELOC_JMP_TBL
;
2398 pcrel
= (r_type
== RELOC_DISP8
2399 || r_type
== RELOC_DISP16
2400 || r_type
== RELOC_DISP32
2401 || r_type
== RELOC_WDISP30
2402 || r_type
== RELOC_WDISP22
);
2403 /* We don't consider the PC10 and PC22 types to be PC relative,
2404 because they are pcrel_offset. */
2409 bfd_vma
*got_offsetp
;
2413 got_offsetp
= &h
->got_offset
;
2414 else if (adata (input_bfd
).local_got_offsets
== NULL
)
2418 struct reloc_std_external
*srel
;
2421 srel
= (struct reloc_std_external
*) reloc
;
2422 if (obj_reloc_entry_size (input_bfd
) == RELOC_STD_SIZE
)
2424 if (bfd_header_big_endian (input_bfd
))
2425 r_index
= ((srel
->r_index
[0] << 16)
2426 | (srel
->r_index
[1] << 8)
2427 | srel
->r_index
[2]);
2429 r_index
= ((srel
->r_index
[2] << 16)
2430 | (srel
->r_index
[1] << 8)
2431 | srel
->r_index
[0]);
2435 struct reloc_ext_external
*erel
;
2437 erel
= (struct reloc_ext_external
*) reloc
;
2438 if (bfd_header_big_endian (input_bfd
))
2439 r_index
= ((erel
->r_index
[0] << 16)
2440 | (erel
->r_index
[1] << 8)
2441 | erel
->r_index
[2]);
2443 r_index
= ((erel
->r_index
[2] << 16)
2444 | (erel
->r_index
[1] << 8)
2445 | erel
->r_index
[0]);
2448 got_offsetp
= adata (input_bfd
).local_got_offsets
+ r_index
;
2451 BFD_ASSERT (got_offsetp
!= NULL
&& *got_offsetp
!= 0);
2453 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2455 /* We set the least significant bit to indicate whether we have
2456 already initialized the GOT entry. */
2457 if ((*got_offsetp
& 1) == 0)
2461 && ((h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
2462 || (h
->flags
& SUNOS_DEF_REGULAR
) != 0)))
2463 PUT_WORD (dynobj
, *relocationp
, sgot
->contents
+ *got_offsetp
);
2465 PUT_WORD (dynobj
, 0, sgot
->contents
+ *got_offsetp
);
2469 && (h
->flags
& SUNOS_DEF_DYNAMIC
) != 0
2470 && (h
->flags
& SUNOS_DEF_REGULAR
) == 0))
2472 /* We need to create a GLOB_DAT or 32 reloc to tell the
2473 dynamic linker to fill in this entry in the table. */
2475 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2476 BFD_ASSERT (s
!= NULL
);
2477 BFD_ASSERT (s
->reloc_count
* obj_reloc_entry_size (dynobj
)
2481 + s
->reloc_count
* obj_reloc_entry_size (dynobj
));
2488 if (obj_reloc_entry_size (dynobj
) == RELOC_STD_SIZE
)
2490 struct reloc_std_external
*srel
;
2492 srel
= (struct reloc_std_external
*) p
;
2495 + sgot
->output_section
->vma
2496 + sgot
->output_offset
),
2498 if (bfd_header_big_endian (dynobj
))
2500 srel
->r_index
[0] = (bfd_byte
) (indx
>> 16);
2501 srel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2502 srel
->r_index
[2] = (bfd_byte
)indx
;
2504 srel
->r_type
[0] = 2 << RELOC_STD_BITS_LENGTH_SH_BIG
;
2507 (RELOC_STD_BITS_EXTERN_BIG
2508 | RELOC_STD_BITS_BASEREL_BIG
2509 | RELOC_STD_BITS_RELATIVE_BIG
2510 | (2 << RELOC_STD_BITS_LENGTH_SH_BIG
));
2514 srel
->r_index
[2] = (bfd_byte
) (indx
>> 16);
2515 srel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2516 srel
->r_index
[0] = (bfd_byte
)indx
;
2518 srel
->r_type
[0] = 2 << RELOC_STD_BITS_LENGTH_SH_LITTLE
;
2521 (RELOC_STD_BITS_EXTERN_LITTLE
2522 | RELOC_STD_BITS_BASEREL_LITTLE
2523 | RELOC_STD_BITS_RELATIVE_LITTLE
2524 | (2 << RELOC_STD_BITS_LENGTH_SH_LITTLE
));
2529 struct reloc_ext_external
*erel
;
2531 erel
= (struct reloc_ext_external
*) p
;
2534 + sgot
->output_section
->vma
2535 + sgot
->output_offset
),
2537 if (bfd_header_big_endian (dynobj
))
2539 erel
->r_index
[0] = (bfd_byte
) (indx
>> 16);
2540 erel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2541 erel
->r_index
[2] = (bfd_byte
)indx
;
2544 RELOC_32
<< RELOC_EXT_BITS_TYPE_SH_BIG
;
2547 (RELOC_EXT_BITS_EXTERN_BIG
2548 | (RELOC_GLOB_DAT
<< RELOC_EXT_BITS_TYPE_SH_BIG
));
2552 erel
->r_index
[2] = (bfd_byte
) (indx
>> 16);
2553 erel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2554 erel
->r_index
[0] = (bfd_byte
)indx
;
2557 RELOC_32
<< RELOC_EXT_BITS_TYPE_SH_LITTLE
;
2560 (RELOC_EXT_BITS_EXTERN_LITTLE
2562 << RELOC_EXT_BITS_TYPE_SH_LITTLE
));
2564 PUT_WORD (dynobj
, 0, erel
->r_addend
);
2573 *relocationp
= (sgot
->vma
2574 + (*got_offsetp
&~ (bfd_vma
) 1)
2575 - sunos_hash_table (info
)->got_base
);
2577 /* There is nothing else to do for a base relative reloc. */
2581 if (! sunos_hash_table (info
)->dynamic_sections_needed
)
2587 || h
->root
.root
.type
!= bfd_link_hash_undefined
2588 || (h
->flags
& SUNOS_DEF_REGULAR
) != 0
2589 || (h
->flags
& SUNOS_DEF_DYNAMIC
) == 0
2590 || (h
->root
.root
.u
.undef
.abfd
->flags
& DYNAMIC
) == 0)
2596 && (h
->dynindx
== -1
2598 || strcmp (h
->root
.root
.root
.string
,
2599 "__GLOBAL_OFFSET_TABLE_") == 0))
2603 /* It looks like this is a reloc we are supposed to copy. */
2605 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2606 BFD_ASSERT (s
!= NULL
);
2607 BFD_ASSERT (s
->reloc_count
* obj_reloc_entry_size (dynobj
) < s
->size
);
2609 p
= s
->contents
+ s
->reloc_count
* obj_reloc_entry_size (dynobj
);
2611 /* Copy the reloc over. */
2612 memcpy (p
, reloc
, obj_reloc_entry_size (dynobj
));
2619 /* Adjust the address and symbol index. */
2620 if (obj_reloc_entry_size (dynobj
) == RELOC_STD_SIZE
)
2622 struct reloc_std_external
*srel
;
2624 srel
= (struct reloc_std_external
*) p
;
2626 (GET_WORD (dynobj
, srel
->r_address
)
2627 + input_section
->output_section
->vma
2628 + input_section
->output_offset
),
2630 if (bfd_header_big_endian (dynobj
))
2632 srel
->r_index
[0] = (bfd_byte
) (indx
>> 16);
2633 srel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2634 srel
->r_index
[2] = (bfd_byte
)indx
;
2638 srel
->r_index
[2] = (bfd_byte
) (indx
>> 16);
2639 srel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2640 srel
->r_index
[0] = (bfd_byte
)indx
;
2642 /* FIXME: We may have to change the addend for a PC relative
2647 struct reloc_ext_external
*erel
;
2649 erel
= (struct reloc_ext_external
*) p
;
2651 (GET_WORD (dynobj
, erel
->r_address
)
2652 + input_section
->output_section
->vma
2653 + input_section
->output_offset
),
2655 if (bfd_header_big_endian (dynobj
))
2657 erel
->r_index
[0] = (bfd_byte
) (indx
>> 16);
2658 erel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2659 erel
->r_index
[2] = (bfd_byte
)indx
;
2663 erel
->r_index
[2] = (bfd_byte
) (indx
>> 16);
2664 erel
->r_index
[1] = (bfd_byte
) (indx
>> 8);
2665 erel
->r_index
[0] = (bfd_byte
)indx
;
2667 if (pcrel
&& h
!= NULL
)
2669 /* Adjust the addend for the change in address. */
2671 (GET_WORD (dynobj
, erel
->r_addend
)
2672 - (input_section
->output_section
->vma
2673 + input_section
->output_offset
2674 - input_section
->vma
)),
2687 /* Finish up the dynamic linking information. */
2690 sunos_finish_dynamic_link (bfd
*abfd
, struct bfd_link_info
*info
)
2697 if (! sunos_hash_table (info
)->dynamic_sections_needed
2698 && ! sunos_hash_table (info
)->got_needed
)
2701 dynobj
= sunos_hash_table (info
)->dynobj
;
2703 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
2704 BFD_ASSERT (sdyn
!= NULL
);
2706 /* Finish up the .need section. The linker emulation code filled it
2707 in, but with offsets from the start of the section instead of
2708 real addresses. Now that we know the section location, we can
2709 fill in the final values. */
2710 s
= bfd_get_section_by_name (dynobj
, ".need");
2711 if (s
!= NULL
&& s
->size
!= 0)
2716 filepos
= s
->output_section
->filepos
+ s
->output_offset
;
2722 PUT_WORD (dynobj
, GET_WORD (dynobj
, p
) + filepos
, p
);
2723 val
= GET_WORD (dynobj
, p
+ 12);
2726 PUT_WORD (dynobj
, val
+ filepos
, p
+ 12);
2731 /* The first entry in the .got section is the address of the
2732 dynamic information, unless this is a shared library. */
2733 s
= bfd_get_section_by_name (dynobj
, ".got");
2734 BFD_ASSERT (s
!= NULL
);
2735 if (info
->shared
|| sdyn
->size
== 0)
2736 PUT_WORD (dynobj
, 0, s
->contents
);
2738 PUT_WORD (dynobj
, sdyn
->output_section
->vma
+ sdyn
->output_offset
,
2741 for (o
= dynobj
->sections
; o
!= NULL
; o
= o
->next
)
2743 if ((o
->flags
& SEC_HAS_CONTENTS
) != 0
2744 && o
->contents
!= NULL
)
2746 BFD_ASSERT (o
->output_section
!= NULL
2747 && o
->output_section
->owner
== abfd
);
2748 if (! bfd_set_section_contents (abfd
, o
->output_section
,
2750 (file_ptr
) o
->output_offset
,
2758 struct external_sun4_dynamic esd
;
2759 struct external_sun4_dynamic_link esdl
;
2762 /* Finish up the dynamic link information. */
2763 PUT_WORD (dynobj
, (bfd_vma
) 3, esd
.ld_version
);
2765 sdyn
->output_section
->vma
+ sdyn
->output_offset
+ sizeof esd
,
2768 (sdyn
->output_section
->vma
2769 + sdyn
->output_offset
2771 + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE
),
2774 if (! bfd_set_section_contents (abfd
, sdyn
->output_section
, &esd
,
2775 (file_ptr
) sdyn
->output_offset
,
2776 (bfd_size_type
) sizeof esd
))
2779 PUT_WORD (dynobj
, (bfd_vma
) 0, esdl
.ld_loaded
);
2781 s
= bfd_get_section_by_name (dynobj
, ".need");
2782 if (s
== NULL
|| s
->size
== 0)
2783 PUT_WORD (dynobj
, (bfd_vma
) 0, esdl
.ld_need
);
2785 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2788 s
= bfd_get_section_by_name (dynobj
, ".rules");
2789 if (s
== NULL
|| s
->size
== 0)
2790 PUT_WORD (dynobj
, (bfd_vma
) 0, esdl
.ld_rules
);
2792 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2795 s
= bfd_get_section_by_name (dynobj
, ".got");
2796 BFD_ASSERT (s
!= NULL
);
2797 PUT_WORD (dynobj
, s
->output_section
->vma
+ s
->output_offset
,
2800 s
= bfd_get_section_by_name (dynobj
, ".plt");
2801 BFD_ASSERT (s
!= NULL
);
2802 PUT_WORD (dynobj
, s
->output_section
->vma
+ s
->output_offset
,
2804 PUT_WORD (dynobj
, s
->size
, esdl
.ld_plt_sz
);
2806 s
= bfd_get_section_by_name (dynobj
, ".dynrel");
2807 BFD_ASSERT (s
!= NULL
);
2808 BFD_ASSERT (s
->reloc_count
* obj_reloc_entry_size (dynobj
)
2810 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2813 s
= bfd_get_section_by_name (dynobj
, ".hash");
2814 BFD_ASSERT (s
!= NULL
);
2815 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2818 s
= bfd_get_section_by_name (dynobj
, ".dynsym");
2819 BFD_ASSERT (s
!= NULL
);
2820 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2823 PUT_WORD (dynobj
, (bfd_vma
) 0, esdl
.ld_stab_hash
);
2825 PUT_WORD (dynobj
, (bfd_vma
) sunos_hash_table (info
)->bucketcount
,
2828 s
= bfd_get_section_by_name (dynobj
, ".dynstr");
2829 BFD_ASSERT (s
!= NULL
);
2830 PUT_WORD (dynobj
, s
->output_section
->filepos
+ s
->output_offset
,
2832 PUT_WORD (dynobj
, s
->size
, esdl
.ld_symb_size
);
2834 /* The size of the text area is the size of the .text section
2835 rounded up to a page boundary. FIXME: Should the page size be
2836 conditional on something? */
2838 BFD_ALIGN (obj_textsec (abfd
)->size
, 0x2000),
2841 pos
= sdyn
->output_offset
;
2842 pos
+= sizeof esd
+ EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE
;
2843 if (! bfd_set_section_contents (abfd
, sdyn
->output_section
, &esdl
,
2844 pos
, (bfd_size_type
) sizeof esdl
))
2847 abfd
->flags
|= DYNAMIC
;