Deleted Added
full compact
sunos.c (84865) sunos.c (89857)
1/* BFD backend for SunOS binaries.
1/* BFD backend for SunOS binaries.
2 Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000
2 Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000, 2001,
3 2002
3 Free Software Foundation, Inc.
4 Written by Cygnus Support.
5
6This file is part of BFD, the Binary File Descriptor library.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or

--- 4 unchanged lines hidden (view full) ---

15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22#define TARGETNAME "a.out-sunos-big"
4 Free Software Foundation, Inc.
5 Written by Cygnus Support.
6
7This file is part of BFD, the Binary File Descriptor library.
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or

--- 4 unchanged lines hidden (view full) ---

16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23#define TARGETNAME "a.out-sunos-big"
23#define MY(OP) CAT(sunos_big_,OP)
24
24
25/* Do not "beautify" the CONCAT* macro args. Traditional C will not
26 remove whitespace added here, and thus will fail to concatenate
27 the tokens. */
28#define MY(OP) CONCAT2 (sunos_big_,OP)
29
25#include "bfd.h"
26#include "bfdlink.h"
27#include "libaout.h"
28
29/* Static routines defined in this file. */
30
31static boolean sunos_read_dynamic_info PARAMS ((bfd *));
32static long sunos_get_dynamic_symtab_upper_bound PARAMS ((bfd *));

--- 104 unchanged lines hidden (view full) ---

137 bfd *abfd;
138{
139 struct sunos_dynamic_info *info;
140 asection *dynsec;
141 bfd_vma dynoff;
142 struct external_sun4_dynamic dyninfo;
143 unsigned long dynver;
144 struct external_sun4_dynamic_link linkinfo;
30#include "bfd.h"
31#include "bfdlink.h"
32#include "libaout.h"
33
34/* Static routines defined in this file. */
35
36static boolean sunos_read_dynamic_info PARAMS ((bfd *));
37static long sunos_get_dynamic_symtab_upper_bound PARAMS ((bfd *));

--- 104 unchanged lines hidden (view full) ---

142 bfd *abfd;
143{
144 struct sunos_dynamic_info *info;
145 asection *dynsec;
146 bfd_vma dynoff;
147 struct external_sun4_dynamic dyninfo;
148 unsigned long dynver;
149 struct external_sun4_dynamic_link linkinfo;
150 bfd_size_type amt;
145
146 if (obj_aout_dynamic_info (abfd) != (PTR) NULL)
147 return true;
148
149 if ((abfd->flags & DYNAMIC) == 0)
150 {
151 bfd_set_error (bfd_error_invalid_operation);
152 return false;
153 }
154
151
152 if (obj_aout_dynamic_info (abfd) != (PTR) NULL)
153 return true;
154
155 if ((abfd->flags & DYNAMIC) == 0)
156 {
157 bfd_set_error (bfd_error_invalid_operation);
158 return false;
159 }
160
155 info = ((struct sunos_dynamic_info *)
156 bfd_zalloc (abfd, sizeof (struct sunos_dynamic_info)));
161 amt = sizeof (struct sunos_dynamic_info);
162 info = (struct sunos_dynamic_info *) bfd_zalloc (abfd, amt);
157 if (!info)
158 return false;
159 info->valid = false;
160 info->dynsym = NULL;
161 info->dynstr = NULL;
162 info->canonical_dynsym = NULL;
163 info->dynrel = NULL;
164 info->canonical_dynrel = NULL;

--- 4 unchanged lines hidden (view full) ---

169 However this inhibits recovering the dynamic symbols from a
170 stripped object file, so blindly assume that the dynamic linking
171 information is located at the start of the data section.
172 We could verify this assumption later by looking through the dynamic
173 symbols for the __DYNAMIC symbol. */
174 if ((abfd->flags & DYNAMIC) == 0)
175 return true;
176 if (! bfd_get_section_contents (abfd, obj_datasec (abfd), (PTR) &dyninfo,
163 if (!info)
164 return false;
165 info->valid = false;
166 info->dynsym = NULL;
167 info->dynstr = NULL;
168 info->canonical_dynsym = NULL;
169 info->dynrel = NULL;
170 info->canonical_dynrel = NULL;

--- 4 unchanged lines hidden (view full) ---

175 However this inhibits recovering the dynamic symbols from a
176 stripped object file, so blindly assume that the dynamic linking
177 information is located at the start of the data section.
178 We could verify this assumption later by looking through the dynamic
179 symbols for the __DYNAMIC symbol. */
180 if ((abfd->flags & DYNAMIC) == 0)
181 return true;
182 if (! bfd_get_section_contents (abfd, obj_datasec (abfd), (PTR) &dyninfo,
177 (file_ptr) 0, sizeof dyninfo))
183 (file_ptr) 0,
184 (bfd_size_type) sizeof dyninfo))
178 return true;
179
180 dynver = GET_WORD (abfd, dyninfo.ld_version);
181 if (dynver != 2 && dynver != 3)
182 return true;
183
184 dynoff = GET_WORD (abfd, dyninfo.ld);
185

--- 4 unchanged lines hidden (view full) ---

190 else
191 dynsec = obj_datasec (abfd);
192 dynoff -= bfd_get_section_vma (abfd, dynsec);
193 if (dynoff > bfd_section_size (abfd, dynsec))
194 return true;
195
196 /* This executable appears to be dynamically linked in a way that we
197 can understand. */
185 return true;
186
187 dynver = GET_WORD (abfd, dyninfo.ld_version);
188 if (dynver != 2 && dynver != 3)
189 return true;
190
191 dynoff = GET_WORD (abfd, dyninfo.ld);
192

--- 4 unchanged lines hidden (view full) ---

197 else
198 dynsec = obj_datasec (abfd);
199 dynoff -= bfd_get_section_vma (abfd, dynsec);
200 if (dynoff > bfd_section_size (abfd, dynsec))
201 return true;
202
203 /* This executable appears to be dynamically linked in a way that we
204 can understand. */
198 if (! bfd_get_section_contents (abfd, dynsec, (PTR) &linkinfo, dynoff,
205 if (! bfd_get_section_contents (abfd, dynsec, (PTR) &linkinfo,
206 (file_ptr) dynoff,
199 (bfd_size_type) sizeof linkinfo))
200 return true;
201
202 /* Swap in the dynamic link information. */
203 info->dyninfo.ld_loaded = GET_WORD (abfd, linkinfo.ld_loaded);
204 info->dyninfo.ld_need = GET_WORD (abfd, linkinfo.ld_need);
205 info->dyninfo.ld_rules = GET_WORD (abfd, linkinfo.ld_rules);
206 info->dyninfo.ld_got = GET_WORD (abfd, linkinfo.ld_got);

--- 65 unchanged lines hidden (view full) ---

272
273/* Read the external dynamic symbols. */
274
275static boolean
276sunos_slurp_dynamic_symtab (abfd)
277 bfd *abfd;
278{
279 struct sunos_dynamic_info *info;
207 (bfd_size_type) sizeof linkinfo))
208 return true;
209
210 /* Swap in the dynamic link information. */
211 info->dyninfo.ld_loaded = GET_WORD (abfd, linkinfo.ld_loaded);
212 info->dyninfo.ld_need = GET_WORD (abfd, linkinfo.ld_need);
213 info->dyninfo.ld_rules = GET_WORD (abfd, linkinfo.ld_rules);
214 info->dyninfo.ld_got = GET_WORD (abfd, linkinfo.ld_got);

--- 65 unchanged lines hidden (view full) ---

280
281/* Read the external dynamic symbols. */
282
283static boolean
284sunos_slurp_dynamic_symtab (abfd)
285 bfd *abfd;
286{
287 struct sunos_dynamic_info *info;
288 bfd_size_type amt;
280
281 /* Get the general dynamic information. */
282 if (obj_aout_dynamic_info (abfd) == NULL)
283 {
284 if (! sunos_read_dynamic_info (abfd))
285 return false;
286 }
287
288 info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
289 if (! info->valid)
290 {
291 bfd_set_error (bfd_error_no_symbols);
292 return false;
293 }
294
295 /* Get the dynamic nlist structures. */
296 if (info->dynsym == (struct external_nlist *) NULL)
297 {
289
290 /* Get the general dynamic information. */
291 if (obj_aout_dynamic_info (abfd) == NULL)
292 {
293 if (! sunos_read_dynamic_info (abfd))
294 return false;
295 }
296
297 info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
298 if (! info->valid)
299 {
300 bfd_set_error (bfd_error_no_symbols);
301 return false;
302 }
303
304 /* Get the dynamic nlist structures. */
305 if (info->dynsym == (struct external_nlist *) NULL)
306 {
298 info->dynsym = ((struct external_nlist *)
299 bfd_alloc (abfd,
300 (info->dynsym_count
301 * EXTERNAL_NLIST_SIZE)));
307 amt = (bfd_size_type) info->dynsym_count * EXTERNAL_NLIST_SIZE;
308 info->dynsym = (struct external_nlist *) bfd_alloc (abfd, amt);
302 if (info->dynsym == NULL && info->dynsym_count != 0)
303 return false;
309 if (info->dynsym == NULL && info->dynsym_count != 0)
310 return false;
304 if (bfd_seek (abfd, info->dyninfo.ld_stab, SEEK_SET) != 0
305 || (bfd_read ((PTR) info->dynsym, info->dynsym_count,
306 EXTERNAL_NLIST_SIZE, abfd)
307 != info->dynsym_count * EXTERNAL_NLIST_SIZE))
311 if (bfd_seek (abfd, (file_ptr) info->dyninfo.ld_stab, SEEK_SET) != 0
312 || bfd_bread ((PTR) info->dynsym, amt, abfd) != amt)
308 {
309 if (info->dynsym != NULL)
310 {
311 bfd_release (abfd, info->dynsym);
312 info->dynsym = NULL;
313 }
314 return false;
315 }
316 }
317
318 /* Get the dynamic strings. */
319 if (info->dynstr == (char *) NULL)
320 {
313 {
314 if (info->dynsym != NULL)
315 {
316 bfd_release (abfd, info->dynsym);
317 info->dynsym = NULL;
318 }
319 return false;
320 }
321 }
322
323 /* Get the dynamic strings. */
324 if (info->dynstr == (char *) NULL)
325 {
321 info->dynstr = (char *) bfd_alloc (abfd, info->dyninfo.ld_symb_size);
326 amt = info->dyninfo.ld_symb_size;
327 info->dynstr = (char *) bfd_alloc (abfd, amt);
322 if (info->dynstr == NULL && info->dyninfo.ld_symb_size != 0)
323 return false;
328 if (info->dynstr == NULL && info->dyninfo.ld_symb_size != 0)
329 return false;
324 if (bfd_seek (abfd, info->dyninfo.ld_symbols, SEEK_SET) != 0
325 || (bfd_read ((PTR) info->dynstr, 1, info->dyninfo.ld_symb_size,
326 abfd)
327 != info->dyninfo.ld_symb_size))
330 if (bfd_seek (abfd, (file_ptr) info->dyninfo.ld_symbols, SEEK_SET) != 0
331 || bfd_bread ((PTR) info->dynstr, amt, abfd) != amt)
328 {
329 if (info->dynstr != NULL)
330 {
331 bfd_release (abfd, info->dynstr);
332 info->dynstr = NULL;
333 }
334 return false;
335 }

--- 26 unchanged lines hidden (view full) ---

362 bfd_size_type i;
363
364 if (info->dyninfo.ld_buckets > info->dynsym_count)
365 abort ();
366 table_size = info->dyninfo.ld_stab - info->dyninfo.ld_hash;
367 table = (bfd_byte *) bfd_malloc (table_size);
368 if (table == NULL && table_size != 0)
369 abort ();
332 {
333 if (info->dynstr != NULL)
334 {
335 bfd_release (abfd, info->dynstr);
336 info->dynstr = NULL;
337 }
338 return false;
339 }

--- 26 unchanged lines hidden (view full) ---

366 bfd_size_type i;
367
368 if (info->dyninfo.ld_buckets > info->dynsym_count)
369 abort ();
370 table_size = info->dyninfo.ld_stab - info->dyninfo.ld_hash;
371 table = (bfd_byte *) bfd_malloc (table_size);
372 if (table == NULL && table_size != 0)
373 abort ();
370 if (bfd_seek (abfd, info->dyninfo.ld_hash, SEEK_SET) != 0
371 || bfd_read ((PTR) table, 1, table_size, abfd) != table_size)
374 if (bfd_seek (abfd, (file_ptr) info->dyninfo.ld_hash, SEEK_SET) != 0
375 || bfd_bread ((PTR) table, table_size, abfd) != table_size)
372 abort ();
373 for (i = 0; i < info->dynsym_count; i++)
374 {
375 unsigned char *name;
376 unsigned long hash;
377
378 name = ((unsigned char *) info->dynstr
379 + GET_WORD (abfd, info->dynsym[i].e_strx));

--- 13 unchanged lines hidden (view full) ---

393 free (table);
394 }
395#endif /* CHECK_DYNAMIC_HASH */
396
397 /* Get the asymbol structures corresponding to the dynamic nlist
398 structures. */
399 if (info->canonical_dynsym == (aout_symbol_type *) NULL)
400 {
376 abort ();
377 for (i = 0; i < info->dynsym_count; i++)
378 {
379 unsigned char *name;
380 unsigned long hash;
381
382 name = ((unsigned char *) info->dynstr
383 + GET_WORD (abfd, info->dynsym[i].e_strx));

--- 13 unchanged lines hidden (view full) ---

397 free (table);
398 }
399#endif /* CHECK_DYNAMIC_HASH */
400
401 /* Get the asymbol structures corresponding to the dynamic nlist
402 structures. */
403 if (info->canonical_dynsym == (aout_symbol_type *) NULL)
404 {
401 info->canonical_dynsym = ((aout_symbol_type *)
402 bfd_alloc (abfd,
403 (info->dynsym_count
404 * sizeof (aout_symbol_type))));
405 bfd_size_type size;
406 bfd_size_type strsize = info->dyninfo.ld_symb_size;
407
408 size = (bfd_size_type) info->dynsym_count * sizeof (aout_symbol_type);
409 info->canonical_dynsym = (aout_symbol_type *) bfd_alloc (abfd, size);
405 if (info->canonical_dynsym == NULL && info->dynsym_count != 0)
406 return -1;
407
408 if (! aout_32_translate_symbol_table (abfd, info->canonical_dynsym,
410 if (info->canonical_dynsym == NULL && info->dynsym_count != 0)
411 return -1;
412
413 if (! aout_32_translate_symbol_table (abfd, info->canonical_dynsym,
409 info->dynsym, info->dynsym_count,
410 info->dynstr,
411 info->dyninfo.ld_symb_size,
412 true))
414 info->dynsym,
415 (bfd_size_type) info->dynsym_count,
416 info->dynstr, strsize, true))
413 {
414 if (info->canonical_dynsym != NULL)
415 {
416 bfd_release (abfd, info->canonical_dynsym);
417 info->canonical_dynsym = NULL;
418 }
419 return -1;
420 }

--- 33 unchanged lines hidden (view full) ---

454static long
455sunos_canonicalize_dynamic_reloc (abfd, storage, syms)
456 bfd *abfd;
457 arelent **storage;
458 asymbol **syms;
459{
460 struct sunos_dynamic_info *info;
461 unsigned long i;
417 {
418 if (info->canonical_dynsym != NULL)
419 {
420 bfd_release (abfd, info->canonical_dynsym);
421 info->canonical_dynsym = NULL;
422 }
423 return -1;
424 }

--- 33 unchanged lines hidden (view full) ---

458static long
459sunos_canonicalize_dynamic_reloc (abfd, storage, syms)
460 bfd *abfd;
461 arelent **storage;
462 asymbol **syms;
463{
464 struct sunos_dynamic_info *info;
465 unsigned long i;
466 bfd_size_type size;
462
463 /* Get the general dynamic information. */
464 if (obj_aout_dynamic_info (abfd) == (PTR) NULL)
465 {
466 if (! sunos_read_dynamic_info (abfd))
467 return -1;
468 }
469
470 info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
471 if (! info->valid)
472 {
473 bfd_set_error (bfd_error_no_symbols);
474 return -1;
475 }
476
477 /* Get the dynamic reloc information. */
478 if (info->dynrel == NULL)
479 {
467
468 /* Get the general dynamic information. */
469 if (obj_aout_dynamic_info (abfd) == (PTR) NULL)
470 {
471 if (! sunos_read_dynamic_info (abfd))
472 return -1;
473 }
474
475 info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
476 if (! info->valid)
477 {
478 bfd_set_error (bfd_error_no_symbols);
479 return -1;
480 }
481
482 /* Get the dynamic reloc information. */
483 if (info->dynrel == NULL)
484 {
480 info->dynrel = (PTR) bfd_alloc (abfd,
481 (info->dynrel_count
482 * obj_reloc_entry_size (abfd)));
483 if (info->dynrel == NULL && info->dynrel_count != 0)
485 size = (bfd_size_type) info->dynrel_count * obj_reloc_entry_size (abfd);
486 info->dynrel = (PTR) bfd_alloc (abfd, size);
487 if (info->dynrel == NULL && size != 0)
484 return -1;
488 return -1;
485 if (bfd_seek (abfd, info->dyninfo.ld_rel, SEEK_SET) != 0
486 || (bfd_read ((PTR) info->dynrel, info->dynrel_count,
487 obj_reloc_entry_size (abfd), abfd)
488 != info->dynrel_count * obj_reloc_entry_size (abfd)))
489 if (bfd_seek (abfd, (file_ptr) info->dyninfo.ld_rel, SEEK_SET) != 0
490 || bfd_bread ((PTR) info->dynrel, size, abfd) != size)
489 {
490 if (info->dynrel != NULL)
491 {
492 bfd_release (abfd, info->dynrel);
493 info->dynrel = NULL;
494 }
495 return -1;
496 }
497 }
498
499 /* Get the arelent structures corresponding to the dynamic reloc
500 information. */
501 if (info->canonical_dynrel == (arelent *) NULL)
502 {
503 arelent *to;
504
491 {
492 if (info->dynrel != NULL)
493 {
494 bfd_release (abfd, info->dynrel);
495 info->dynrel = NULL;
496 }
497 return -1;
498 }
499 }
500
501 /* Get the arelent structures corresponding to the dynamic reloc
502 information. */
503 if (info->canonical_dynrel == (arelent *) NULL)
504 {
505 arelent *to;
506
505 info->canonical_dynrel = ((arelent *)
506 bfd_alloc (abfd,
507 (info->dynrel_count
508 * sizeof (arelent))));
507 size = (bfd_size_type) info->dynrel_count * sizeof (arelent);
508 info->canonical_dynrel = (arelent *) bfd_alloc (abfd, size);
509 if (info->canonical_dynrel == NULL && info->dynrel_count != 0)
510 return -1;
511
512 to = info->canonical_dynrel;
513
514 if (obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE)
515 {
516 register struct reloc_ext_external *p;
517 struct reloc_ext_external *pend;
518
519 p = (struct reloc_ext_external *) info->dynrel;
520 pend = p + info->dynrel_count;
521 for (; p < pend; p++, to++)
522 NAME(aout,swap_ext_reloc_in) (abfd, p, to, syms,
509 if (info->canonical_dynrel == NULL && info->dynrel_count != 0)
510 return -1;
511
512 to = info->canonical_dynrel;
513
514 if (obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE)
515 {
516 register struct reloc_ext_external *p;
517 struct reloc_ext_external *pend;
518
519 p = (struct reloc_ext_external *) info->dynrel;
520 pend = p + info->dynrel_count;
521 for (; p < pend; p++, to++)
522 NAME(aout,swap_ext_reloc_in) (abfd, p, to, syms,
523 info->dynsym_count);
523 (bfd_size_type) info->dynsym_count);
524 }
525 else
526 {
527 register struct reloc_std_external *p;
528 struct reloc_std_external *pend;
529
530 p = (struct reloc_std_external *) info->dynrel;
531 pend = p + info->dynrel_count;
532 for (; p < pend; p++, to++)
533 NAME(aout,swap_std_reloc_in) (abfd, p, to, syms,
524 }
525 else
526 {
527 register struct reloc_std_external *p;
528 struct reloc_std_external *pend;
529
530 p = (struct reloc_std_external *) info->dynrel;
531 pend = p + info->dynrel_count;
532 for (; p < pend; p++, to++)
533 NAME(aout,swap_std_reloc_in) (abfd, p, to, syms,
534 info->dynsym_count);
534 (bfd_size_type) info->dynsym_count);
535 }
536 }
537
538 /* Return pointers to the dynamic arelent structures. */
539 for (i = 0; i < info->dynrel_count; i++)
540 *storage++ = info->canonical_dynrel + i;
541 *storage = NULL;
542

--- 16 unchanged lines hidden (view full) ---

559 0x3, 0, 0, 0,
560 /* jmp %g1; offset filled in by runtime linker. */
561 0x81, 0xc0, 0x60, 0,
562 /* nop */
563 0x1, 0, 0, 0
564};
565
566/* save %sp, -96, %sp */
535 }
536 }
537
538 /* Return pointers to the dynamic arelent structures. */
539 for (i = 0; i < info->dynrel_count; i++)
540 *storage++ = info->canonical_dynrel + i;
541 *storage = NULL;
542

--- 16 unchanged lines hidden (view full) ---

559 0x3, 0, 0, 0,
560 /* jmp %g1; offset filled in by runtime linker. */
561 0x81, 0xc0, 0x60, 0,
562 /* nop */
563 0x1, 0, 0, 0
564};
565
566/* save %sp, -96, %sp */
567#define SPARC_PLT_ENTRY_WORD0 0x9de3bfa0
567#define SPARC_PLT_ENTRY_WORD0 ((bfd_vma) 0x9de3bfa0)
568/* call; address filled in later. */
568/* call; address filled in later. */
569#define SPARC_PLT_ENTRY_WORD1 0x40000000
569#define SPARC_PLT_ENTRY_WORD1 ((bfd_vma) 0x40000000)
570/* sethi; reloc index filled in later. */
570/* sethi; reloc index filled in later. */
571#define SPARC_PLT_ENTRY_WORD2 0x01000000
571#define SPARC_PLT_ENTRY_WORD2 ((bfd_vma) 0x01000000)
572
573/* This sequence is used when for the jump table entry to a defined
574 symbol in a complete executable. It is used when linking PIC
575 compiled code which is not being put into a shared library. */
576/* sethi <address to be filled in later>, %g1 */
572
573/* This sequence is used when for the jump table entry to a defined
574 symbol in a complete executable. It is used when linking PIC
575 compiled code which is not being put into a shared library. */
576/* sethi <address to be filled in later>, %g1 */
577#define SPARC_PLT_PIC_WORD0 0x03000000
577#define SPARC_PLT_PIC_WORD0 ((bfd_vma) 0x03000000)
578/* jmp %g1 + <address to be filled in later> */
578/* jmp %g1 + <address to be filled in later> */
579#define SPARC_PLT_PIC_WORD1 0x81c06000
579#define SPARC_PLT_PIC_WORD1 ((bfd_vma) 0x81c06000)
580/* nop */
580/* nop */
581#define SPARC_PLT_PIC_WORD2 0x01000000
581#define SPARC_PLT_PIC_WORD2 ((bfd_vma) 0x01000000)
582
583/* An m68k procedure linkage table entry is 8 bytes. The first entry
584 in the table is a jump which is filled in the by the runtime
585 linker. The remaining entries are branches back to the first
586 entry, followed by a two byte index into the relocation table. */
587
588#define M68K_PLT_ENTRY_SIZE (8)
589
590static const bfd_byte m68k_plt_first_entry[M68K_PLT_ENTRY_SIZE] =
591{
592 /* jmps @# */
593 0x4e, 0xf9,
594 /* Filled in by runtime linker with a magic address. */
595 0, 0, 0, 0,
596 /* Not used? */
597 0, 0
598};
599
600/* bsrl */
582
583/* An m68k procedure linkage table entry is 8 bytes. The first entry
584 in the table is a jump which is filled in the by the runtime
585 linker. The remaining entries are branches back to the first
586 entry, followed by a two byte index into the relocation table. */
587
588#define M68K_PLT_ENTRY_SIZE (8)
589
590static const bfd_byte m68k_plt_first_entry[M68K_PLT_ENTRY_SIZE] =
591{
592 /* jmps @# */
593 0x4e, 0xf9,
594 /* Filled in by runtime linker with a magic address. */
595 0, 0, 0, 0,
596 /* Not used? */
597 0, 0
598};
599
600/* bsrl */
601#define M68K_PLT_ENTRY_WORD0 (0x61ff)
601#define M68K_PLT_ENTRY_WORD0 ((bfd_vma) 0x61ff)
602/* Remaining words filled in later. */
603
604/* An entry in the SunOS linker hash table. */
605
606struct sunos_link_hash_entry
607{
608 struct aout_link_hash_entry root;
609

--- 100 unchanged lines hidden (view full) ---

710
711/* Create a SunOS link hash table. */
712
713static struct bfd_link_hash_table *
714sunos_link_hash_table_create (abfd)
715 bfd *abfd;
716{
717 struct sunos_link_hash_table *ret;
602/* Remaining words filled in later. */
603
604/* An entry in the SunOS linker hash table. */
605
606struct sunos_link_hash_entry
607{
608 struct aout_link_hash_entry root;
609

--- 100 unchanged lines hidden (view full) ---

710
711/* Create a SunOS link hash table. */
712
713static struct bfd_link_hash_table *
714sunos_link_hash_table_create (abfd)
715 bfd *abfd;
716{
717 struct sunos_link_hash_table *ret;
718 bfd_size_type amt = sizeof (struct sunos_link_hash_table);
718
719
719 ret = ((struct sunos_link_hash_table *)
720 bfd_alloc (abfd, sizeof (struct sunos_link_hash_table)));
720 ret = (struct sunos_link_hash_table *) bfd_alloc (abfd, amt);
721 if (ret == (struct sunos_link_hash_table *) NULL)
722 return (struct bfd_link_hash_table *) NULL;
723 if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
724 sunos_link_hash_newfunc))
725 {
726 bfd_release (abfd, ret);
727 return (struct bfd_link_hash_table *) NULL;
728 }

--- 141 unchanged lines hidden (view full) ---

870static boolean
871sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp)
872 bfd *abfd;
873 struct bfd_link_info *info;
874 struct external_nlist **symsp;
875 bfd_size_type *sym_countp;
876 char **stringsp;
877{
721 if (ret == (struct sunos_link_hash_table *) NULL)
722 return (struct bfd_link_hash_table *) NULL;
723 if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
724 sunos_link_hash_newfunc))
725 {
726 bfd_release (abfd, ret);
727 return (struct bfd_link_hash_table *) NULL;
728 }

--- 141 unchanged lines hidden (view full) ---

870static boolean
871sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp)
872 bfd *abfd;
873 struct bfd_link_info *info;
874 struct external_nlist **symsp;
875 bfd_size_type *sym_countp;
876 char **stringsp;
877{
878 asection *s;
879 bfd *dynobj;
880 struct sunos_dynamic_info *dinfo;
881 unsigned long need;
878 bfd *dynobj;
879 struct sunos_dynamic_info *dinfo;
880 unsigned long need;
881 asection **ps;
882
883 /* Make sure we have all the required sections. */
884 if (info->hash->creator == abfd->xvec)
885 {
886 if (! sunos_create_dynamic_sections (abfd, info,
887 (((abfd->flags & DYNAMIC) != 0
888 && ! info->relocateable)
889 ? true

--- 9 unchanged lines hidden (view full) ---

899
900 /* We do not want to include the sections in a dynamic object in the
901 output file. We hack by simply clobbering the list of sections
902 in the BFD. This could be handled more cleanly by, say, a new
903 section flag; the existing SEC_NEVER_LOAD flag is not the one we
904 want, because that one still implies that the section takes up
905 space in the output file. If this is the first object we have
906 seen, we must preserve the dynamic sections we just created. */
882
883 /* Make sure we have all the required sections. */
884 if (info->hash->creator == abfd->xvec)
885 {
886 if (! sunos_create_dynamic_sections (abfd, info,
887 (((abfd->flags & DYNAMIC) != 0
888 && ! info->relocateable)
889 ? true

--- 9 unchanged lines hidden (view full) ---

899
900 /* We do not want to include the sections in a dynamic object in the
901 output file. We hack by simply clobbering the list of sections
902 in the BFD. This could be handled more cleanly by, say, a new
903 section flag; the existing SEC_NEVER_LOAD flag is not the one we
904 want, because that one still implies that the section takes up
905 space in the output file. If this is the first object we have
906 seen, we must preserve the dynamic sections we just created. */
907 if (abfd != dynobj)
908 abfd->sections = NULL;
909 else
907 for (ps = &abfd->sections; *ps != NULL; )
910 {
908 {
911 asection *s;
912
913 for (s = abfd->sections;
914 (s->flags & SEC_LINKER_CREATED) == 0;
915 s = s->next)
916 ;
917 abfd->sections = s;
909 if (abfd != dynobj || ((*ps)->flags & SEC_LINKER_CREATED) == 0)
910 bfd_section_list_remove (abfd, ps);
911 else
912 ps = &(*ps)->next;
918 }
919
920 /* The native linker seems to just ignore dynamic objects when -r is
921 used. */
922 if (info->relocateable)
923 return true;
924
925 /* There's no hope of using a dynamic object which does not exactly

--- 7 unchanged lines hidden (view full) ---

933 /* Make sure we have a .need and a .rules sections. These are only
934 needed if there really is a dynamic object in the link, so they
935 are not added by sunos_create_dynamic_sections. */
936 if (bfd_get_section_by_name (dynobj, ".need") == NULL)
937 {
938 /* The .need section holds the list of names of shared objets
939 which must be included at runtime. The address of this
940 section is put in the ld_need field. */
913 }
914
915 /* The native linker seems to just ignore dynamic objects when -r is
916 used. */
917 if (info->relocateable)
918 return true;
919
920 /* There's no hope of using a dynamic object which does not exactly

--- 7 unchanged lines hidden (view full) ---

928 /* Make sure we have a .need and a .rules sections. These are only
929 needed if there really is a dynamic object in the link, so they
930 are not added by sunos_create_dynamic_sections. */
931 if (bfd_get_section_by_name (dynobj, ".need") == NULL)
932 {
933 /* The .need section holds the list of names of shared objets
934 which must be included at runtime. The address of this
935 section is put in the ld_need field. */
941 s = bfd_make_section (dynobj, ".need");
936 asection *s = bfd_make_section (dynobj, ".need");
942 if (s == NULL
943 || ! bfd_set_section_flags (dynobj, s,
944 (SEC_ALLOC
945 | SEC_LOAD
946 | SEC_HAS_CONTENTS
947 | SEC_IN_MEMORY
948 | SEC_READONLY))
949 || ! bfd_set_section_alignment (dynobj, s, 2))
950 return false;
951 }
952
953 if (bfd_get_section_by_name (dynobj, ".rules") == NULL)
954 {
955 /* The .rules section holds the path to search for shared
956 objects. The address of this section is put in the ld_rules
957 field. */
937 if (s == NULL
938 || ! bfd_set_section_flags (dynobj, s,
939 (SEC_ALLOC
940 | SEC_LOAD
941 | SEC_HAS_CONTENTS
942 | SEC_IN_MEMORY
943 | SEC_READONLY))
944 || ! bfd_set_section_alignment (dynobj, s, 2))
945 return false;
946 }
947
948 if (bfd_get_section_by_name (dynobj, ".rules") == NULL)
949 {
950 /* The .rules section holds the path to search for shared
951 objects. The address of this section is put in the ld_rules
952 field. */
958 s = bfd_make_section (dynobj, ".rules");
953 asection *s = bfd_make_section (dynobj, ".rules");
959 if (s == NULL
960 || ! bfd_set_section_flags (dynobj, s,
961 (SEC_ALLOC
962 | SEC_LOAD
963 | SEC_HAS_CONTENTS
964 | SEC_IN_MEMORY
965 | SEC_READONLY))
966 || ! bfd_set_section_alignment (dynobj, s, 2))

--- 13 unchanged lines hidden (view full) ---

980 need = dinfo->dyninfo.ld_need;
981 while (need != 0)
982 {
983 bfd_byte buf[16];
984 unsigned long name, flags;
985 unsigned short major_vno, minor_vno;
986 struct bfd_link_needed_list *needed, **pp;
987 char *namebuf, *p;
954 if (s == NULL
955 || ! bfd_set_section_flags (dynobj, s,
956 (SEC_ALLOC
957 | SEC_LOAD
958 | SEC_HAS_CONTENTS
959 | SEC_IN_MEMORY
960 | SEC_READONLY))
961 || ! bfd_set_section_alignment (dynobj, s, 2))

--- 13 unchanged lines hidden (view full) ---

975 need = dinfo->dyninfo.ld_need;
976 while (need != 0)
977 {
978 bfd_byte buf[16];
979 unsigned long name, flags;
980 unsigned short major_vno, minor_vno;
981 struct bfd_link_needed_list *needed, **pp;
982 char *namebuf, *p;
988 size_t alc;
983 bfd_size_type alc;
989 bfd_byte b;
990 char *namecopy;
991
984 bfd_byte b;
985 char *namecopy;
986
992 if (bfd_seek (abfd, need, SEEK_SET) != 0
993 || bfd_read (buf, 1, 16, abfd) != 16)
987 if (bfd_seek (abfd, (file_ptr) need, SEEK_SET) != 0
988 || bfd_bread (buf, (bfd_size_type) 16, abfd) != 16)
994 return false;
995
996 /* For the format of an ld_need entry, see aout/sun4.h. We
997 should probably define structs for this manipulation. */
998
999 name = bfd_get_32 (abfd, buf);
1000 flags = bfd_get_32 (abfd, buf + 4);
989 return false;
990
991 /* For the format of an ld_need entry, see aout/sun4.h. We
992 should probably define structs for this manipulation. */
993
994 name = bfd_get_32 (abfd, buf);
995 flags = bfd_get_32 (abfd, buf + 4);
1001 major_vno = (unsigned short)bfd_get_16 (abfd, buf + 8);
1002 minor_vno = (unsigned short)bfd_get_16 (abfd, buf + 10);
996 major_vno = (unsigned short) bfd_get_16 (abfd, buf + 8);
997 minor_vno = (unsigned short) bfd_get_16 (abfd, buf + 10);
1003 need = bfd_get_32 (abfd, buf + 12);
1004
998 need = bfd_get_32 (abfd, buf + 12);
999
1005 needed = ((struct bfd_link_needed_list *)
1006 bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
1000 alc = sizeof (struct bfd_link_needed_list);
1001 needed = (struct bfd_link_needed_list *) bfd_alloc (abfd, alc);
1007 if (needed == NULL)
1008 return false;
1009 needed->by = abfd;
1010
1011 /* We return the name as [-l]name[.maj][.min]. */
1012 alc = 30;
1013 namebuf = (char *) bfd_malloc (alc + 1);
1014 if (namebuf == NULL)
1015 return false;
1016 p = namebuf;
1017
1018 if ((flags & 0x80000000) != 0)
1019 {
1020 *p++ = '-';
1021 *p++ = 'l';
1022 }
1002 if (needed == NULL)
1003 return false;
1004 needed->by = abfd;
1005
1006 /* We return the name as [-l]name[.maj][.min]. */
1007 alc = 30;
1008 namebuf = (char *) bfd_malloc (alc + 1);
1009 if (namebuf == NULL)
1010 return false;
1011 p = namebuf;
1012
1013 if ((flags & 0x80000000) != 0)
1014 {
1015 *p++ = '-';
1016 *p++ = 'l';
1017 }
1023 if (bfd_seek (abfd, name, SEEK_SET) != 0)
1018 if (bfd_seek (abfd, (file_ptr) name, SEEK_SET) != 0)
1024 {
1025 free (namebuf);
1026 return false;
1027 }
1028
1029 do
1030 {
1019 {
1020 free (namebuf);
1021 return false;
1022 }
1023
1024 do
1025 {
1031 if (bfd_read (&b, 1, 1, abfd) != 1)
1026 if (bfd_bread (&b, (bfd_size_type) 1, abfd) != 1)
1032 {
1033 free (namebuf);
1034 return false;
1035 }
1036
1027 {
1028 free (namebuf);
1029 return false;
1030 }
1031
1037 if ((size_t) (p - namebuf) >= alc)
1032 if ((bfd_size_type) (p - namebuf) >= alc)
1038 {
1039 char *n;
1040
1041 alc *= 2;
1042 n = (char *) bfd_realloc (namebuf, alc + 1);
1043 if (n == NULL)
1044 {
1045 free (namebuf);

--- 34 unchanged lines hidden (view full) ---

1080 p = n + (p - namebuf);
1081 namebuf = n;
1082 }
1083
1084 strcpy (p, majbuf);
1085 strcat (p, minbuf);
1086 }
1087
1033 {
1034 char *n;
1035
1036 alc *= 2;
1037 n = (char *) bfd_realloc (namebuf, alc + 1);
1038 if (n == NULL)
1039 {
1040 free (namebuf);

--- 34 unchanged lines hidden (view full) ---

1075 p = n + (p - namebuf);
1076 namebuf = n;
1077 }
1078
1079 strcpy (p, majbuf);
1080 strcat (p, minbuf);
1081 }
1082
1088 namecopy = bfd_alloc (abfd, strlen (namebuf) + 1);
1083 namecopy = bfd_alloc (abfd, (bfd_size_type) strlen (namebuf) + 1);
1089 if (namecopy == NULL)
1090 {
1091 free (namebuf);
1092 return false;
1093 }
1094 strcpy (namecopy, namebuf);
1095 free (namebuf);
1096 needed->name = namecopy;

--- 220 unchanged lines hidden (view full) ---

1317 srulesptr)
1318 bfd *output_bfd;
1319 struct bfd_link_info *info;
1320 asection **sdynptr;
1321 asection **sneedptr;
1322 asection **srulesptr;
1323{
1324 bfd *dynobj;
1084 if (namecopy == NULL)
1085 {
1086 free (namebuf);
1087 return false;
1088 }
1089 strcpy (namecopy, namebuf);
1090 free (namebuf);
1091 needed->name = namecopy;

--- 220 unchanged lines hidden (view full) ---

1312 srulesptr)
1313 bfd *output_bfd;
1314 struct bfd_link_info *info;
1315 asection **sdynptr;
1316 asection **sneedptr;
1317 asection **srulesptr;
1318{
1319 bfd *dynobj;
1325 size_t dynsymcount;
1320 bfd_size_type dynsymcount;
1326 struct sunos_link_hash_entry *h;
1327 asection *s;
1328 size_t bucketcount;
1321 struct sunos_link_hash_entry *h;
1322 asection *s;
1323 size_t bucketcount;
1329 size_t hashalloc;
1324 bfd_size_type hashalloc;
1330 size_t i;
1331 bfd *sub;
1332
1333 *sdynptr = NULL;
1334 *sneedptr = NULL;
1335 *srulesptr = NULL;
1336
1337 if (info->relocateable)

--- 99 unchanged lines hidden (view full) ---

1437 else
1438 bucketcount = 1;
1439 s = bfd_get_section_by_name (dynobj, ".hash");
1440 BFD_ASSERT (s != NULL);
1441 hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
1442 s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
1443 if (s->contents == NULL && dynsymcount > 0)
1444 return false;
1325 size_t i;
1326 bfd *sub;
1327
1328 *sdynptr = NULL;
1329 *sneedptr = NULL;
1330 *srulesptr = NULL;
1331
1332 if (info->relocateable)

--- 99 unchanged lines hidden (view full) ---

1432 else
1433 bucketcount = 1;
1434 s = bfd_get_section_by_name (dynobj, ".hash");
1435 BFD_ASSERT (s != NULL);
1436 hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
1437 s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
1438 if (s->contents == NULL && dynsymcount > 0)
1439 return false;
1445 memset (s->contents, 0, hashalloc);
1440 memset (s->contents, 0, (size_t) hashalloc);
1446 for (i = 0; i < bucketcount; i++)
1447 PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
1448 s->_raw_size = bucketcount * HASH_ENTRY_SIZE;
1449
1450 sunos_hash_table (info)->bucketcount = bucketcount;
1451
1452 /* Scan all the symbols, place them in the dynamic symbol table,
1453 and build the dynamic hash table. We reuse dynsymcount as a

--- 11 unchanged lines hidden (view full) ---

1465 BFD_ASSERT (s != NULL);
1466 if ((s->_raw_size & 7) != 0)
1467 {
1468 bfd_size_type add;
1469 bfd_byte *contents;
1470
1471 add = 8 - (s->_raw_size & 7);
1472 contents = (bfd_byte *) bfd_realloc (s->contents,
1441 for (i = 0; i < bucketcount; i++)
1442 PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
1443 s->_raw_size = bucketcount * HASH_ENTRY_SIZE;
1444
1445 sunos_hash_table (info)->bucketcount = bucketcount;
1446
1447 /* Scan all the symbols, place them in the dynamic symbol table,
1448 and build the dynamic hash table. We reuse dynsymcount as a

--- 11 unchanged lines hidden (view full) ---

1460 BFD_ASSERT (s != NULL);
1461 if ((s->_raw_size & 7) != 0)
1462 {
1463 bfd_size_type add;
1464 bfd_byte *contents;
1465
1466 add = 8 - (s->_raw_size & 7);
1467 contents = (bfd_byte *) bfd_realloc (s->contents,
1473 (size_t) (s->_raw_size + add));
1468 s->_raw_size + add);
1474 if (contents == NULL)
1475 return false;
1476 memset (contents + s->_raw_size, 0, (size_t) add);
1477 s->contents = contents;
1478 s->_raw_size += add;
1479 }
1480 }
1481

--- 57 unchanged lines hidden (view full) ---

1539{
1540 PTR relocs;
1541 PTR free_relocs = NULL;
1542
1543 if (rel_size == 0)
1544 return true;
1545
1546 if (! info->keep_memory)
1469 if (contents == NULL)
1470 return false;
1471 memset (contents + s->_raw_size, 0, (size_t) add);
1472 s->contents = contents;
1473 s->_raw_size += add;
1474 }
1475 }
1476

--- 57 unchanged lines hidden (view full) ---

1534{
1535 PTR relocs;
1536 PTR free_relocs = NULL;
1537
1538 if (rel_size == 0)
1539 return true;
1540
1541 if (! info->keep_memory)
1547 relocs = free_relocs = bfd_malloc ((size_t) rel_size);
1542 relocs = free_relocs = bfd_malloc (rel_size);
1548 else
1549 {
1550 struct aout_section_data_struct *n;
1543 else
1544 {
1545 struct aout_section_data_struct *n;
1546 bfd_size_type amt = sizeof (struct aout_section_data_struct);
1551
1547
1552 n = ((struct aout_section_data_struct *)
1553 bfd_alloc (abfd, sizeof (struct aout_section_data_struct)));
1548 n = (struct aout_section_data_struct *) bfd_alloc (abfd, amt);
1554 if (n == NULL)
1555 relocs = NULL;
1556 else
1557 {
1558 set_aout_section_data (sec, n);
1549 if (n == NULL)
1550 relocs = NULL;
1551 else
1552 {
1553 set_aout_section_data (sec, n);
1559 relocs = bfd_malloc ((size_t) rel_size);
1554 relocs = bfd_malloc (rel_size);
1560 aout_section_data (sec)->relocs = relocs;
1561 }
1562 }
1563 if (relocs == NULL)
1564 return false;
1565
1566 if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
1555 aout_section_data (sec)->relocs = relocs;
1556 }
1557 }
1558 if (relocs == NULL)
1559 return false;
1560
1561 if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
1567 || bfd_read (relocs, 1, rel_size, abfd) != rel_size)
1562 || bfd_bread (relocs, rel_size, abfd) != rel_size)
1568 goto error_return;
1569
1570 if (obj_reloc_entry_size (abfd) == RELOC_STD_SIZE)
1571 {
1572 if (! sunos_scan_std_relocs (info, abfd, sec,
1573 (struct reloc_std_external *) relocs,
1574 rel_size))
1575 goto error_return;

--- 196 unchanged lines hidden (view full) ---

1772 bfd_size_type rel_size;
1773{
1774 bfd *dynobj;
1775 struct sunos_link_hash_entry **sym_hashes;
1776 const struct reloc_ext_external *rel, *relend;
1777 asection *splt = NULL;
1778 asection *sgot = NULL;
1779 asection *srel = NULL;
1563 goto error_return;
1564
1565 if (obj_reloc_entry_size (abfd) == RELOC_STD_SIZE)
1566 {
1567 if (! sunos_scan_std_relocs (info, abfd, sec,
1568 (struct reloc_std_external *) relocs,
1569 rel_size))
1570 goto error_return;

--- 196 unchanged lines hidden (view full) ---

1767 bfd_size_type rel_size;
1768{
1769 bfd *dynobj;
1770 struct sunos_link_hash_entry **sym_hashes;
1771 const struct reloc_ext_external *rel, *relend;
1772 asection *splt = NULL;
1773 asection *sgot = NULL;
1774 asection *srel = NULL;
1775 bfd_size_type amt;
1780
1781 /* We only know how to handle SPARC plt entries. */
1782 if (bfd_get_arch (abfd) != bfd_arch_sparc)
1783 {
1784 bfd_set_error (bfd_error_invalid_target);
1785 return false;
1786 }
1787

--- 75 unchanged lines hidden (view full) ---

1863 {
1864 /* This is abnormal, but should be caught in the
1865 relocation phase. */
1866 continue;
1867 }
1868
1869 if (adata (abfd).local_got_offsets == NULL)
1870 {
1776
1777 /* We only know how to handle SPARC plt entries. */
1778 if (bfd_get_arch (abfd) != bfd_arch_sparc)
1779 {
1780 bfd_set_error (bfd_error_invalid_target);
1781 return false;
1782 }
1783

--- 75 unchanged lines hidden (view full) ---

1859 {
1860 /* This is abnormal, but should be caught in the
1861 relocation phase. */
1862 continue;
1863 }
1864
1865 if (adata (abfd).local_got_offsets == NULL)
1866 {
1867 amt = bfd_get_symcount (abfd);
1868 amt *= sizeof (bfd_vma);
1871 adata (abfd).local_got_offsets =
1869 adata (abfd).local_got_offsets =
1872 (bfd_vma *) bfd_zalloc (abfd,
1873 (bfd_get_symcount (abfd)
1874 * sizeof (bfd_vma)));
1870 (bfd_vma *) bfd_zalloc (abfd, amt);
1875 if (adata (abfd).local_got_offsets == NULL)
1876 return false;
1877 }
1878
1879 if (adata (abfd).local_got_offsets[r_index] != 0)
1880 continue;
1881
1882 adata (abfd).local_got_offsets[r_index] = sgot->_raw_size;

--- 313 unchanged lines hidden (view full) ---

2196
2197 /* If this symbol is in the procedure linkage table, fill in the
2198 table entry. */
2199 if (h->plt_offset != 0)
2200 {
2201 bfd *dynobj;
2202 asection *splt;
2203 bfd_byte *p;
1871 if (adata (abfd).local_got_offsets == NULL)
1872 return false;
1873 }
1874
1875 if (adata (abfd).local_got_offsets[r_index] != 0)
1876 continue;
1877
1878 adata (abfd).local_got_offsets[r_index] = sgot->_raw_size;

--- 313 unchanged lines hidden (view full) ---

2192
2193 /* If this symbol is in the procedure linkage table, fill in the
2194 table entry. */
2195 if (h->plt_offset != 0)
2196 {
2197 bfd *dynobj;
2198 asection *splt;
2199 bfd_byte *p;
2204 asection *s;
2205 bfd_vma r_address;
2206
2207 dynobj = sunos_hash_table (info)->dynobj;
2208 splt = bfd_get_section_by_name (dynobj, ".plt");
2209 p = splt->contents + h->plt_offset;
2210
2211 s = bfd_get_section_by_name (dynobj, ".dynrel");
2212

--- 12 unchanged lines hidden (view full) ---

2225 + (((- (h->plt_offset + 4) >> 2)
2226 & 0x3fffffff))),
2227 p + 4);
2228 bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD2 + s->reloc_count,
2229 p + 8);
2230 }
2231 else
2232 {
2200 bfd_vma r_address;
2201
2202 dynobj = sunos_hash_table (info)->dynobj;
2203 splt = bfd_get_section_by_name (dynobj, ".plt");
2204 p = splt->contents + h->plt_offset;
2205
2206 s = bfd_get_section_by_name (dynobj, ".dynrel");
2207

--- 12 unchanged lines hidden (view full) ---

2220 + (((- (h->plt_offset + 4) >> 2)
2221 & 0x3fffffff))),
2222 p + 4);
2223 bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD2 + s->reloc_count,
2224 p + 8);
2225 }
2226 else
2227 {
2233 bfd_vma val;
2234
2235 val = (h->root.root.u.def.section->output_section->vma
2236 + h->root.root.u.def.section->output_offset
2237 + h->root.root.u.def.value);
2238 bfd_put_32 (output_bfd,
2239 SPARC_PLT_PIC_WORD0 + ((val >> 10) & 0x3fffff),
2240 p);
2241 bfd_put_32 (output_bfd,
2242 SPARC_PLT_PIC_WORD1 + (val & 0x3ff),
2243 p + 4);
2244 bfd_put_32 (output_bfd, SPARC_PLT_PIC_WORD2, p + 8);
2245 }
2246 break;
2247
2248 case bfd_arch_m68k:
2249 if (! info->shared && (h->flags & SUNOS_DEF_REGULAR) != 0)
2250 abort ();
2251 bfd_put_16 (output_bfd, M68K_PLT_ENTRY_WORD0, p);
2252 bfd_put_32 (output_bfd, (- (h->plt_offset + 2)), p + 2);
2228 val = (h->root.root.u.def.section->output_section->vma
2229 + h->root.root.u.def.section->output_offset
2230 + h->root.root.u.def.value);
2231 bfd_put_32 (output_bfd,
2232 SPARC_PLT_PIC_WORD0 + ((val >> 10) & 0x3fffff),
2233 p);
2234 bfd_put_32 (output_bfd,
2235 SPARC_PLT_PIC_WORD1 + (val & 0x3ff),
2236 p + 4);
2237 bfd_put_32 (output_bfd, SPARC_PLT_PIC_WORD2, p + 8);
2238 }
2239 break;
2240
2241 case bfd_arch_m68k:
2242 if (! info->shared && (h->flags & SUNOS_DEF_REGULAR) != 0)
2243 abort ();
2244 bfd_put_16 (output_bfd, M68K_PLT_ENTRY_WORD0, p);
2245 bfd_put_32 (output_bfd, (- (h->plt_offset + 2)), p + 2);
2253 bfd_put_16 (output_bfd, s->reloc_count, p + 6);
2246 bfd_put_16 (output_bfd, (bfd_vma) s->reloc_count, p + 6);
2254 r_address += 2;
2255 break;
2256
2257 default:
2258 abort ();
2259 }
2260
2261 /* We also need to add a jump table reloc, unless this is the

--- 132 unchanged lines hidden (view full) ---

2394 return true;
2395 }
2396
2397 s = bfd_get_section_by_name (sunos_hash_table (info)->dynobj, ".dynsym");
2398 BFD_ASSERT (s != NULL);
2399 outsym = ((struct external_nlist *)
2400 (s->contents + h->dynindx * EXTERNAL_NLIST_SIZE));
2401
2247 r_address += 2;
2248 break;
2249
2250 default:
2251 abort ();
2252 }
2253
2254 /* We also need to add a jump table reloc, unless this is the

--- 132 unchanged lines hidden (view full) ---

2387 return true;
2388 }
2389
2390 s = bfd_get_section_by_name (sunos_hash_table (info)->dynobj, ".dynsym");
2391 BFD_ASSERT (s != NULL);
2392 outsym = ((struct external_nlist *)
2393 (s->contents + h->dynindx * EXTERNAL_NLIST_SIZE));
2394
2402 bfd_h_put_8 (output_bfd, type, outsym->e_type);
2403 bfd_h_put_8 (output_bfd, 0, outsym->e_other);
2395 H_PUT_8 (output_bfd, type, outsym->e_type);
2396 H_PUT_8 (output_bfd, 0, outsym->e_other);
2404
2405 /* FIXME: The native linker doesn't use 0 for desc. It seems to use
2406 one less than the desc value in the shared library, although that
2407 seems unlikely. */
2397
2398 /* FIXME: The native linker doesn't use 0 for desc. It seems to use
2399 one less than the desc value in the shared library, although that
2400 seems unlikely. */
2408 bfd_h_put_16 (output_bfd, 0, outsym->e_desc);
2401 H_PUT_16 (output_bfd, 0, outsym->e_desc);
2409
2410 PUT_WORD (output_bfd, h->dynstr_index, outsym->e_strx);
2411 PUT_WORD (output_bfd, val, outsym->e_value);
2412
2413 return true;
2414}
2415
2416/* This is called for each reloc against an external symbol. If this

--- 246 unchanged lines hidden (view full) ---

2663
2664 ++s->reloc_count;
2665 }
2666
2667 *got_offsetp |= 1;
2668 }
2669
2670 *relocationp = (sgot->vma
2402
2403 PUT_WORD (output_bfd, h->dynstr_index, outsym->e_strx);
2404 PUT_WORD (output_bfd, val, outsym->e_value);
2405
2406 return true;
2407}
2408
2409/* This is called for each reloc against an external symbol. If this

--- 246 unchanged lines hidden (view full) ---

2656
2657 ++s->reloc_count;
2658 }
2659
2660 *got_offsetp |= 1;
2661 }
2662
2663 *relocationp = (sgot->vma
2671 + (*got_offsetp &~ 1)
2664 + (*got_offsetp &~ (bfd_vma) 1)
2672 - sunos_hash_table (info)->got_base);
2673
2674 /* There is nothing else to do for a base relative reloc. */
2675 return true;
2676 }
2677
2678 if (! sunos_hash_table (info)->dynamic_sections_needed)
2679 return true;

--- 160 unchanged lines hidden (view full) ---

2840 for (o = dynobj->sections; o != NULL; o = o->next)
2841 {
2842 if ((o->flags & SEC_HAS_CONTENTS) != 0
2843 && o->contents != NULL)
2844 {
2845 BFD_ASSERT (o->output_section != NULL
2846 && o->output_section->owner == abfd);
2847 if (! bfd_set_section_contents (abfd, o->output_section,
2665 - sunos_hash_table (info)->got_base);
2666
2667 /* There is nothing else to do for a base relative reloc. */
2668 return true;
2669 }
2670
2671 if (! sunos_hash_table (info)->dynamic_sections_needed)
2672 return true;

--- 160 unchanged lines hidden (view full) ---

2833 for (o = dynobj->sections; o != NULL; o = o->next)
2834 {
2835 if ((o->flags & SEC_HAS_CONTENTS) != 0
2836 && o->contents != NULL)
2837 {
2838 BFD_ASSERT (o->output_section != NULL
2839 && o->output_section->owner == abfd);
2840 if (! bfd_set_section_contents (abfd, o->output_section,
2848 o->contents, o->output_offset,
2841 o->contents,
2842 (file_ptr) o->output_offset,
2849 o->_raw_size))
2850 return false;
2851 }
2852 }
2853
2854 if (sdyn->_raw_size > 0)
2855 {
2856 struct external_sun4_dynamic esd;
2857 struct external_sun4_dynamic_link esdl;
2843 o->_raw_size))
2844 return false;
2845 }
2846 }
2847
2848 if (sdyn->_raw_size > 0)
2849 {
2850 struct external_sun4_dynamic esd;
2851 struct external_sun4_dynamic_link esdl;
2852 file_ptr pos;
2858
2859 /* Finish up the dynamic link information. */
2860 PUT_WORD (dynobj, (bfd_vma) 3, esd.ld_version);
2861 PUT_WORD (dynobj,
2862 sdyn->output_section->vma + sdyn->output_offset + sizeof esd,
2863 esd.ldd);
2864 PUT_WORD (dynobj,
2865 (sdyn->output_section->vma
2866 + sdyn->output_offset
2867 + sizeof esd
2868 + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE),
2869 esd.ld);
2870
2871 if (! bfd_set_section_contents (abfd, sdyn->output_section, &esd,
2853
2854 /* Finish up the dynamic link information. */
2855 PUT_WORD (dynobj, (bfd_vma) 3, esd.ld_version);
2856 PUT_WORD (dynobj,
2857 sdyn->output_section->vma + sdyn->output_offset + sizeof esd,
2858 esd.ldd);
2859 PUT_WORD (dynobj,
2860 (sdyn->output_section->vma
2861 + sdyn->output_offset
2862 + sizeof esd
2863 + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE),
2864 esd.ld);
2865
2866 if (! bfd_set_section_contents (abfd, sdyn->output_section, &esd,
2872 sdyn->output_offset, sizeof esd))
2867 (file_ptr) sdyn->output_offset,
2868 (bfd_size_type) sizeof esd))
2873 return false;
2874
2875 PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_loaded);
2876
2877 s = bfd_get_section_by_name (dynobj, ".need");
2878 if (s == NULL || s->_raw_size == 0)
2879 PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_need);
2880 else

--- 48 unchanged lines hidden (view full) ---

2929
2930 /* The size of the text area is the size of the .text section
2931 rounded up to a page boundary. FIXME: Should the page size be
2932 conditional on something? */
2933 PUT_WORD (dynobj,
2934 BFD_ALIGN (obj_textsec (abfd)->_raw_size, 0x2000),
2935 esdl.ld_text);
2936
2869 return false;
2870
2871 PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_loaded);
2872
2873 s = bfd_get_section_by_name (dynobj, ".need");
2874 if (s == NULL || s->_raw_size == 0)
2875 PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_need);
2876 else

--- 48 unchanged lines hidden (view full) ---

2925
2926 /* The size of the text area is the size of the .text section
2927 rounded up to a page boundary. FIXME: Should the page size be
2928 conditional on something? */
2929 PUT_WORD (dynobj,
2930 BFD_ALIGN (obj_textsec (abfd)->_raw_size, 0x2000),
2931 esdl.ld_text);
2932
2933 pos = sdyn->output_offset;
2934 pos += sizeof esd + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE;
2937 if (! bfd_set_section_contents (abfd, sdyn->output_section, &esdl,
2935 if (! bfd_set_section_contents (abfd, sdyn->output_section, &esdl,
2938 (sdyn->output_offset
2939 + sizeof esd
2940 + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE),
2941 sizeof esdl))
2936 pos, (bfd_size_type) sizeof esdl))
2942 return false;
2943
2944 abfd->flags |= DYNAMIC;
2945 }
2946
2947 return true;
2948}
2937 return false;
2938
2939 abfd->flags |= DYNAMIC;
2940 }
2941
2942 return true;
2943}