Subversion Repositories Kolibri OS

Rev

Rev 5197 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5197 Rev 6324
Line 1... Line 1...
1
/* ELF linking support for BFD.
1
/* ELF linking support for BFD.
2
   Copyright 1995-2013 Free Software Foundation, Inc.
2
   Copyright (C) 1995-2015 Free Software Foundation, Inc.
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
   This file is part of BFD, the Binary File Descriptor library.
4
   This file is part of BFD, the Binary File Descriptor library.
5
 
5
 
Line 18... Line 18...
18
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
18
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
   MA 02110-1301, USA.  */
19
   MA 02110-1301, USA.  */
Line 20... Line 20...
20
 
20
 
21
#include "sysdep.h"
21
#include "sysdep.h"
-
 
22
#include "bfd.h"
22
#include "bfd.h"
23
#include "bfd_stdint.h"
23
#include "bfdlink.h"
24
#include "bfdlink.h"
24
#include "libbfd.h"
25
#include "libbfd.h"
25
#define ARCH_SIZE 0
26
#define ARCH_SIZE 0
26
#include "elf-bfd.h"
27
#include "elf-bfd.h"
Line 51... Line 52...
51
};
52
};
Line 52... Line 53...
52
 
53
 
53
static bfd_boolean _bfd_elf_fix_symbol_flags
54
static bfd_boolean _bfd_elf_fix_symbol_flags
Line -... Line 55...
-
 
55
  (struct elf_link_hash_entry *, struct elf_info_failed *);
-
 
56
 
-
 
57
asection *
-
 
58
_bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
-
 
59
			     unsigned long r_symndx,
-
 
60
			     bfd_boolean discard)
-
 
61
{
-
 
62
  if (r_symndx >= cookie->locsymcount
-
 
63
      || ELF_ST_BIND (cookie->locsyms[r_symndx].st_info) != STB_LOCAL)
-
 
64
    {
-
 
65
      struct elf_link_hash_entry *h;
-
 
66
 
-
 
67
      h = cookie->sym_hashes[r_symndx - cookie->extsymoff];
-
 
68
 
-
 
69
      while (h->root.type == bfd_link_hash_indirect
-
 
70
	     || h->root.type == bfd_link_hash_warning)
-
 
71
	h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
 
72
 
-
 
73
      if ((h->root.type == bfd_link_hash_defined
-
 
74
	   || h->root.type == bfd_link_hash_defweak)
-
 
75
	   && discarded_section (h->root.u.def.section))
-
 
76
        return h->root.u.def.section;
-
 
77
      else
-
 
78
	return NULL;
-
 
79
    }
-
 
80
  else
-
 
81
    {
-
 
82
      /* It's not a relocation against a global symbol,
-
 
83
	 but it could be a relocation against a local
-
 
84
	 symbol for a discarded section.  */
-
 
85
      asection *isec;
-
 
86
      Elf_Internal_Sym *isym;
-
 
87
 
-
 
88
      /* Need to: get the symbol; get the section.  */
-
 
89
      isym = &cookie->locsyms[r_symndx];
-
 
90
      isec = bfd_section_from_elf_index (cookie->abfd, isym->st_shndx);
-
 
91
      if (isec != NULL
-
 
92
	  && discard ? discarded_section (isec) : 1)
-
 
93
	return isec;
-
 
94
     }
-
 
95
  return NULL;
54
  (struct elf_link_hash_entry *, struct elf_info_failed *);
96
}
Line 55... Line 97...
55
 
97
 
56
/* Define a symbol in a dynamic linkage section.  */
98
/* Define a symbol in a dynamic linkage section.  */
57
 
99
 
Line 74... Line 116...
74
	 lose the link to the bfd which is via the symbol section.  */
116
	 lose the link to the bfd which is via the symbol section.  */
75
      h->root.type = bfd_link_hash_new;
117
      h->root.type = bfd_link_hash_new;
76
    }
118
    }
Line 77... Line 119...
77
 
119
 
-
 
120
  bh = &h->root;
78
  bh = &h->root;
121
  bed = get_elf_backend_data (abfd);
79
  if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL,
122
  if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL,
80
					 sec, 0, NULL, FALSE,
-
 
81
					 get_elf_backend_data (abfd)->collect,
123
					 sec, 0, NULL, FALSE, bed->collect,
82
					 &bh))
124
					 &bh))
83
    return NULL;
125
    return NULL;
84
  h = (struct elf_link_hash_entry *) bh;
126
  h = (struct elf_link_hash_entry *) bh;
85
  h->def_regular = 1;
127
  h->def_regular = 1;
-
 
128
  h->non_elf = 0;
86
  h->non_elf = 0;
129
  h->root.linker_def = 1;
87
  h->type = STT_OBJECT;
130
  h->type = STT_OBJECT;
88
  if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
131
  if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
Line 89... Line -...
89
    h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
-
 
90
 
132
    h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
91
  bed = get_elf_backend_data (abfd);
133
 
92
  (*bed->elf_backend_hide_symbol) (info, h, TRUE);
134
  (*bed->elf_backend_hide_symbol) (info, h, TRUE);
Line 93... Line 135...
93
  return h;
135
  return h;
Line 202... Line 244...
202
 
244
 
Line 203... Line 245...
203
  flags = bed->dynamic_sec_flags;
245
  flags = bed->dynamic_sec_flags;
204
 
246
 
205
  /* A dynamically linked executable has a .interp section, but a
247
  /* A dynamically linked executable has a .interp section, but a
206
     shared library does not.  */
248
     shared library does not.  */
207
  if (info->executable)
249
  if (bfd_link_executable (info) && !info->nointerp)
208
    {
250
    {
209
      s = bfd_make_section_anyway_with_flags (abfd, ".interp",
251
      s = bfd_make_section_anyway_with_flags (abfd, ".interp",
210
					      flags | SEC_READONLY);
252
					      flags | SEC_READONLY);
Line 235... Line 277...
235
  s = bfd_make_section_anyway_with_flags (abfd, ".dynsym",
277
  s = bfd_make_section_anyway_with_flags (abfd, ".dynsym",
236
					  flags | SEC_READONLY);
278
					  flags | SEC_READONLY);
237
  if (s == NULL
279
  if (s == NULL
238
      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
280
      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
239
    return FALSE;
281
    return FALSE;
-
 
282
  elf_hash_table (info)->dynsym = s;
Line 240... Line 283...
240
 
283
 
241
  s = bfd_make_section_anyway_with_flags (abfd, ".dynstr",
284
  s = bfd_make_section_anyway_with_flags (abfd, ".dynstr",
242
					  flags | SEC_READONLY);
285
					  flags | SEC_READONLY);
243
  if (s == NULL)
286
  if (s == NULL)
Line 374... Line 417...
374
	 (size_dynamic_sections) the input sections have already been
417
	 (size_dynamic_sections) the input sections have already been
375
	 mapped to the output sections.  If the section turns out not to
418
	 mapped to the output sections.  If the section turns out not to
376
	 be needed, we can discard it later.  We will never need this
419
	 be needed, we can discard it later.  We will never need this
377
	 section when generating a shared object, since they do not use
420
	 section when generating a shared object, since they do not use
378
	 copy relocs.  */
421
	 copy relocs.  */
379
      if (! info->shared)
422
      if (! bfd_link_pic (info))
380
	{
423
	{
381
	  s = bfd_make_section_anyway_with_flags (abfd,
424
	  s = bfd_make_section_anyway_with_flags (abfd,
382
						  (bed->rela_plts_and_copies_p
425
						  (bed->rela_plts_and_copies_p
383
						   ? ".rela.bss" : ".rel.bss"),
426
						   ? ".rela.bss" : ".rel.bss"),
384
						  flags | SEC_READONLY);
427
						  flags | SEC_READONLY);
Line 475... Line 518...
475
				  Elf_Internal_Sym *sym)
518
				  Elf_Internal_Sym *sym)
476
{
519
{
477
  struct bfd_elf_dynamic_list *d = info->dynamic_list;
520
  struct bfd_elf_dynamic_list *d = info->dynamic_list;
Line 478... Line 521...
478
 
521
 
479
  /* It may be called more than once on the same H.  */
522
  /* It may be called more than once on the same H.  */
480
  if(h->dynamic || info->relocatable)
523
  if(h->dynamic || bfd_link_relocatable (info))
Line 481... Line 524...
481
    return;
524
    return;
482
 
525
 
483
  if ((info->dynamic_data
526
  if ((info->dynamic_data
Line 579... Line 622...
579
      (*bed->elf_backend_hide_symbol) (info, h, TRUE);
622
      (*bed->elf_backend_hide_symbol) (info, h, TRUE);
580
    }
623
    }
Line 581... Line 624...
581
 
624
 
582
  /* STV_HIDDEN and STV_INTERNAL symbols must be STB_LOCAL in shared objects
625
  /* STV_HIDDEN and STV_INTERNAL symbols must be STB_LOCAL in shared objects
583
     and executables.  */
626
     and executables.  */
584
  if (!info->relocatable
627
  if (!bfd_link_relocatable (info)
585
      && h->dynindx != -1
628
      && h->dynindx != -1
586
      && (ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
629
      && (ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
587
	  || ELF_ST_VISIBILITY (h->other) == STV_INTERNAL))
630
	  || ELF_ST_VISIBILITY (h->other) == STV_INTERNAL))
Line 588... Line 631...
588
    h->forced_local = 1;
631
    h->forced_local = 1;
589
 
632
 
590
  if ((h->def_dynamic
633
  if ((h->def_dynamic
-
 
634
       || h->ref_dynamic
591
       || h->ref_dynamic
635
       || bfd_link_pic (info)
592
       || info->shared
636
       || (bfd_link_pde (info)
593
       || (info->executable && elf_hash_table (info)->is_relocatable_executable))
637
	   && elf_hash_table (info)->is_relocatable_executable))
594
      && h->dynindx == -1)
638
      && h->dynindx == -1)
595
    {
639
    {
Line 758... Line 802...
758
_bfd_elf_link_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED,
802
_bfd_elf_link_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED,
759
				   struct bfd_link_info *info,
803
				   struct bfd_link_info *info,
760
				   asection *p)
804
				   asection *p)
761
{
805
{
762
  struct elf_link_hash_table *htab;
806
  struct elf_link_hash_table *htab;
-
 
807
  asection *ip;
Line 763... Line 808...
763
 
808
 
764
  switch (elf_section_data (p)->this_hdr.sh_type)
809
  switch (elf_section_data (p)->this_hdr.sh_type)
765
    {
810
    {
766
    case SHT_PROGBITS:
811
    case SHT_PROGBITS:
Line 773... Line 818...
773
	return FALSE;
818
	return FALSE;
Line 774... Line 819...
774
 
819
 
775
      if (htab->text_index_section != NULL)
820
      if (htab->text_index_section != NULL)
Line 776... Line -...
776
	return p != htab->text_index_section && p != htab->data_index_section;
-
 
777
 
-
 
778
      if (strcmp (p->name, ".got") == 0
-
 
779
	  || strcmp (p->name, ".got.plt") == 0
-
 
780
	  || strcmp (p->name, ".plt") == 0)
-
 
781
	{
-
 
782
	  asection *ip;
821
	return p != htab->text_index_section && p != htab->data_index_section;
783
 
822
 
784
	  if (htab->dynobj != NULL
823
      return (htab->dynobj != NULL
785
	      && (ip = bfd_get_linker_section (htab->dynobj, p->name)) != NULL
-
 
786
	      && ip->output_section == p)
-
 
787
	    return TRUE;
-
 
Line 788... Line 824...
788
	}
824
	      && (ip = bfd_get_linker_section (htab->dynobj, p->name)) != NULL
789
      return FALSE;
825
	      && ip->output_section == p);
790
 
826
 
791
      /* There shouldn't be section relative relocations
827
      /* There shouldn't be section relative relocations
Line 806... Line 842...
806
				struct bfd_link_info *info,
842
				struct bfd_link_info *info,
807
				unsigned long *section_sym_count)
843
				unsigned long *section_sym_count)
808
{
844
{
809
  unsigned long dynsymcount = 0;
845
  unsigned long dynsymcount = 0;
Line -... Line 846...
-
 
846
 
810
 
847
  if (bfd_link_pic (info)
811
  if (info->shared || elf_hash_table (info)->is_relocatable_executable)
848
      || elf_hash_table (info)->is_relocatable_executable)
812
    {
849
    {
813
      const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
850
      const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
814
      asection *p;
851
      asection *p;
815
      for (p = output_bfd->sections; p ; p = p->next)
852
      for (p = output_bfd->sections; p ; p = p->next)
Line 849... Line 886...
849
 
886
 
Line 850... Line 887...
850
/* Merge st_other field.  */
887
/* Merge st_other field.  */
851
 
888
 
852
static void
889
static void
853
elf_merge_st_other (bfd *abfd, struct elf_link_hash_entry *h,
890
elf_merge_st_other (bfd *abfd, struct elf_link_hash_entry *h,
854
		    Elf_Internal_Sym *isym, bfd_boolean definition,
891
		    const Elf_Internal_Sym *isym, asection *sec,
855
		    bfd_boolean dynamic)
892
		    bfd_boolean definition, bfd_boolean dynamic)
Line 856... Line 893...
856
{
893
{
857
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
894
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
858
 
-
 
859
  /* If st_other has a processor-specific meaning, specific
895
 
860
     code might be needed here. We never merge the visibility
896
  /* If st_other has a processor-specific meaning, specific
861
     attribute with the one from a dynamic object.  */
897
     code might be needed here.  */
Line 862... Line -...
862
  if (bed->elf_backend_merge_symbol_attribute)
-
 
863
    (*bed->elf_backend_merge_symbol_attribute) (h, isym, definition,
-
 
864
						dynamic);
-
 
865
 
898
  if (bed->elf_backend_merge_symbol_attribute)
866
  /* If this symbol has default visibility and the user has requested
-
 
867
     we not re-export it, then mark it as hidden.  */
-
 
868
  if (definition
-
 
869
      && !dynamic
-
 
870
      && (abfd->no_export
-
 
871
	  || (abfd->my_archive && abfd->my_archive->no_export))
-
 
872
      && ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL)
-
 
873
    isym->st_other = (STV_HIDDEN
899
    (*bed->elf_backend_merge_symbol_attribute) (h, isym, definition,
-
 
900
						dynamic);
874
		      | (isym->st_other & ~ELF_ST_VISIBILITY (-1)));
901
 
Line 875... Line 902...
875
 
902
  if (!dynamic)
876
  if (!dynamic && ELF_ST_VISIBILITY (isym->st_other) != 0)
903
    {
877
    {
-
 
878
      unsigned char hvis, symvis, other, nvis;
-
 
879
 
-
 
880
      /* Only merge the visibility. Leave the remainder of the
904
      unsigned symvis = ELF_ST_VISIBILITY (isym->st_other);
881
	 st_other field to elf_backend_merge_symbol_attribute.  */
905
      unsigned hvis = ELF_ST_VISIBILITY (h->other);
882
      other = h->other & ~ELF_ST_VISIBILITY (-1);
906
 
883
 
-
 
884
      /* Combine visibilities, using the most constraining one.  */
907
      /* Keep the most constraining visibility.  Leave the remainder
885
      hvis = ELF_ST_VISIBILITY (h->other);
908
	 of the st_other field to elf_backend_merge_symbol_attribute.  */
886
      symvis = ELF_ST_VISIBILITY (isym->st_other);
-
 
887
      if (! hvis)
909
      if (symvis - 1 < hvis - 1)
888
	nvis = symvis;
-
 
889
      else if (! symvis)
910
	h->other = symvis | (h->other & ~ELF_ST_VISIBILITY (-1));
890
	nvis = hvis;
-
 
891
      else
911
    }
Line 892... Line 912...
892
	nvis = hvis < symvis ? hvis : symvis;
912
  else if (definition
893
 
913
	   && ELF_ST_VISIBILITY (isym->st_other) != STV_DEFAULT
894
      h->other = other | nvis;
914
	   && (sec->flags & SEC_READONLY) == 0)
Line 920... Line 940...
920
		       bfd_boolean *pold_weak,
940
		       bfd_boolean *pold_weak,
921
		       unsigned int *pold_alignment,
941
		       unsigned int *pold_alignment,
922
		       bfd_boolean *skip,
942
		       bfd_boolean *skip,
923
		       bfd_boolean *override,
943
		       bfd_boolean *override,
924
		       bfd_boolean *type_change_ok,
944
		       bfd_boolean *type_change_ok,
925
		       bfd_boolean *size_change_ok)
945
		       bfd_boolean *size_change_ok,
-
 
946
		       bfd_boolean *matched)
926
{
947
{
927
  asection *sec, *oldsec;
948
  asection *sec, *oldsec;
928
  struct elf_link_hash_entry *h;
949
  struct elf_link_hash_entry *h;
929
  struct elf_link_hash_entry *hi;
950
  struct elf_link_hash_entry *hi;
930
  struct elf_link_hash_entry *flip;
951
  struct elf_link_hash_entry *flip;
931
  int bind;
952
  int bind;
932
  bfd *oldbfd;
953
  bfd *oldbfd;
933
  bfd_boolean newdyn, olddyn, olddef, newdef, newdyncommon, olddyncommon;
954
  bfd_boolean newdyn, olddyn, olddef, newdef, newdyncommon, olddyncommon;
934
  bfd_boolean newweak, oldweak, newfunc, oldfunc;
955
  bfd_boolean newweak, oldweak, newfunc, oldfunc;
935
  const struct elf_backend_data *bed;
956
  const struct elf_backend_data *bed;
-
 
957
  char *new_version;
Line 936... Line 958...
936
 
958
 
937
  *skip = FALSE;
959
  *skip = FALSE;
Line 938... Line 960...
938
  *override = FALSE;
960
  *override = FALSE;
Line 949... Line 971...
949
    return FALSE;
971
    return FALSE;
950
  *sym_hash = h;
972
  *sym_hash = h;
Line 951... Line 973...
951
 
973
 
Line -... Line 974...
-
 
974
  bed = get_elf_backend_data (abfd);
-
 
975
 
-
 
976
  /* NEW_VERSION is the symbol version of the new symbol.  */
-
 
977
  if (h->versioned != unversioned)
-
 
978
    {
-
 
979
      /* Symbol version is unknown or versioned.  */
-
 
980
      new_version = strrchr (name, ELF_VER_CHR);
-
 
981
      if (new_version)
-
 
982
	{
-
 
983
	  if (h->versioned == unknown)
-
 
984
	    {
-
 
985
	      if (new_version > name && new_version[-1] != ELF_VER_CHR)
-
 
986
		h->versioned = versioned_hidden;
-
 
987
	      else
-
 
988
		h->versioned = versioned;
-
 
989
	    }
-
 
990
	  new_version += 1;
-
 
991
	  if (new_version[0] == '\0')
-
 
992
	    new_version = NULL;
-
 
993
	}
-
 
994
      else
-
 
995
	h->versioned = unversioned;
-
 
996
    }
-
 
997
  else
952
  bed = get_elf_backend_data (abfd);
998
    new_version = NULL;
953
 
999
 
954
  /* For merging, we only care about real symbols.  But we need to make
1000
  /* For merging, we only care about real symbols.  But we need to make
955
     sure that indirect symbol dynamic flags are updated.  */
1001
     sure that indirect symbol dynamic flags are updated.  */
956
  hi = h;
1002
  hi = h;
957
  while (h->root.type == bfd_link_hash_indirect
1003
  while (h->root.type == bfd_link_hash_indirect
Line -... Line 1004...
-
 
1004
	 || h->root.type == bfd_link_hash_warning)
-
 
1005
    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
 
1006
 
-
 
1007
  if (!*matched)
-
 
1008
    {
-
 
1009
      if (hi == h || h->root.type == bfd_link_hash_new)
-
 
1010
	*matched = TRUE;
-
 
1011
      else
-
 
1012
	{
-
 
1013
	  /* OLD_HIDDEN is true if the existing symbol is only visible
-
 
1014
	     to the symbol with the same symbol version.  NEW_HIDDEN is
-
 
1015
	     true if the new symbol is only visible to the symbol with
-
 
1016
	     the same symbol version.  */
-
 
1017
	  bfd_boolean old_hidden = h->versioned == versioned_hidden;
-
 
1018
	  bfd_boolean new_hidden = hi->versioned == versioned_hidden;
-
 
1019
	  if (!old_hidden && !new_hidden)
-
 
1020
	    /* The new symbol matches the existing symbol if both
-
 
1021
	       aren't hidden.  */
-
 
1022
	    *matched = TRUE;
-
 
1023
	  else
-
 
1024
	    {
-
 
1025
	      /* OLD_VERSION is the symbol version of the existing
-
 
1026
		 symbol. */
-
 
1027
	      char *old_version;
-
 
1028
 
-
 
1029
	      if (h->versioned >= versioned)
-
 
1030
		old_version = strrchr (h->root.root.string,
-
 
1031
				       ELF_VER_CHR) + 1;
-
 
1032
	      else
-
 
1033
		 old_version = NULL;
-
 
1034
 
-
 
1035
	      /* The new symbol matches the existing symbol if they
-
 
1036
		 have the same symbol version.  */
-
 
1037
	      *matched = (old_version == new_version
-
 
1038
			  || (old_version != NULL
-
 
1039
			      && new_version != NULL
-
 
1040
			      && strcmp (old_version, new_version) == 0));
-
 
1041
	    }
958
	 || h->root.type == bfd_link_hash_warning)
1042
	}
959
    h = (struct elf_link_hash_entry *) h->root.u.i.link;
1043
    }
Line 960... Line 1044...
960
 
1044
 
961
  /* OLDBFD and OLDSEC are a BFD and an ASECTION associated with the
1045
  /* OLDBFD and OLDSEC are a BFD and an ASECTION associated with the
Line 1028... Line 1112...
1028
	      hi->ref_dynamic_nonweak = 1;
1112
	      hi->ref_dynamic_nonweak = 1;
1029
	    }
1113
	    }
1030
	}
1114
	}
1031
      else
1115
      else
1032
	{
1116
	{
-
 
1117
	  /* Update the existing symbol only if they match. */
-
 
1118
	  if (*matched)
1033
	  h->dynamic_def = 1;
1119
	    h->dynamic_def = 1;
1034
	  hi->dynamic_def = 1;
1120
	  hi->dynamic_def = 1;
1035
	}
1121
	}
1036
    }
1122
    }
Line 1085... Line 1171...
1085
  oldfunc = (h->type != STT_NOTYPE
1171
  oldfunc = (h->type != STT_NOTYPE
1086
	     && bed->is_function_type (h->type));
1172
	     && bed->is_function_type (h->type));
Line 1087... Line 1173...
1087
 
1173
 
1088
  /* When we try to create a default indirect symbol from the dynamic
1174
  /* When we try to create a default indirect symbol from the dynamic
1089
     definition with the default version, we skip it if its type and
1175
     definition with the default version, we skip it if its type and
1090
     the type of existing regular definition mismatch.  We only do it
-
 
1091
     if the existing regular definition won't be dynamic.  */
1176
     the type of existing regular definition mismatch.  */
1092
  if (pold_alignment == NULL
-
 
1093
      && !info->shared
-
 
1094
      && !info->export_dynamic
-
 
1095
      && !h->ref_dynamic
1177
  if (pold_alignment == NULL
1096
      && newdyn
1178
      && newdyn
1097
      && newdef
1179
      && newdef
1098
      && !olddyn
1180
      && !olddyn
1099
      && (olddef || h->root.type == bfd_link_hash_common)
1181
      && (((olddef || h->root.type == bfd_link_hash_common)
1100
      && ELF_ST_TYPE (sym->st_info) != h->type
1182
	   && ELF_ST_TYPE (sym->st_info) != h->type
1101
      && ELF_ST_TYPE (sym->st_info) != STT_NOTYPE
1183
	   && ELF_ST_TYPE (sym->st_info) != STT_NOTYPE
1102
      && h->type != STT_NOTYPE
1184
	   && h->type != STT_NOTYPE
-
 
1185
	   && !(newfunc && oldfunc))
-
 
1186
	  || (olddef
-
 
1187
	      && ((h->type == STT_GNU_IFUNC)
1103
      && !(newfunc && oldfunc))
1188
		  != (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)))))
1104
    {
1189
    {
1105
      *skip = TRUE;
1190
      *skip = TRUE;
1106
      return TRUE;
1191
      return TRUE;
Line 1107... Line 1192...
1107
    }
1192
    }
1108
 
1193
 
1109
  /* Plugin symbol type isn't currently set.  Stop bogus errors.  */
-
 
1110
  if (oldbfd != NULL && (oldbfd->flags & BFD_PLUGIN) != 0)
-
 
1111
    *type_change_ok = TRUE;
1194
  /* Check TLS symbols.  We don't check undefined symbols introduced
1112
 
1195
     by "ld -u" which have no type (and oldbfd NULL), and we don't
1113
  /* Check TLS symbol.  We don't check undefined symbol introduced by
1196
     check symbols from plugins because they also have no type.  */
-
 
1197
  if (oldbfd != NULL
1114
     "ld -u".  */
1198
      && (oldbfd->flags & BFD_PLUGIN) == 0
1115
  else if (oldbfd != NULL
1199
      && (abfd->flags & BFD_PLUGIN) == 0
1116
	   && ELF_ST_TYPE (sym->st_info) != h->type
1200
      && ELF_ST_TYPE (sym->st_info) != h->type
1117
	   && (ELF_ST_TYPE (sym->st_info) == STT_TLS || h->type == STT_TLS))
1201
      && (ELF_ST_TYPE (sym->st_info) == STT_TLS || h->type == STT_TLS))
1118
    {
1202
    {
Line 1435... Line 1519...
1435
    {
1519
    {
1436
      /* Don't skip new non-IR weak syms.  */
1520
      /* Don't skip new non-IR weak syms.  */
1437
      if (!(oldbfd != NULL
1521
      if (!(oldbfd != NULL
1438
	    && (oldbfd->flags & BFD_PLUGIN) != 0
1522
	    && (oldbfd->flags & BFD_PLUGIN) != 0
1439
	    && (abfd->flags & BFD_PLUGIN) == 0))
1523
	    && (abfd->flags & BFD_PLUGIN) == 0))
-
 
1524
	{
-
 
1525
	  newdef = FALSE;
1440
	*skip = TRUE;
1526
	  *skip = TRUE;
-
 
1527
	}
Line 1441... Line 1528...
1441
 
1528
 
1442
      /* Merge st_other.  If the symbol already has a dynamic index,
1529
      /* Merge st_other.  If the symbol already has a dynamic index,
1443
	 but visibility says it should not be visible, turn it into a
1530
	 but visibility says it should not be visible, turn it into a
1444
	 local symbol.  */
1531
	 local symbol.  */
1445
      elf_merge_st_other (abfd, h, sym, newdef, newdyn);
1532
      elf_merge_st_other (abfd, h, sym, sec, newdef, newdyn);
1446
      if (h->dynindx != -1)
1533
      if (h->dynindx != -1)
1447
	switch (ELF_ST_VISIBILITY (h->other))
1534
	switch (ELF_ST_VISIBILITY (h->other))
1448
	  {
1535
	  {
1449
	  case STV_INTERNAL:
1536
	  case STV_INTERNAL:
Line 1598... Line 1685...
1598
  bfd_boolean dynamic;
1685
  bfd_boolean dynamic;
1599
  bfd_boolean override;
1686
  bfd_boolean override;
1600
  char *p;
1687
  char *p;
1601
  size_t len, shortlen;
1688
  size_t len, shortlen;
1602
  asection *tmp_sec;
1689
  asection *tmp_sec;
-
 
1690
  bfd_boolean matched;
-
 
1691
 
-
 
1692
  if (h->versioned == unversioned || h->versioned == versioned_hidden)
-
 
1693
    return TRUE;
Line 1603... Line 1694...
1603
 
1694
 
1604
  /* If this symbol has a version, and it is the default version, we
1695
  /* If this symbol has a version, and it is the default version, we
1605
     create an indirect symbol from the default name to the fully
1696
     create an indirect symbol from the default name to the fully
1606
     decorated name.  This will cause external references which do not
1697
     decorated name.  This will cause external references which do not
1607
     specify a version to be bound to this version of the symbol.  */
1698
     specify a version to be bound to this version of the symbol.  */
1608
  p = strchr (name, ELF_VER_CHR);
1699
  p = strchr (name, ELF_VER_CHR);
-
 
1700
  if (h->versioned == unknown)
-
 
1701
    {
-
 
1702
      if (p == NULL)
-
 
1703
	{
1609
  if (p == NULL || p[1] != ELF_VER_CHR)
1704
	  h->versioned = unversioned;
-
 
1705
	  return TRUE;
-
 
1706
	}
-
 
1707
      else
-
 
1708
	{
-
 
1709
	  if (p[1] != ELF_VER_CHR)
-
 
1710
	    {
-
 
1711
	      h->versioned = versioned_hidden;
-
 
1712
	      return TRUE;
-
 
1713
	    }
-
 
1714
	  else
-
 
1715
	    h->versioned = versioned;
-
 
1716
	}
-
 
1717
    }
-
 
1718
  else
-
 
1719
    {
-
 
1720
      /* PR ld/19073: We may see an unversioned definition after the
-
 
1721
	 default version.  */
-
 
1722
      if (p == NULL)
-
 
1723
	return TRUE;
Line 1610... Line 1724...
1610
    return TRUE;
1724
    }
1611
 
1725
 
1612
  bed = get_elf_backend_data (abfd);
1726
  bed = get_elf_backend_data (abfd);
Line 1624... Line 1738...
1624
     symbol with this name.  For the purposes of the merge, act as
1738
     symbol with this name.  For the purposes of the merge, act as
1625
     though we were defining the symbol we just defined, although we
1739
     though we were defining the symbol we just defined, although we
1626
     actually going to define an indirect symbol.  */
1740
     actually going to define an indirect symbol.  */
1627
  type_change_ok = FALSE;
1741
  type_change_ok = FALSE;
1628
  size_change_ok = FALSE;
1742
  size_change_ok = FALSE;
-
 
1743
  matched = TRUE;
1629
  tmp_sec = sec;
1744
  tmp_sec = sec;
1630
  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
1745
  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
1631
			      &hi, poldbfd, NULL, NULL, &skip, &override,
1746
			      &hi, poldbfd, NULL, NULL, &skip, &override,
1632
			      &type_change_ok, &size_change_ok))
1747
			      &type_change_ok, &size_change_ok, &matched))
1633
    return FALSE;
1748
    return FALSE;
Line 1634... Line 1749...
1634
 
1749
 
1635
  if (skip)
1750
  if (skip)
Line 1636... Line 1751...
1636
    goto nondefault;
1751
    goto nondefault;
1637
 
1752
 
-
 
1753
  if (! override)
-
 
1754
    {
-
 
1755
      /* Add the default symbol if not performing a relocatable link.  */
1638
  if (! override)
1756
      if (! bfd_link_relocatable (info))
1639
    {
1757
	{
1640
      bh = &hi->root;
1758
	  bh = &hi->root;
-
 
1759
	  if (! (_bfd_generic_link_add_one_symbol
1641
      if (! (_bfd_generic_link_add_one_symbol
1760
		 (info, abfd, shortname, BSF_INDIRECT,
1642
	     (info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr,
1761
		  bfd_ind_section_ptr,
1643
	      0, name, FALSE, collect, &bh)))
1762
		  0, name, FALSE, collect, &bh)))
1644
	return FALSE;
1763
	    return FALSE;
-
 
1764
	  hi = (struct elf_link_hash_entry *) bh;
1645
      hi = (struct elf_link_hash_entry *) bh;
1765
	}
1646
    }
1766
    }
1647
  else
1767
  else
1648
    {
1768
    {
1649
      /* In this case the symbol named SHORTNAME is overriding the
1769
      /* In this case the symbol named SHORTNAME is overriding the
Line 1700... Line 1820...
1700
      struct elf_link_hash_entry *ht;
1820
      struct elf_link_hash_entry *ht;
Line 1701... Line 1821...
1701
 
1821
 
1702
      ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
1822
      ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
Line -... Line 1823...
-
 
1823
      (*bed->elf_backend_copy_indirect_symbol) (info, ht, hi);
-
 
1824
 
-
 
1825
      /* A reference to the SHORTNAME symbol from a dynamic library
-
 
1826
	 will be satisfied by the versioned symbol at runtime.  In
-
 
1827
	 effect, we have a reference to the versioned symbol.  */
-
 
1828
      ht->ref_dynamic_nonweak |= hi->ref_dynamic_nonweak;
1703
      (*bed->elf_backend_copy_indirect_symbol) (info, ht, hi);
1829
      hi->dynamic_def |= ht->dynamic_def;
1704
 
1830
 
1705
      /* See if the new flags lead us to realize that the symbol must
1831
      /* See if the new flags lead us to realize that the symbol must
1706
	 be dynamic.  */
1832
	 be dynamic.  */
1707
      if (! *dynsym)
1833
      if (! *dynsym)
1708
	{
1834
	{
1709
	  if (! dynamic)
1835
	  if (! dynamic)
1710
	    {
1836
	    {
1711
	      if (! info->executable
1837
	      if (! bfd_link_executable (info)
1712
		  || hi->def_dynamic
1838
		  || hi->def_dynamic
1713
		  || hi->ref_dynamic)
1839
		  || hi->ref_dynamic)
1714
		*dynsym = TRUE;
1840
		*dynsym = TRUE;
Line 1735... Line 1861...
1735
  /* Once again, merge with any existing symbol.  */
1861
  /* Once again, merge with any existing symbol.  */
1736
  type_change_ok = FALSE;
1862
  type_change_ok = FALSE;
1737
  size_change_ok = FALSE;
1863
  size_change_ok = FALSE;
1738
  tmp_sec = sec;
1864
  tmp_sec = sec;
1739
  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
1865
  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
1740
			      &hi, NULL, NULL, NULL, &skip, &override,
1866
			      &hi, poldbfd, NULL, NULL, &skip, &override,
1741
			      &type_change_ok, &size_change_ok))
1867
			      &type_change_ok, &size_change_ok, &matched))
1742
    return FALSE;
1868
    return FALSE;
Line 1743... Line 1869...
1743
 
1869
 
1744
  if (skip)
1870
  if (skip)
Line 1769... Line 1895...
1769
	 to the user in that case.  */
1895
	 to the user in that case.  */
Line 1770... Line 1896...
1770
 
1896
 
1771
      if (hi->root.type == bfd_link_hash_indirect)
1897
      if (hi->root.type == bfd_link_hash_indirect)
1772
	{
1898
	{
-
 
1899
	  (*bed->elf_backend_copy_indirect_symbol) (info, h, hi);
-
 
1900
	  h->ref_dynamic_nonweak |= hi->ref_dynamic_nonweak;
Line 1773... Line 1901...
1773
	  (*bed->elf_backend_copy_indirect_symbol) (info, h, hi);
1901
	  hi->dynamic_def |= h->dynamic_def;
1774
 
1902
 
1775
	  /* See if the new flags lead us to realize that the symbol
1903
	  /* See if the new flags lead us to realize that the symbol
1776
	     must be dynamic.  */
1904
	     must be dynamic.  */
1777
	  if (! *dynsym)
1905
	  if (! *dynsym)
1778
	    {
1906
	    {
1779
	      if (! dynamic)
1907
	      if (! dynamic)
1780
		{
1908
		{
1781
		  if (! info->executable
1909
		  if (! bfd_link_executable (info)
1782
		      || hi->ref_dynamic)
1910
		      || hi->ref_dynamic)
1783
		    *dynsym = TRUE;
1911
		    *dynsym = TRUE;
1784
		}
1912
		}
Line 1842... Line 1970...
1842
  /* We only care about symbols defined in shared objects with version
1970
  /* We only care about symbols defined in shared objects with version
1843
     information.  */
1971
     information.  */
1844
  if (!h->def_dynamic
1972
  if (!h->def_dynamic
1845
      || h->def_regular
1973
      || h->def_regular
1846
      || h->dynindx == -1
1974
      || h->dynindx == -1
1847
      || h->verinfo.verdef == NULL)
1975
      || h->verinfo.verdef == NULL
-
 
1976
      || (elf_dyn_lib_class (h->verinfo.verdef->vd_bfd)
-
 
1977
	  & (DYN_AS_NEEDED | DYN_DT_NEEDED | DYN_NO_NEEDED)))
1848
    return TRUE;
1978
    return TRUE;
Line 1849... Line 1979...
1849
 
1979
 
1850
  /* See if we already know about this version.  */
1980
  /* See if we already know about this version.  */
1851
  for (t = elf_tdata (rinfo->info->output_bfd)->verref;
1981
  for (t = elf_tdata (rinfo->info->output_bfd)->verref;
Line 1942... Line 2072...
1942
  bed = get_elf_backend_data (info->output_bfd);
2072
  bed = get_elf_backend_data (info->output_bfd);
1943
  p = strchr (h->root.root.string, ELF_VER_CHR);
2073
  p = strchr (h->root.root.string, ELF_VER_CHR);
1944
  if (p != NULL && h->verinfo.vertree == NULL)
2074
  if (p != NULL && h->verinfo.vertree == NULL)
1945
    {
2075
    {
1946
      struct bfd_elf_version_tree *t;
2076
      struct bfd_elf_version_tree *t;
1947
      bfd_boolean hidden;
-
 
Line 1948... Line -...
1948
 
-
 
1949
      hidden = TRUE;
-
 
1950
 
-
 
1951
      /* There are two consecutive ELF_VER_CHR characters if this is
-
 
1952
	 not a hidden symbol.  */
2077
 
1953
      ++p;
2078
      ++p;
1954
      if (*p == ELF_VER_CHR)
-
 
1955
	{
-
 
1956
	  hidden = FALSE;
2079
      if (*p == ELF_VER_CHR)
1957
	  ++p;
-
 
Line 1958... Line 2080...
1958
	}
2080
	++p;
1959
 
2081
 
1960
      /* If there is no version string, we can just return out.  */
-
 
1961
      if (*p == '\0')
-
 
1962
	{
-
 
1963
	  if (hidden)
2082
      /* If there is no version string, we can just return out.  */
1964
	    h->hidden = 1;
-
 
Line 1965... Line 2083...
1965
	  return TRUE;
2083
      if (*p == '\0')
1966
	}
2084
	return TRUE;
1967
 
2085
 
1968
      /* Look for the version.  If we find it, it is no longer weak.  */
2086
      /* Look for the version.  If we find it, it is no longer weak.  */
Line 2009... Line 2127...
2009
	    }
2127
	    }
2010
	}
2128
	}
Line 2011... Line 2129...
2011
 
2129
 
2012
      /* If we are building an application, we need to create a
2130
      /* If we are building an application, we need to create a
2013
	 version node for this version.  */
2131
	 version node for this version.  */
2014
      if (t == NULL && info->executable)
2132
      if (t == NULL && bfd_link_executable (info))
2015
	{
2133
	{
2016
	  struct bfd_elf_version_tree **pp;
2134
	  struct bfd_elf_version_tree **pp;
Line 2017... Line 2135...
2017
	  int version_index;
2135
	  int version_index;
Line 2057... Line 2175...
2057
	     info->output_bfd, h->root.root.string);
2175
	     info->output_bfd, h->root.root.string);
2058
	  bfd_set_error (bfd_error_bad_value);
2176
	  bfd_set_error (bfd_error_bad_value);
2059
	  sinfo->failed = TRUE;
2177
	  sinfo->failed = TRUE;
2060
	  return FALSE;
2178
	  return FALSE;
2061
	}
2179
	}
2062
 
-
 
2063
      if (hidden)
-
 
2064
	h->hidden = 1;
-
 
2065
    }
2180
    }
Line 2066... Line 2181...
2066
 
2181
 
2067
  /* If we don't have a version for this symbol, see if we can find
2182
  /* If we don't have a version for this symbol, see if we can find
2068
     something.  */
2183
     something.  */
Line 2293... Line 2408...
2293
 
2408
 
2294
  if (reldata->hashes == NULL && reldata->count)
2409
  if (reldata->hashes == NULL && reldata->count)
2295
    {
2410
    {
Line 2296... Line 2411...
2296
      struct elf_link_hash_entry **p;
2411
      struct elf_link_hash_entry **p;
2297
 
2412
 
2298
      p = (struct elf_link_hash_entry **)
2413
      p = ((struct elf_link_hash_entry **)
2299
          bfd_zmalloc (reldata->count * sizeof (struct elf_link_hash_entry *));
2414
	   bfd_zmalloc (reldata->count * sizeof (*p)));
Line 2300... Line 2415...
2300
      if (p == NULL)
2415
      if (p == NULL)
2301
	return FALSE;
2416
	return FALSE;
Line 2374... Line 2489...
2374
 
2489
 
2375
bfd_boolean
2490
bfd_boolean
2376
_bfd_elf_link_hash_fixup_symbol (struct bfd_link_info *info,
2491
_bfd_elf_link_hash_fixup_symbol (struct bfd_link_info *info,
2377
				 struct elf_link_hash_entry *h)
2492
				 struct elf_link_hash_entry *h)
2378
{
2493
{
2379
  if (info->pie
2494
  if (bfd_link_pie (info)
2380
      && h->dynindx == -1
2495
      && h->dynindx == -1
2381
      && h->root.type == bfd_link_hash_undefweak)
2496
      && h->root.type == bfd_link_hash_undefweak)
Line 2382... Line 2497...
2382
    return bfd_elf_link_record_dynamic_symbol (info, h);
2497
    return bfd_elf_link_record_dynamic_symbol (info, h);
Line 2477... Line 2592...
2477
     symbol was defined in a regular object, then it actually doesn't
2592
     symbol was defined in a regular object, then it actually doesn't
2478
     need a PLT entry.  Likewise, if the symbol has non-default
2593
     need a PLT entry.  Likewise, if the symbol has non-default
2479
     visibility.  If the symbol has hidden or internal visibility, we
2594
     visibility.  If the symbol has hidden or internal visibility, we
2480
     will force it local.  */
2595
     will force it local.  */
2481
  if (h->needs_plt
2596
  if (h->needs_plt
2482
      && eif->info->shared
2597
      && bfd_link_pic (eif->info)
2483
      && is_elf_hash_table (eif->info->hash)
2598
      && is_elf_hash_table (eif->info->hash)
2484
      && (SYMBOLIC_BIND (eif->info, h)
2599
      && (SYMBOLIC_BIND (eif->info, h)
2485
	  || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
2600
	  || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
2486
      && h->def_regular)
2601
      && h->def_regular)
2487
    {
2602
    {
Line 2644... Line 2759...
2644
 
2759
 
2645
/* Adjust the dynamic symbol, H, for copy in the dynamic bss section,
2760
/* Adjust the dynamic symbol, H, for copy in the dynamic bss section,
Line 2646... Line 2761...
2646
   DYNBSS.  */
2761
   DYNBSS.  */
2647
 
2762
 
-
 
2763
bfd_boolean
2648
bfd_boolean
2764
_bfd_elf_adjust_dynamic_copy (struct bfd_link_info *info,
2649
_bfd_elf_adjust_dynamic_copy (struct elf_link_hash_entry *h,
2765
			      struct elf_link_hash_entry *h,
2650
			      asection *dynbss)
2766
			      asection *dynbss)
2651
{
2767
{
2652
  unsigned int power_of_two;
2768
  unsigned int power_of_two;
Line 2683... Line 2799...
2683
  h->root.u.def.value = dynbss->size;
2799
  h->root.u.def.value = dynbss->size;
Line 2684... Line 2800...
2684
 
2800
 
2685
  /* Increment the size of DYNBSS to make room for the symbol.  */
2801
  /* Increment the size of DYNBSS to make room for the symbol.  */
Line -... Line 2802...
-
 
2802
  dynbss->size += h->size;
-
 
2803
 
-
 
2804
  /* No error if extern_protected_data is true.  */
-
 
2805
  if (h->protected_def
-
 
2806
      && (!info->extern_protected_data
-
 
2807
	  || (info->extern_protected_data < 0
-
 
2808
	      && !get_elf_backend_data (dynbss->owner)->extern_protected_data)))
-
 
2809
    info->callbacks->einfo
-
 
2810
      (_("%P: copy reloc against protected `%T' is dangerous\n"),
2686
  dynbss->size += h->size;
2811
       h->root.root.string);
2687
 
2812
 
Line 2688... Line 2813...
2688
  return TRUE;
2813
  return TRUE;
2689
}
2814
}
Line 2739... Line 2864...
2739
  if (h->forced_local)
2864
  if (h->forced_local)
2740
    return FALSE;
2865
    return FALSE;
Line 2741... Line 2866...
2741
 
2866
 
2742
  /* Identify the cases where name binding rules say that a
2867
  /* Identify the cases where name binding rules say that a
2743
     visible symbol resolves locally.  */
2868
     visible symbol resolves locally.  */
-
 
2869
  binding_stays_local_p = (bfd_link_executable (info)
Line 2744... Line 2870...
2744
  binding_stays_local_p = info->executable || SYMBOLIC_BIND (info, h);
2870
			   || SYMBOLIC_BIND (info, h));
2745
 
2871
 
2746
  switch (ELF_ST_VISIBILITY (h->other))
2872
  switch (ELF_ST_VISIBILITY (h->other))
2747
    {
2873
    {
Line 2824... Line 2950...
2824
    return TRUE;
2950
    return TRUE;
Line 2825... Line 2951...
2825
 
2951
 
2826
  /* At this point, we know the symbol is defined and dynamic.  In an
2952
  /* At this point, we know the symbol is defined and dynamic.  In an
2827
     executable it must resolve locally, likewise when building symbolic
2953
     executable it must resolve locally, likewise when building symbolic
2828
     shared libraries.  */
2954
     shared libraries.  */
2829
  if (info->executable || SYMBOLIC_BIND (info, h))
2955
  if (bfd_link_executable (info) || SYMBOLIC_BIND (info, h))
Line 2830... Line 2956...
2830
    return TRUE;
2956
    return TRUE;
2831
 
2957
 
2832
  /* Now deal with defined dynamic symbols in shared libraries.  Ones
2958
  /* Now deal with defined dynamic symbols in shared libraries.  Ones
Line 2838... Line 2964...
2838
  if (!is_elf_hash_table (hash_table))
2964
  if (!is_elf_hash_table (hash_table))
2839
    return TRUE;
2965
    return TRUE;
Line 2840... Line 2966...
2840
 
2966
 
Line -... Line 2967...
-
 
2967
  bed = get_elf_backend_data (hash_table->dynobj);
2841
  bed = get_elf_backend_data (hash_table->dynobj);
2968
 
-
 
2969
  /* If extern_protected_data is false, STV_PROTECTED non-function
-
 
2970
     symbols are local.  */
-
 
2971
  if ((!info->extern_protected_data
2842
 
2972
       || (info->extern_protected_data < 0
2843
  /* STV_PROTECTED non-function symbols are local.  */
2973
	   && !bed->extern_protected_data))
Line 2844... Line 2974...
2844
  if (!bed->is_function_type (h->type))
2974
      && !bed->is_function_type (h->type))
2845
    return TRUE;
2975
    return TRUE;
2846
 
2976
 
Line 2938... Line 3068...
2938
 
3068
 
2939
  abfd = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
3069
  abfd = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
2940
  if (abfd == NULL)
3070
  if (abfd == NULL)
Line -... Line 3071...
-
 
3071
    return FALSE;
2941
    return FALSE;
3072
 
2942
 
3073
  /* Return FALSE if the object has been claimed by plugin.  */
Line 2943... Line -...
2943
  if (! bfd_check_format (abfd, bfd_object))
-
 
2944
    return FALSE;
-
 
2945
 
-
 
2946
  /* If we have already included the element containing this symbol in the
-
 
2947
     link then we do not need to include it again.  Just claim that any symbol
3074
  if (abfd->plugin_format == bfd_plugin_yes)
2948
     it contains is not a definition, so that our caller will not decide to
3075
    return FALSE;
Line 2949... Line 3076...
2949
     (re)include this element.  */
3076
 
2950
  if (abfd->archive_pass)
3077
  if (! bfd_check_format (abfd, bfd_object))
2951
    return FALSE;
3078
    return FALSE;
Line 3103... Line 3230...
3103
 
3230
 
3104
static bfd_boolean
3231
static bfd_boolean
3105
on_needed_list (const char *soname, struct bfd_link_needed_list *needed)
3232
on_needed_list (const char *soname, struct bfd_link_needed_list *needed)
3106
{
3233
{
-
 
3234
  for (; needed != NULL; needed = needed->next)
3107
  for (; needed != NULL; needed = needed->next)
3235
    if ((elf_dyn_lib_class (needed->by) & DYN_AS_NEEDED) == 0
3108
    if (strcmp (soname, needed->name) == 0)
3236
	&& strcmp (soname, needed->name) == 0)
Line 3109... Line 3237...
3109
      return TRUE;
3237
      return TRUE;
3110
 
3238
 
Line 3124... Line 3252...
3124
  vdiff = h1->root.u.def.value - h2->root.u.def.value;
3252
  vdiff = h1->root.u.def.value - h2->root.u.def.value;
3125
  if (vdiff != 0)
3253
  if (vdiff != 0)
3126
    return vdiff > 0 ? 1 : -1;
3254
    return vdiff > 0 ? 1 : -1;
3127
  else
3255
  else
3128
    {
3256
    {
3129
      long sdiff = h1->root.u.def.section->id - h2->root.u.def.section->id;
3257
      int sdiff = h1->root.u.def.section->id - h2->root.u.def.section->id;
3130
      if (sdiff != 0)
3258
      if (sdiff != 0)
3131
	return sdiff > 0 ? 1 : -1;
3259
	return sdiff > 0 ? 1 : -1;
3132
    }
3260
    }
3133
  vdiff = h1->size - h2->size;
3261
  vdiff = h1->size - h2->size;
3134
  return vdiff == 0 ? 0 : vdiff > 0 ? 1 : -1;
3262
  return vdiff == 0 ? 0 : vdiff > 0 ? 1 : -1;
Line 3316... Line 3444...
3316
bfd_boolean
3444
bfd_boolean
3317
_bfd_elf_notice_as_needed (bfd *ibfd,
3445
_bfd_elf_notice_as_needed (bfd *ibfd,
3318
			   struct bfd_link_info *info,
3446
			   struct bfd_link_info *info,
3319
			   enum notice_asneeded_action act)
3447
			   enum notice_asneeded_action act)
3320
{
3448
{
3321
  return (*info->callbacks->notice) (info, NULL, ibfd, NULL, act, 0, NULL);
3449
  return (*info->callbacks->notice) (info, NULL, NULL, ibfd, NULL, act, 0);
3322
}
3450
}
Line 3323... Line 3451...
3323
 
3451
 
Line 3324... Line 3452...
3324
/* Add symbols from an ELF object file to the linker hash table.  */
3452
/* Add symbols from an ELF object file to the linker hash table.  */
Line 3355... Line 3483...
3355
  struct bfd_link_hash_entry *old_undefs_tail = NULL;
3483
  struct bfd_link_hash_entry *old_undefs_tail = NULL;
3356
  long old_dynsymcount = 0;
3484
  long old_dynsymcount = 0;
3357
  bfd_size_type old_dynstr_size = 0;
3485
  bfd_size_type old_dynstr_size = 0;
3358
  size_t tabsize = 0;
3486
  size_t tabsize = 0;
3359
  asection *s;
3487
  asection *s;
-
 
3488
  bfd_boolean just_syms;
Line 3360... Line 3489...
3360
 
3489
 
3361
  htab = elf_hash_table (info);
3490
  htab = elf_hash_table (info);
Line 3362... Line 3491...
3362
  bed = get_elf_backend_data (abfd);
3491
  bed = get_elf_backend_data (abfd);
Line 3368... Line 3497...
3368
      dynamic = TRUE;
3497
      dynamic = TRUE;
Line 3369... Line 3498...
3369
 
3498
 
3370
      /* You can't use -r against a dynamic object.  Also, there's no
3499
      /* You can't use -r against a dynamic object.  Also, there's no
3371
	 hope of using a dynamic object which does not exactly match
3500
	 hope of using a dynamic object which does not exactly match
3372
	 the format of the output file.  */
3501
	 the format of the output file.  */
3373
      if (info->relocatable
3502
      if (bfd_link_relocatable (info)
3374
	  || !is_elf_hash_table (htab)
3503
	  || !is_elf_hash_table (htab)
3375
	  || info->output_bfd->xvec != abfd->xvec)
3504
	  || info->output_bfd->xvec != abfd->xvec)
3376
	{
3505
	{
3377
	  if (info->relocatable)
3506
	  if (bfd_link_relocatable (info))
3378
	    bfd_set_error (bfd_error_invalid_operation);
3507
	    bfd_set_error (bfd_error_invalid_operation);
3379
	  else
3508
	  else
3380
	    bfd_set_error (bfd_error_wrong_format);
3509
	    bfd_set_error (bfd_error_wrong_format);
3381
	  goto error_return;
3510
	  goto error_return;
Line 3445... Line 3574...
3445
	  if (! (_bfd_generic_link_add_one_symbol
3574
	  if (! (_bfd_generic_link_add_one_symbol
3446
		 (info, abfd, name, BSF_WARNING, s, 0, msg,
3575
		 (info, abfd, name, BSF_WARNING, s, 0, msg,
3447
		  FALSE, bed->collect, NULL)))
3576
		  FALSE, bed->collect, NULL)))
3448
	    goto error_return;
3577
	    goto error_return;
Line 3449... Line 3578...
3449
 
3578
 
3450
	  if (!info->relocatable && info->executable)
3579
	  if (bfd_link_executable (info))
3451
	    {
3580
	    {
3452
	      /* Clobber the section size so that the warning does
3581
	      /* Clobber the section size so that the warning does
3453
		 not get copied into the output file.  */
3582
		 not get copied into the output file.  */
Line 3458... Line 3587...
3458
	      s->flags |= SEC_EXCLUDE;
3587
	      s->flags |= SEC_EXCLUDE;
3459
	    }
3588
	    }
3460
	}
3589
	}
3461
    }
3590
    }
Line -... Line 3591...
-
 
3591
 
-
 
3592
  just_syms = ((s = abfd->sections) != NULL
-
 
3593
	       && s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS);
3462
 
3594
 
3463
  add_needed = TRUE;
3595
  add_needed = TRUE;
3464
  if (! dynamic)
3596
  if (! dynamic)
3465
    {
3597
    {
3466
      /* If we are creating a shared library, create all the dynamic
3598
      /* If we are creating a shared library, create all the dynamic
3467
	 sections immediately.  We need to attach them to something,
3599
	 sections immediately.  We need to attach them to something,
3468
	 so we attach them to this BFD, provided it is the right
3600
	 so we attach them to this BFD, provided it is the right
-
 
3601
	 format and is not from ld --just-symbols.  FIXME: If there
3469
	 format.  FIXME: If there are no input BFD's of the same
3602
	 are no input BFD's of the same format as the output, we can't
3470
	 format as the output, we can't make a shared library.  */
3603
	 make a shared library.  */
-
 
3604
      if (!just_syms
3471
      if (info->shared
3605
	  && bfd_link_pic (info)
3472
	  && is_elf_hash_table (htab)
3606
	  && is_elf_hash_table (htab)
3473
	  && info->output_bfd->xvec == abfd->xvec
3607
	  && info->output_bfd->xvec == abfd->xvec
3474
	  && !htab->dynamic_sections_created)
3608
	  && !htab->dynamic_sections_created)
3475
	{
3609
	{
Line 3486... Line 3620...
3486
      struct bfd_link_needed_list *rpath = NULL, *runpath = NULL;
3620
      struct bfd_link_needed_list *rpath = NULL, *runpath = NULL;
3487
      int ret;
3621
      int ret;
Line 3488... Line 3622...
3488
 
3622
 
3489
      /* ld --just-symbols and dynamic objects don't mix very well.
3623
      /* ld --just-symbols and dynamic objects don't mix very well.
3490
	 ld shouldn't allow it.  */
3624
	 ld shouldn't allow it.  */
3491
      if ((s = abfd->sections) != NULL
-
 
3492
	  && s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
3625
      if (just_syms)
Line 3493... Line 3626...
3493
	abort ();
3626
	abort ();
3494
 
3627
 
3495
      /* If this dynamic lib was specified on the command line with
3628
      /* If this dynamic lib was specified on the command line with
Line 3833... Line 3966...
3833
      bfd_boolean old_weak;
3966
      bfd_boolean old_weak;
3834
      bfd_boolean override;
3967
      bfd_boolean override;
3835
      bfd_boolean common;
3968
      bfd_boolean common;
3836
      unsigned int old_alignment;
3969
      unsigned int old_alignment;
3837
      bfd *old_bfd;
3970
      bfd *old_bfd;
-
 
3971
      bfd_boolean matched;
Line 3838... Line 3972...
3838
 
3972
 
Line 3839... Line 3973...
3839
      override = FALSE;
3973
      override = FALSE;
3840
 
3974
 
Line 3918... Line 4052...
3918
	    }
4052
	    }
3919
	  sec = xc;
4053
	  sec = xc;
3920
	}
4054
	}
3921
      else if (isym->st_shndx == SHN_COMMON
4055
      else if (isym->st_shndx == SHN_COMMON
3922
	       && ELF_ST_TYPE (isym->st_info) == STT_TLS
4056
	       && ELF_ST_TYPE (isym->st_info) == STT_TLS
3923
	       && !info->relocatable)
4057
	       && !bfd_link_relocatable (info))
3924
	{
4058
	{
3925
	  asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon");
4059
	  asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon");
Line 3926... Line 4060...
3926
 
4060
 
3927
	  if (tcomm == NULL)
4061
	  if (tcomm == NULL)
Line 3967... Line 4101...
3967
	definition = TRUE;
4101
	definition = TRUE;
Line 3968... Line 4102...
3968
 
4102
 
3969
      size_change_ok = FALSE;
4103
      size_change_ok = FALSE;
3970
      type_change_ok = bed->type_change_ok;
4104
      type_change_ok = bed->type_change_ok;
-
 
4105
      old_weak = FALSE;
3971
      old_weak = FALSE;
4106
      matched = FALSE;
3972
      old_alignment = 0;
4107
      old_alignment = 0;
3973
      old_bfd = NULL;
4108
      old_bfd = NULL;
Line 3974... Line 4109...
3974
      new_sec = sec;
4109
      new_sec = sec;
Line 4084... Line 4219...
4084
	      memcpy (p, verstr, verlen + 1);
4219
	      memcpy (p, verstr, verlen + 1);
Line 4085... Line 4220...
4085
 
4220
 
4086
	      name = newname;
4221
	      name = newname;
Line -... Line 4222...
-
 
4222
	    }
-
 
4223
 
-
 
4224
	  /* If this symbol has default visibility and the user has
-
 
4225
	     requested we not re-export it, then mark it as hidden.  */
-
 
4226
	  if (!bfd_is_und_section (sec)
-
 
4227
	      && !dynamic
-
 
4228
	      && abfd->no_export
-
 
4229
	      && ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL)
-
 
4230
	    isym->st_other = (STV_HIDDEN
4087
	    }
4231
			      | (isym->st_other & ~ELF_ST_VISIBILITY (-1)));
4088
 
4232
 
4089
	  if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value,
4233
	  if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value,
4090
				      sym_hash, &old_bfd, &old_weak,
4234
				      sym_hash, &old_bfd, &old_weak,
-
 
4235
				      &old_alignment, &skip, &override,
4091
				      &old_alignment, &skip, &override,
4236
				      &type_change_ok, &size_change_ok,
Line 4092... Line 4237...
4092
				      &type_change_ok, &size_change_ok))
4237
				      &matched))
4093
	    goto error_free_vers;
4238
	    goto error_free_vers;
Line -... Line 4239...
-
 
4239
 
-
 
4240
	  if (skip)
4094
 
4241
	    continue;
4095
	  if (skip)
4242
 
Line 4096... Line 4243...
4096
	    continue;
4243
	  /* Override a definition only if the new symbol matches the
4097
 
4244
	     existing one.  */
4098
	  if (override)
4245
	  if (override && matched)
Line 4201... Line 4348...
4201
		}
4348
		}
Line 4202... Line 4349...
4202
 
4349
 
4203
	      /* If the indirect symbol has been forced local, don't
4350
	      /* If the indirect symbol has been forced local, don't
4204
		 make the real symbol dynamic.  */
4351
		 make the real symbol dynamic.  */
4205
	      if ((h == hi || !hi->forced_local)
4352
	      if ((h == hi || !hi->forced_local)
4206
		  && (! info->executable
4353
		  && (bfd_link_dll (info)
4207
		      || h->def_dynamic
4354
		      || h->def_dynamic
4208
		      || h->ref_dynamic))
4355
		      || h->ref_dynamic))
4209
		dynsym = TRUE;
4356
		dynsym = TRUE;
4210
	    }
4357
	    }
Line 4350... Line 4497...
4350
		  h->type = type;
4497
		  h->type = type;
4351
		}
4498
		}
4352
	    }
4499
	    }
Line 4353... Line 4500...
4353
 
4500
 
4354
	  /* Merge st_other field.  */
4501
	  /* Merge st_other field.  */
Line 4355... Line 4502...
4355
	  elf_merge_st_other (abfd, h, isym, definition, dynamic);
4502
	  elf_merge_st_other (abfd, h, isym, sec, definition, dynamic);
-
 
4503
 
4356
 
4504
	  /* We don't want to make debug symbol dynamic.  */
-
 
4505
	  if (definition
4357
	  /* We don't want to make debug symbol dynamic.  */
4506
	      && (sec->flags & SEC_DEBUGGING)
Line 4358... Line 4507...
4358
	  if (definition && (sec->flags & SEC_DEBUGGING) && !info->relocatable)
4507
	      && !bfd_link_relocatable (info))
4359
	    dynsym = FALSE;
4508
	    dynsym = FALSE;
4360
 
4509
 
Line 4377... Line 4526...
4377
		     aliases can be checked.  */
4526
		     aliases can be checked.  */
4378
		  if (!nondeflt_vers)
4527
		  if (!nondeflt_vers)
4379
		    {
4528
		    {
4380
		      amt = ((isymend - isym + 1)
4529
		      amt = ((isymend - isym + 1)
4381
			     * sizeof (struct elf_link_hash_entry *));
4530
			     * sizeof (struct elf_link_hash_entry *));
4382
		      nondeflt_vers =
4531
		      nondeflt_vers
4383
                          (struct elf_link_hash_entry **) bfd_malloc (amt);
4532
			= (struct elf_link_hash_entry **) bfd_malloc (amt);
4384
		      if (!nondeflt_vers)
4533
		      if (!nondeflt_vers)
4385
			goto error_free_vers;
4534
			goto error_free_vers;
4386
		    }
4535
		    }
4387
		  nondeflt_vers[nondeflt_vers_cnt++] = h;
4536
		  nondeflt_vers[nondeflt_vers_cnt++] = h;
4388
		}
4537
		}
Line 4425... Line 4574...
4425
		      && !on_needed_list (elf_dt_name (abfd), htab->needed))))
4574
		      && !on_needed_list (elf_dt_name (abfd), htab->needed))))
4426
	    {
4575
	    {
4427
	      int ret;
4576
	      int ret;
4428
	      const char *soname = elf_dt_name (abfd);
4577
	      const char *soname = elf_dt_name (abfd);
Line -... Line 4578...
-
 
4578
 
-
 
4579
	      info->callbacks->minfo ("%!", soname, old_bfd,
-
 
4580
				      h->root.root.string);
4429
 
4581
 
4430
	      /* A symbol from a library loaded via DT_NEEDED of some
4582
	      /* A symbol from a library loaded via DT_NEEDED of some
4431
		 other library is referenced by a regular object.
4583
		 other library is referenced by a regular object.
4432
		 Add a DT_NEEDED entry for it.  Issue an error if
4584
		 Add a DT_NEEDED entry for it.  Issue an error if
4433
		 --no-add-needed is used and the reference was not
4585
		 --no-add-needed is used and the reference was not
Line 4550... Line 4702...
4550
	goto error_free_vers;
4702
	goto error_free_vers;
4551
      free (old_tab);
4703
      free (old_tab);
4552
      old_tab = NULL;
4704
      old_tab = NULL;
4553
    }
4705
    }
Line 4554... Line 4706...
4554
 
4706
 
-
 
4707
  /* Now that all the symbols from this input file are created, if
4555
  /* Now that all the symbols from this input file are created, handle
4708
     not performing a relocatable link, handle .symver foo, foo@BAR
4556
     .symver foo, foo@BAR such that any relocs against foo become foo@BAR.  */
4709
     such that any relocs against foo become foo@BAR.  */
4557
  if (nondeflt_vers != NULL)
4710
  if (!bfd_link_relocatable (info) && nondeflt_vers != NULL)
4558
    {
4711
    {
Line 4559... Line 4712...
4559
      bfd_size_type cnt, symidx;
4712
      bfd_size_type cnt, symidx;
4560
 
4713
 
Line 4682... Line 4835...
4682
		j = idx;
4835
		j = idx;
4683
	      else if (vdiff > 0)
4836
	      else if (vdiff > 0)
4684
		i = idx + 1;
4837
		i = idx + 1;
4685
	      else
4838
	      else
4686
		{
4839
		{
4687
		  long sdiff = slook->id - h->root.u.def.section->id;
4840
		  int sdiff = slook->id - h->root.u.def.section->id;
4688
		  if (sdiff < 0)
4841
		  if (sdiff < 0)
4689
		    j = idx;
4842
		    j = idx;
4690
		  else if (sdiff > 0)
4843
		  else if (sdiff > 0)
4691
		    i = idx + 1;
4844
		    i = idx + 1;
4692
		  else
4845
		  else
Line 4850... Line 5003...
4850
  if (is_elf_hash_table (htab) && add_needed)
5003
  if (is_elf_hash_table (htab) && add_needed)
4851
    {
5004
    {
4852
      /* Add this bfd to the loaded list.  */
5005
      /* Add this bfd to the loaded list.  */
4853
      struct elf_link_loaded_list *n;
5006
      struct elf_link_loaded_list *n;
Line 4854... Line 5007...
4854
 
5007
 
4855
      n = (struct elf_link_loaded_list *)
-
 
4856
          bfd_alloc (abfd, sizeof (struct elf_link_loaded_list));
5008
      n = (struct elf_link_loaded_list *) bfd_alloc (abfd, sizeof (*n));
4857
      if (n == NULL)
5009
      if (n == NULL)
4858
	goto error_return;
5010
	goto error_return;
4859
      n->abfd = abfd;
5011
      n->abfd = abfd;
4860
      n->next = htab->loaded;
5012
      n->next = htab->loaded;
Line 4925... Line 5077...
4925
  bfd_release (abfd, copy);
5077
  bfd_release (abfd, copy);
4926
  return h;
5078
  return h;
4927
}
5079
}
Line 4928... Line 5080...
4928
 
5080
 
4929
/* Add symbols from an ELF archive file to the linker hash table.  We
5081
/* Add symbols from an ELF archive file to the linker hash table.  We
4930
   don't use _bfd_generic_link_add_archive_symbols because of a
-
 
4931
   problem which arises on UnixWare.  The UnixWare libc.so is an
-
 
4932
   archive which includes an entry libc.so.1 which defines a bunch of
-
 
4933
   symbols.  The libc.so archive also includes a number of other
-
 
4934
   object files, which also define symbols, some of which are the same
-
 
4935
   as those defined in libc.so.1.  Correct linking requires that we
-
 
4936
   consider each object file in turn, and include it if it defines any
-
 
4937
   symbols we need.  _bfd_generic_link_add_archive_symbols does not do
-
 
4938
   this; it looks through the list of undefined symbols, and includes
-
 
4939
   any object file which defines them.  When this algorithm is used on
-
 
4940
   UnixWare, it winds up pulling in libc.so.1 early and defining a
-
 
4941
   bunch of symbols.  This means that some of the other objects in the
-
 
4942
   archive are not included in the link, which is incorrect since they
5082
   don't use _bfd_generic_link_add_archive_symbols because we need to
Line 4943... Line 5083...
4943
   precede libc.so.1 in the archive.
5083
   handle versioned symbols.
4944
 
5084
 
4945
   Fortunately, ELF archive handling is simpler than that done by
5085
   Fortunately, ELF archive handling is simpler than that done by
4946
   _bfd_generic_link_add_archive_symbols, which has to allow for a.out
5086
   _bfd_generic_link_add_archive_symbols, which has to allow for a.out
Line 4953... Line 5093...
4953
 
5093
 
4954
static bfd_boolean
5094
static bfd_boolean
4955
elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
5095
elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
4956
{
5096
{
4957
  symindex c;
-
 
4958
  bfd_boolean *defined = NULL;
5097
  symindex c;
4959
  bfd_boolean *included = NULL;
5098
  unsigned char *included = NULL;
4960
  carsym *symdefs;
5099
  carsym *symdefs;
4961
  bfd_boolean loop;
5100
  bfd_boolean loop;
4962
  bfd_size_type amt;
5101
  bfd_size_type amt;
4963
  const struct elf_backend_data *bed;
5102
  const struct elf_backend_data *bed;
Line 4978... Line 5117...
4978
     second and subsequent passes.  */
5117
     second and subsequent passes.  */
4979
  c = bfd_ardata (abfd)->symdef_count;
5118
  c = bfd_ardata (abfd)->symdef_count;
4980
  if (c == 0)
5119
  if (c == 0)
4981
    return TRUE;
5120
    return TRUE;
4982
  amt = c;
5121
  amt = c;
4983
  amt *= sizeof (bfd_boolean);
5122
  amt *= sizeof (*included);
4984
  defined = (bfd_boolean *) bfd_zmalloc (amt);
-
 
4985
  included = (bfd_boolean *) bfd_zmalloc (amt);
5123
  included = (unsigned char *) bfd_zmalloc (amt);
4986
  if (defined == NULL || included == NULL)
5124
  if (included == NULL)
4987
    goto error_return;
5125
    return FALSE;
Line 4988... Line 5126...
4988
 
5126
 
4989
  symdefs = bfd_ardata (abfd)->symdefs;
5127
  symdefs = bfd_ardata (abfd)->symdefs;
4990
  bed = get_elf_backend_data (abfd);
5128
  bed = get_elf_backend_data (abfd);
Line 5007... Line 5145...
5007
	  struct elf_link_hash_entry *h;
5145
	  struct elf_link_hash_entry *h;
5008
	  bfd *element;
5146
	  bfd *element;
5009
	  struct bfd_link_hash_entry *undefs_tail;
5147
	  struct bfd_link_hash_entry *undefs_tail;
5010
	  symindex mark;
5148
	  symindex mark;
Line 5011... Line 5149...
5011
 
5149
 
5012
	  if (defined[i] || included[i])
5150
	  if (included[i])
5013
	    continue;
5151
	    continue;
5014
	  if (symdef->file_offset == last)
5152
	  if (symdef->file_offset == last)
5015
	    {
5153
	    {
5016
	      included[i] = TRUE;
5154
	      included[i] = TRUE;
Line 5042... Line 5180...
5042
		continue;
5180
		continue;
5043
	    }
5181
	    }
5044
	  else if (h->root.type != bfd_link_hash_undefined)
5182
	  else if (h->root.type != bfd_link_hash_undefined)
5045
	    {
5183
	    {
5046
	      if (h->root.type != bfd_link_hash_undefweak)
5184
	      if (h->root.type != bfd_link_hash_undefweak)
-
 
5185
		/* Symbol must be defined.  Don't check it again.  */
5047
		defined[i] = TRUE;
5186
		included[i] = TRUE;
5048
	      continue;
5187
	      continue;
5049
	    }
5188
	    }
Line 5050... Line 5189...
5050
 
5189
 
5051
	  /* We need to include this archive member.  */
5190
	  /* We need to include this archive member.  */
Line 5054... Line 5193...
5054
	    goto error_return;
5193
	    goto error_return;
Line 5055... Line 5194...
5055
 
5194
 
5056
	  if (! bfd_check_format (element, bfd_object))
5195
	  if (! bfd_check_format (element, bfd_object))
Line 5057... Line -...
5057
	    goto error_return;
-
 
5058
 
-
 
5059
	  /* Doublecheck that we have not included this object
-
 
5060
	     already--it should be impossible, but there may be
-
 
5061
	     something wrong with the archive.  */
-
 
5062
	  if (element->archive_pass != 0)
-
 
5063
	    {
-
 
5064
	      bfd_set_error (bfd_error_bad_value);
-
 
5065
	      goto error_return;
-
 
5066
	    }
-
 
5067
	  element->archive_pass = 1;
5196
	    goto error_return;
Line 5068... Line 5197...
5068
 
5197
 
5069
	  undefs_tail = info->hash->undefs_tail;
5198
	  undefs_tail = info->hash->undefs_tail;
5070
 
5199
 
Line 5101... Line 5230...
5101
	  last = symdef->file_offset;
5230
	  last = symdef->file_offset;
5102
	}
5231
	}
5103
    }
5232
    }
5104
  while (loop);
5233
  while (loop);
Line 5105... Line -...
5105
 
-
 
5106
  free (defined);
5234
 
Line 5107... Line 5235...
5107
  free (included);
5235
  free (included);
Line 5108... Line 5236...
5108
 
5236
 
5109
  return TRUE;
-
 
5110
 
-
 
5111
 error_return:
5237
  return TRUE;
5112
  if (defined != NULL)
5238
 
5113
    free (defined);
5239
 error_return:
5114
  if (included != NULL)
5240
  if (included != NULL)
Line 5146... Line 5272...
5146
static bfd_boolean
5272
static bfd_boolean
5147
elf_collect_hash_codes (struct elf_link_hash_entry *h, void *data)
5273
elf_collect_hash_codes (struct elf_link_hash_entry *h, void *data)
5148
{
5274
{
5149
  struct hash_codes_info *inf = (struct hash_codes_info *) data;
5275
  struct hash_codes_info *inf = (struct hash_codes_info *) data;
5150
  const char *name;
5276
  const char *name;
5151
  char *p;
-
 
5152
  unsigned long ha;
5277
  unsigned long ha;
5153
  char *alc = NULL;
5278
  char *alc = NULL;
Line 5154... Line 5279...
5154
 
5279
 
5155
  /* Ignore indirect symbols.  These are added by the versioning code.  */
5280
  /* Ignore indirect symbols.  These are added by the versioning code.  */
5156
  if (h->dynindx == -1)
5281
  if (h->dynindx == -1)
Line 5157... Line 5282...
5157
    return TRUE;
5282
    return TRUE;
-
 
5283
 
-
 
5284
  name = h->root.root.string;
5158
 
5285
  if (h->versioned >= versioned)
5159
  name = h->root.root.string;
5286
    {
5160
  p = strchr (name, ELF_VER_CHR);
5287
      char *p = strchr (name, ELF_VER_CHR);
5161
  if (p != NULL)
5288
      if (p != NULL)
5162
    {
5289
	{
5163
      alc = (char *) bfd_malloc (p - name + 1);
5290
	  alc = (char *) bfd_malloc (p - name + 1);
Line 5168... Line 5295...
5168
	}
5295
	    }
5169
      memcpy (alc, name, p - name);
5296
	  memcpy (alc, name, p - name);
5170
      alc[p - name] = '\0';
5297
	  alc[p - name] = '\0';
5171
      name = alc;
5298
	  name = alc;
5172
    }
5299
	}
-
 
5300
    }
Line 5173... Line 5301...
5173
 
5301
 
5174
  /* Compute the hash value.  */
5302
  /* Compute the hash value.  */
Line 5175... Line 5303...
5175
  ha = bfd_elf_hash (name);
5303
  ha = bfd_elf_hash (name);
Line 5214... Line 5342...
5214
static bfd_boolean
5342
static bfd_boolean
5215
elf_collect_gnu_hash_codes (struct elf_link_hash_entry *h, void *data)
5343
elf_collect_gnu_hash_codes (struct elf_link_hash_entry *h, void *data)
5216
{
5344
{
5217
  struct collect_gnu_hash_codes *s = (struct collect_gnu_hash_codes *) data;
5345
  struct collect_gnu_hash_codes *s = (struct collect_gnu_hash_codes *) data;
5218
  const char *name;
5346
  const char *name;
5219
  char *p;
-
 
5220
  unsigned long ha;
5347
  unsigned long ha;
5221
  char *alc = NULL;
5348
  char *alc = NULL;
Line 5222... Line 5349...
5222
 
5349
 
5223
  /* Ignore indirect symbols.  These are added by the versioning code.  */
5350
  /* Ignore indirect symbols.  These are added by the versioning code.  */
Line 5227... Line 5354...
5227
  /* Ignore also local symbols and undefined symbols.  */
5354
  /* Ignore also local symbols and undefined symbols.  */
5228
  if (! (*s->bed->elf_hash_symbol) (h))
5355
  if (! (*s->bed->elf_hash_symbol) (h))
5229
    return TRUE;
5356
    return TRUE;
Line 5230... Line 5357...
5230
 
5357
 
-
 
5358
  name = h->root.root.string;
-
 
5359
  if (h->versioned >= versioned)
5231
  name = h->root.root.string;
5360
    {
5232
  p = strchr (name, ELF_VER_CHR);
5361
      char *p = strchr (name, ELF_VER_CHR);
5233
  if (p != NULL)
5362
      if (p != NULL)
5234
    {
5363
	{
5235
      alc = (char *) bfd_malloc (p - name + 1);
5364
	  alc = (char *) bfd_malloc (p - name + 1);
5236
      if (alc == NULL)
5365
	  if (alc == NULL)
Line 5240... Line 5369...
5240
	}
5369
	    }
5241
      memcpy (alc, name, p - name);
5370
	  memcpy (alc, name, p - name);
5242
      alc[p - name] = '\0';
5371
	  alc[p - name] = '\0';
5243
      name = alc;
5372
	  name = alc;
5244
    }
5373
	}
-
 
5374
    }
Line 5245... Line 5375...
5245
 
5375
 
5246
  /* Compute the hash value.  */
5376
  /* Compute the hash value.  */
Line 5247... Line 5377...
5247
  ha = bfd_elf_gnu_hash (name);
5377
  ha = bfd_elf_gnu_hash (name);
Line 5474... Line 5604...
5474
bfd_boolean
5604
bfd_boolean
5475
_bfd_elf_size_group_sections (struct bfd_link_info *info)
5605
_bfd_elf_size_group_sections (struct bfd_link_info *info)
5476
{
5606
{
5477
  bfd *ibfd;
5607
  bfd *ibfd;
Line 5478... Line 5608...
5478
 
5608
 
5479
  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
5609
  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
5480
    if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour
5610
    if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour
5481
	&& !_bfd_elf_fixup_group_sections (ibfd, bfd_abs_section_ptr))
5611
	&& !_bfd_elf_fixup_group_sections (ibfd, bfd_abs_section_ptr))
5482
      return FALSE;
5612
      return FALSE;
5483
  return TRUE;
5613
  return TRUE;
Line 5577... Line 5707...
5577
  elf_hash_table (info)->init_got_refcount
5707
  elf_hash_table (info)->init_got_refcount
5578
    = elf_hash_table (info)->init_got_offset;
5708
    = elf_hash_table (info)->init_got_offset;
5579
  elf_hash_table (info)->init_plt_refcount
5709
  elf_hash_table (info)->init_plt_refcount
5580
    = elf_hash_table (info)->init_plt_offset;
5710
    = elf_hash_table (info)->init_plt_offset;
Line 5581... Line 5711...
5581
 
5711
 
5582
  if (info->relocatable
5712
  if (bfd_link_relocatable (info)
5583
      && !_bfd_elf_size_group_sections (info))
5713
      && !_bfd_elf_size_group_sections (info))
Line 5584... Line 5714...
5584
    return FALSE;
5714
    return FALSE;
5585
 
5715
 
Line 5601... Line 5731...
5601
      asection *notesec = NULL;
5731
      asection *notesec = NULL;
5602
      int exec = 0;
5732
      int exec = 0;
Line 5603... Line 5733...
5603
 
5733
 
5604
      for (inputobj = info->input_bfds;
5734
      for (inputobj = info->input_bfds;
5605
	   inputobj;
5735
	   inputobj;
5606
	   inputobj = inputobj->link_next)
5736
	   inputobj = inputobj->link.next)
5607
	{
5737
	{
Line 5608... Line 5738...
5608
	  asection *s;
5738
	  asection *s;
5609
 
5739
 
Line 5620... Line 5750...
5620
	  else if (bed->default_execstack)
5750
	  else if (bed->default_execstack)
5621
	    exec = PF_X;
5751
	    exec = PF_X;
5622
	}
5752
	}
5623
      if (notesec || info->stacksize > 0)
5753
      if (notesec || info->stacksize > 0)
5624
	elf_stack_flags (output_bfd) = PF_R | PF_W | exec;
5754
	elf_stack_flags (output_bfd) = PF_R | PF_W | exec;
5625
      if (notesec && exec && info->relocatable
5755
      if (notesec && exec && bfd_link_relocatable (info)
5626
	  && notesec->output_section != bfd_abs_section_ptr)
5756
	  && notesec->output_section != bfd_abs_section_ptr)
5627
	notesec->output_section->flags |= SEC_CODE;
5757
	notesec->output_section->flags |= SEC_CODE;
5628
    }
5758
    }
Line 5629... Line 5759...
5629
 
5759
 
Line 5638... Line 5768...
5638
      struct bfd_elf_version_expr *d;
5768
      struct bfd_elf_version_expr *d;
5639
      asection *s;
5769
      asection *s;
5640
      bfd_boolean all_defined;
5770
      bfd_boolean all_defined;
Line 5641... Line 5771...
5641
 
5771
 
5642
      *sinterpptr = bfd_get_linker_section (dynobj, ".interp");
5772
      *sinterpptr = bfd_get_linker_section (dynobj, ".interp");
Line 5643... Line 5773...
5643
      BFD_ASSERT (*sinterpptr != NULL || !info->executable);
5773
      BFD_ASSERT (*sinterpptr != NULL || !bfd_link_executable (info) || info->nointerp);
5644
 
5774
 
5645
      if (soname != NULL)
5775
      if (soname != NULL)
5646
	{
5776
	{
Line 5726... Line 5856...
5726
      eif.failed = FALSE;
5856
      eif.failed = FALSE;
Line 5727... Line 5857...
5727
 
5857
 
5728
      /* If we are supposed to export all symbols into the dynamic symbol
5858
      /* If we are supposed to export all symbols into the dynamic symbol
5729
	 table (this is not the normal case), then do so.  */
5859
	 table (this is not the normal case), then do so.  */
5730
      if (info->export_dynamic
5860
      if (info->export_dynamic
5731
	  || (info->executable && info->dynamic))
5861
	  || (bfd_link_executable (info) && info->dynamic))
5732
	{
5862
	{
5733
	  elf_link_hash_traverse (elf_hash_table (info),
5863
	  elf_link_hash_traverse (elf_hash_table (info),
5734
				  _bfd_elf_export_symbol,
5864
				  _bfd_elf_export_symbol,
5735
				  &eif);
5865
				  &eif);
Line 5861... Line 5991...
5861
 
5991
 
5862
      s = bfd_get_section_by_name (output_bfd, ".preinit_array");
5992
      s = bfd_get_section_by_name (output_bfd, ".preinit_array");
5863
      if (s != NULL && s->linker_has_input)
5993
      if (s != NULL && s->linker_has_input)
5864
	{
5994
	{
5865
	  /* DT_PREINIT_ARRAY is not allowed in shared library.  */
5995
	  /* DT_PREINIT_ARRAY is not allowed in shared library.  */
5866
	  if (! info->executable)
5996
	  if (! bfd_link_executable (info))
5867
	    {
5997
	    {
5868
	      bfd *sub;
5998
	      bfd *sub;
Line 5869... Line 5999...
5869
	      asection *o;
5999
	      asection *o;
5870
 
6000
 
5871
	      for (sub = info->input_bfds; sub != NULL;
6001
	      for (sub = info->input_bfds; sub != NULL;
5872
		   sub = sub->link_next)
6002
		   sub = sub->link.next)
5873
		if (bfd_get_flavour (sub) == bfd_target_elf_flavour)
6003
		if (bfd_get_flavour (sub) == bfd_target_elf_flavour)
5874
		  for (o = sub->sections; o != NULL; o = o->next)
6004
		  for (o = sub->sections; o != NULL; o = o->next)
5875
		    if (elf_section_data (o)->this_hdr.sh_type
6005
		    if (elf_section_data (o)->this_hdr.sh_type
Line 5925... Line 6055...
5925
					      bed->s->sizeof_sym))
6055
					      bed->s->sizeof_sym))
5926
	    return FALSE;
6056
	    return FALSE;
5927
	}
6057
	}
5928
    }
6058
    }
Line -... Line 6059...
-
 
6059
 
-
 
6060
  if (! _bfd_elf_maybe_strip_eh_frame_hdr (info))
-
 
6061
    return FALSE;
5929
 
6062
 
5930
  /* The backend must work out the sizes of all the other dynamic
6063
  /* The backend must work out the sizes of all the other dynamic
5931
     sections.  */
6064
     sections.  */
5932
  if (dynobj != NULL
6065
  if (dynobj != NULL
5933
      && bed->elf_backend_size_dynamic_sections != NULL
6066
      && bed->elf_backend_size_dynamic_sections != NULL
5934
      && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info))
6067
      && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info))
Line 5935... Line -...
5935
    return FALSE;
-
 
5936
 
-
 
5937
  if (! _bfd_elf_maybe_strip_eh_frame_hdr (info))
-
 
5938
    return FALSE;
6068
    return FALSE;
5939
 
6069
 
5940
  if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created)
6070
  if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created)
5941
    {
6071
    {
5942
      unsigned long section_sym_count;
6072
      unsigned long section_sym_count;
Line 6195... Line 6325...
6195
	    return FALSE;
6325
	    return FALSE;
6196
	}
6326
	}
Line 6197... Line 6327...
6197
 
6327
 
6198
      if (info->flags_1)
6328
      if (info->flags_1)
6199
	{
6329
	{
6200
	  if (info->executable)
6330
	  if (bfd_link_executable (info))
6201
	    info->flags_1 &= ~ (DF_1_INITFIRST
6331
	    info->flags_1 &= ~ (DF_1_INITFIRST
6202
				| DF_1_NODELETE
6332
				| DF_1_NODELETE
6203
				| DF_1_NOOPEN);
6333
				| DF_1_NOOPEN);
6204
	  if (!_bfd_elf_add_dynamic_entry (info, DT_FLAGS_1, info->flags_1))
6334
	  if (!_bfd_elf_add_dynamic_entry (info, DT_FLAGS_1, info->flags_1))
Line 6421... Line 6551...
6421
	 the number of dynamic symbols in elf_link_add_object_symbols.
6551
	 the number of dynamic symbols in elf_link_add_object_symbols.
6422
	 We will build the contents of .dynsym and .hash when we build
6552
	 We will build the contents of .dynsym and .hash when we build
6423
	 the final symbol table, because until then we do not know the
6553
	 the final symbol table, because until then we do not know the
6424
	 correct value to give the symbols.  We built the .dynstr
6554
	 correct value to give the symbols.  We built the .dynstr
6425
	 section as we went along in elf_link_add_object_symbols.  */
6555
	 section as we went along in elf_link_add_object_symbols.  */
6426
      s = bfd_get_linker_section (dynobj, ".dynsym");
6556
      s = elf_hash_table (info)->dynsym;
6427
      BFD_ASSERT (s != NULL);
6557
      BFD_ASSERT (s != NULL);
6428
      s->size = dynsymcount * bed->s->sizeof_sym;
6558
      s->size = dynsymcount * bed->s->sizeof_sym;
Line 6429... Line 6559...
6429
 
6559
 
6430
      if (dynsymcount != 0)
6560
      if (dynsymcount != 0)
Line 6689... Line 6819...
6689
}
6819
}
Line 6690... Line 6820...
6690
 
6820
 
Line 6691... Line 6821...
6691
/* Finish SHF_MERGE section merging.  */
6821
/* Finish SHF_MERGE section merging.  */
6692
 
6822
 
6693
bfd_boolean
6823
bfd_boolean
6694
_bfd_elf_merge_sections (bfd *abfd, struct bfd_link_info *info)
6824
_bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info)
6695
{
6825
{
Line 6696... Line 6826...
6696
  bfd *ibfd;
6826
  bfd *ibfd;
6697
  asection *sec;
6827
  asection *sec;
Line 6698... Line 6828...
6698
 
6828
 
6699
  if (!is_elf_hash_table (info->hash))
6829
  if (!is_elf_hash_table (info->hash))
-
 
6830
    return FALSE;
-
 
6831
 
-
 
6832
  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
6700
    return FALSE;
6833
    if ((ibfd->flags & DYNAMIC) == 0
6701
 
6834
	&& bfd_get_flavour (ibfd) == bfd_target_elf_flavour
6702
  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
6835
	&& (elf_elfheader (ibfd)->e_ident[EI_CLASS]
6703
    if ((ibfd->flags & DYNAMIC) == 0)
6836
	    == get_elf_backend_data (obfd)->s->elfclass))
6704
      for (sec = ibfd->sections; sec != NULL; sec = sec->next)
6837
      for (sec = ibfd->sections; sec != NULL; sec = sec->next)
Line 6705... Line 6838...
6705
	if ((sec->flags & SEC_MERGE) != 0
6838
	if ((sec->flags & SEC_MERGE) != 0
6706
	    && !bfd_is_abs_section (sec->output_section))
6839
	    && !bfd_is_abs_section (sec->output_section))
6707
	  {
6840
	  {
6708
	    struct bfd_elf_section_data *secdata;
6841
	    struct bfd_elf_section_data *secdata;
6709
 
6842
 
6710
	    secdata = elf_section_data (sec);
6843
	    secdata = elf_section_data (sec);
6711
	    if (! _bfd_add_merge_section (abfd,
6844
	    if (! _bfd_add_merge_section (obfd,
6712
					  &elf_hash_table (info)->merge_info,
6845
					  &elf_hash_table (info)->merge_info,
Line 6713... Line 6846...
6713
					  sec, &secdata->sec_info))
6846
					  sec, &secdata->sec_info))
6714
	      return FALSE;
6847
	      return FALSE;
6715
	    else if (secdata->sec_info)
6848
	    else if (secdata->sec_info)
6716
	      sec->sec_info_type = SEC_INFO_TYPE_MERGE;
6849
	      sec->sec_info_type = SEC_INFO_TYPE_MERGE;
6717
	  }
6850
	  }
Line 6718... Line 6851...
6718
 
6851
 
Line 6772... Line 6905...
6772
				  struct elf_link_hash_entry *ind)
6905
				  struct elf_link_hash_entry *ind)
6773
{
6906
{
6774
  struct elf_link_hash_table *htab;
6907
  struct elf_link_hash_table *htab;
Line 6775... Line 6908...
6775
 
6908
 
6776
  /* Copy down any references that we may have already seen to the
6909
  /* Copy down any references that we may have already seen to the
-
 
6910
     symbol which just became indirect if DIR isn't a hidden versioned
Line -... Line 6911...
-
 
6911
     symbol.  */
-
 
6912
 
6777
     symbol which just became indirect.  */
6913
  if (dir->versioned != versioned_hidden)
6778
 
6914
    {
6779
  dir->ref_dynamic |= ind->ref_dynamic;
6915
      dir->ref_dynamic |= ind->ref_dynamic;
6780
  dir->ref_regular |= ind->ref_regular;
6916
      dir->ref_regular |= ind->ref_regular;
6781
  dir->ref_regular_nonweak |= ind->ref_regular_nonweak;
6917
      dir->ref_regular_nonweak |= ind->ref_regular_nonweak;
6782
  dir->non_got_ref |= ind->non_got_ref;
6918
      dir->non_got_ref |= ind->non_got_ref;
-
 
6919
      dir->needs_plt |= ind->needs_plt;
Line 6783... Line 6920...
6783
  dir->needs_plt |= ind->needs_plt;
6920
      dir->pointer_equality_needed |= ind->pointer_equality_needed;
6784
  dir->pointer_equality_needed |= ind->pointer_equality_needed;
6921
    }
Line 6785... Line 6922...
6785
 
6922
 
Line 6887... Line 7024...
6887
				       GENERIC_ELF_DATA))
7024
				       GENERIC_ELF_DATA))
6888
    {
7025
    {
6889
      free (ret);
7026
      free (ret);
6890
      return NULL;
7027
      return NULL;
6891
    }
7028
    }
-
 
7029
  ret->root.hash_table_free = _bfd_elf_link_hash_table_free;
Line 6892... Line 7030...
6892
 
7030
 
6893
  return &ret->root;
7031
  return &ret->root;
Line 6894... Line 7032...
6894
}
7032
}
Line 6895... Line 7033...
6895
 
7033
 
6896
/* Destroy an ELF linker hash table.  */
7034
/* Destroy an ELF linker hash table.  */
6897
 
7035
 
-
 
7036
void
-
 
7037
_bfd_elf_link_hash_table_free (bfd *obfd)
6898
void
7038
{
6899
_bfd_elf_link_hash_table_free (struct bfd_link_hash_table *hash)
7039
  struct elf_link_hash_table *htab;
6900
{
7040
 
6901
  struct elf_link_hash_table *htab = (struct elf_link_hash_table *) hash;
7041
  htab = (struct elf_link_hash_table *) obfd->link.hash;
6902
  if (htab->dynstr != NULL)
7042
  if (htab->dynstr != NULL)
6903
    _bfd_elf_strtab_free (htab->dynstr);
7043
    _bfd_elf_strtab_free (htab->dynstr);
Line 6904... Line 7044...
6904
  _bfd_merge_sections_free (htab->merge_info);
7044
  _bfd_merge_sections_free (htab->merge_info);
6905
  _bfd_generic_link_hash_table_free (hash);
7045
  _bfd_generic_link_hash_table_free (obfd);
6906
}
7046
}
Line 7280... Line 7420...
7280
	}
7420
	}
Line 7281... Line 7421...
7281
 
7421
 
7282
      if (count1 == 0 || count2 == 0 || count1 != count2)
7422
      if (count1 == 0 || count2 == 0 || count1 != count2)
Line 7283... Line 7423...
7283
	goto done;
7423
	goto done;
7284
 
7424
 
7285
      symtable1 = (struct elf_symbol *)
7425
      symtable1
7286
          bfd_malloc (count1 * sizeof (struct elf_symbol));
7426
	= (struct elf_symbol *) bfd_malloc (count1 * sizeof (*symtable1));
7287
      symtable2 = (struct elf_symbol *)
7427
      symtable2
7288
          bfd_malloc (count2 * sizeof (struct elf_symbol));
7428
	= (struct elf_symbol *) bfd_malloc (count2 * sizeof (*symtable2));
Line 7289... Line 7429...
7289
      if (symtable1 == NULL || symtable2 == NULL)
7429
      if (symtable1 == NULL || symtable2 == NULL)
7290
	goto done;
7430
	goto done;
Line 7409... Line 7549...
7409
  /* General link information.  */
7549
  /* General link information.  */
7410
  struct bfd_link_info *info;
7550
  struct bfd_link_info *info;
7411
  /* Output BFD.  */
7551
  /* Output BFD.  */
7412
  bfd *output_bfd;
7552
  bfd *output_bfd;
7413
  /* Symbol string table.  */
7553
  /* Symbol string table.  */
7414
  struct bfd_strtab_hash *symstrtab;
7554
  struct elf_strtab_hash *symstrtab;
7415
  /* .dynsym section.  */
-
 
7416
  asection *dynsym_sec;
-
 
7417
  /* .hash section.  */
7555
  /* .hash section.  */
7418
  asection *hash_sec;
7556
  asection *hash_sec;
7419
  /* symbol version section (.gnu.version).  */
7557
  /* symbol version section (.gnu.version).  */
7420
  asection *symver_sec;
7558
  asection *symver_sec;
7421
  /* Buffer large enough to hold contents of any section.  */
7559
  /* Buffer large enough to hold contents of any section.  */
Line 7436... Line 7574...
7436
     of any input BFD.  */
7574
     of any input BFD.  */
7437
  long *indices;
7575
  long *indices;
7438
  /* Array large enough to hold a section pointer for each local
7576
  /* Array large enough to hold a section pointer for each local
7439
     symbol of any input BFD.  */
7577
     symbol of any input BFD.  */
7440
  asection **sections;
7578
  asection **sections;
7441
  /* Buffer to hold swapped out symbols.  */
7579
  /* Buffer for SHT_SYMTAB_SHNDX section.  */
7442
  bfd_byte *symbuf;
-
 
7443
  /* And one for symbol section indices.  */
-
 
7444
  Elf_External_Sym_Shndx *symshndxbuf;
7580
  Elf_External_Sym_Shndx *symshndxbuf;
7445
  /* Number of swapped out symbols in buffer.  */
-
 
7446
  size_t symbuf_count;
-
 
7447
  /* Number of symbols which fit in symbuf.  */
-
 
7448
  size_t symbuf_size;
-
 
7449
  /* And same for symshndxbuf.  */
-
 
7450
  size_t shndxbuf_size;
-
 
7451
  /* Number of STT_FILE syms seen.  */
7581
  /* Number of STT_FILE syms seen.  */
7452
  size_t filesym_count;
7582
  size_t filesym_count;
7453
};
7583
};
Line 7454... Line 7584...
7454
 
7584
 
Line 7455... Line 7585...
7455
/* This struct is used to pass information to elf_link_output_extsym.  */
7585
/* This struct is used to pass information to elf_link_output_extsym.  */
7456
 
7586
 
7457
struct elf_outext_info
7587
struct elf_outext_info
7458
{
7588
{
7459
  bfd_boolean failed;
-
 
7460
  bfd_boolean localsyms;
7589
  bfd_boolean failed;
7461
  bfd_boolean need_second_pass;
7590
  bfd_boolean localsyms;
7462
  bfd_boolean second_pass;
7591
  bfd_boolean file_sym_done;
Line 7463... Line 7592...
7463
  struct elf_final_link_info *flinfo;
7592
  struct elf_final_link_info *flinfo;
Line 7807... Line 7936...
7807
	   bfd_vma x,
7936
	   bfd_vma x,
7808
	   bfd_byte *location)
7937
	   bfd_byte *location)
7809
{
7938
{
7810
  location += (size - chunksz);
7939
  location += (size - chunksz);
Line 7811... Line 7940...
7811
 
7940
 
7812
  for (; size; size -= chunksz, location -= chunksz, x >>= (chunksz * 8))
7941
  for (; size; size -= chunksz, location -= chunksz)
7813
    {
7942
    {
7814
      switch (chunksz)
7943
      switch (chunksz)
7815
	{
-
 
7816
	default:
-
 
7817
	case 0:
-
 
7818
	  abort ();
7944
	{
7819
	case 1:
7945
	case 1:
-
 
7946
	  bfd_put_8 (input_bfd, x, location);
7820
	  bfd_put_8 (input_bfd, x, location);
7947
	  x >>= 8;
7821
	  break;
7948
	  break;
7822
	case 2:
7949
	case 2:
-
 
7950
	  bfd_put_16 (input_bfd, x, location);
7823
	  bfd_put_16 (input_bfd, x, location);
7951
	  x >>= 16;
7824
	  break;
7952
	  break;
7825
	case 4:
7953
	case 4:
-
 
7954
	  bfd_put_32 (input_bfd, x, location);
-
 
7955
	  /* Computed this way because x >>= 32 is undefined if x is a 32-bit value.  */
-
 
7956
	  x >>= 16;
7826
	  bfd_put_32 (input_bfd, x, location);
7957
	  x >>= 16;
7827
	  break;
-
 
7828
	case 8:
7958
	  break;
-
 
7959
#ifdef BFD64
7829
#ifdef BFD64
7960
	case 8:
-
 
7961
	  bfd_put_64 (input_bfd, x, location);
-
 
7962
	  /* Computed this way because x >>= 64 is undefined if x is a 64-bit value.  */
7830
	  bfd_put_64 (input_bfd, x, location);
7963
	  x >>= 32;
7831
#else
7964
	  x >>= 32;
7832
	  abort ();
7965
	  break;
-
 
7966
#endif
-
 
7967
	default:
7833
#endif
7968
	  abort ();
7834
	  break;
7969
	  break;
7835
	}
7970
	}
7836
    }
7971
    }
Line 7975... Line 8110...
7975
  /* FIXME: octets_per_byte.  */
8110
  /* FIXME: octets_per_byte.  */
7976
  put_value (wordsz, chunksz, input_bfd, x, contents + rel->r_offset);
8111
  put_value (wordsz, chunksz, input_bfd, x, contents + rel->r_offset);
7977
  return r;
8112
  return r;
7978
}
8113
}
Line -... Line 8114...
-
 
8114
 
-
 
8115
/* Functions to read r_offset from external (target order) reloc
-
 
8116
   entry.  Faster than bfd_getl32 et al, because we let the compiler
-
 
8117
   know the value is aligned.  */
-
 
8118
 
-
 
8119
static bfd_vma
-
 
8120
ext32l_r_offset (const void *p)
-
 
8121
{
-
 
8122
  union aligned32
-
 
8123
  {
-
 
8124
    uint32_t v;
-
 
8125
    unsigned char c[4];
-
 
8126
  };
-
 
8127
  const union aligned32 *a
-
 
8128
    = (const union aligned32 *) &((const Elf32_External_Rel *) p)->r_offset;
-
 
8129
 
-
 
8130
  uint32_t aval = (  (uint32_t) a->c[0]
-
 
8131
		   | (uint32_t) a->c[1] << 8
-
 
8132
		   | (uint32_t) a->c[2] << 16
-
 
8133
		   | (uint32_t) a->c[3] << 24);
-
 
8134
  return aval;
-
 
8135
}
-
 
8136
 
-
 
8137
static bfd_vma
-
 
8138
ext32b_r_offset (const void *p)
-
 
8139
{
-
 
8140
  union aligned32
-
 
8141
  {
-
 
8142
    uint32_t v;
-
 
8143
    unsigned char c[4];
-
 
8144
  };
-
 
8145
  const union aligned32 *a
-
 
8146
    = (const union aligned32 *) &((const Elf32_External_Rel *) p)->r_offset;
-
 
8147
 
-
 
8148
  uint32_t aval = (  (uint32_t) a->c[0] << 24
-
 
8149
		   | (uint32_t) a->c[1] << 16
-
 
8150
		   | (uint32_t) a->c[2] << 8
-
 
8151
		   | (uint32_t) a->c[3]);
-
 
8152
  return aval;
-
 
8153
}
-
 
8154
 
-
 
8155
#ifdef BFD_HOST_64_BIT
-
 
8156
static bfd_vma
-
 
8157
ext64l_r_offset (const void *p)
-
 
8158
{
-
 
8159
  union aligned64
-
 
8160
  {
-
 
8161
    uint64_t v;
-
 
8162
    unsigned char c[8];
-
 
8163
  };
-
 
8164
  const union aligned64 *a
-
 
8165
    = (const union aligned64 *) &((const Elf64_External_Rel *) p)->r_offset;
-
 
8166
 
-
 
8167
  uint64_t aval = (  (uint64_t) a->c[0]
-
 
8168
		   | (uint64_t) a->c[1] << 8
-
 
8169
		   | (uint64_t) a->c[2] << 16
-
 
8170
		   | (uint64_t) a->c[3] << 24
-
 
8171
		   | (uint64_t) a->c[4] << 32
-
 
8172
		   | (uint64_t) a->c[5] << 40
-
 
8173
		   | (uint64_t) a->c[6] << 48
-
 
8174
		   | (uint64_t) a->c[7] << 56);
-
 
8175
  return aval;
-
 
8176
}
-
 
8177
 
-
 
8178
static bfd_vma
-
 
8179
ext64b_r_offset (const void *p)
-
 
8180
{
-
 
8181
  union aligned64
-
 
8182
  {
-
 
8183
    uint64_t v;
-
 
8184
    unsigned char c[8];
-
 
8185
  };
-
 
8186
  const union aligned64 *a
-
 
8187
    = (const union aligned64 *) &((const Elf64_External_Rel *) p)->r_offset;
-
 
8188
 
-
 
8189
  uint64_t aval = (  (uint64_t) a->c[0] << 56
-
 
8190
		   | (uint64_t) a->c[1] << 48
-
 
8191
		   | (uint64_t) a->c[2] << 40
-
 
8192
		   | (uint64_t) a->c[3] << 32
-
 
8193
		   | (uint64_t) a->c[4] << 24
-
 
8194
		   | (uint64_t) a->c[5] << 16
-
 
8195
		   | (uint64_t) a->c[6] << 8
-
 
8196
		   | (uint64_t) a->c[7]);
-
 
8197
  return aval;
-
 
8198
}
-
 
8199
#endif
7979
 
8200
 
7980
/* When performing a relocatable link, the input relocations are
8201
/* When performing a relocatable link, the input relocations are
7981
   preserved.  But, if they reference global symbols, the indices
8202
   preserved.  But, if they reference global symbols, the indices
7982
   referenced must be updated.  Update all the relocations found in
8203
   referenced must be updated.  Update all the relocations found in
Line 7983... Line 8204...
7983
   RELDATA.  */
8204
   RELDATA.  */
7984
 
8205
 
7985
static void
8206
static bfd_boolean
-
 
8207
elf_link_adjust_relocs (bfd *abfd,
7986
elf_link_adjust_relocs (bfd *abfd,
8208
			struct bfd_elf_section_reloc_data *reldata,
7987
			struct bfd_elf_section_reloc_data *reldata)
8209
			bfd_boolean sort)
7988
{
8210
{
7989
  unsigned int i;
8211
  unsigned int i;
7990
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
8212
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
Line 8038... Line 8260...
8038
      for (j = 0; j < bed->s->int_rels_per_ext_rel; j++)
8260
      for (j = 0; j < bed->s->int_rels_per_ext_rel; j++)
8039
	irela[j].r_info = ((bfd_vma) (*rel_hash)->indx << r_sym_shift
8261
	irela[j].r_info = ((bfd_vma) (*rel_hash)->indx << r_sym_shift
8040
			   | (irela[j].r_info & r_type_mask));
8262
			   | (irela[j].r_info & r_type_mask));
8041
      (*swap_out) (abfd, irela, erela);
8263
      (*swap_out) (abfd, irela, erela);
8042
    }
8264
    }
-
 
8265
 
-
 
8266
  if (sort && count != 0)
-
 
8267
    {
-
 
8268
      bfd_vma (*ext_r_off) (const void *);
-
 
8269
      bfd_vma r_off;
-
 
8270
      size_t elt_size;
-
 
8271
      bfd_byte *base, *end, *p, *loc;
-
 
8272
      bfd_byte *buf = NULL;
-
 
8273
 
-
 
8274
      if (bed->s->arch_size == 32)
-
 
8275
	{
-
 
8276
	  if (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
-
 
8277
	    ext_r_off = ext32l_r_offset;
-
 
8278
	  else if (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
-
 
8279
	    ext_r_off = ext32b_r_offset;
-
 
8280
	  else
-
 
8281
	    abort ();
-
 
8282
	}
-
 
8283
      else
-
 
8284
	{
-
 
8285
#ifdef BFD_HOST_64_BIT
-
 
8286
	  if (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
-
 
8287
	    ext_r_off = ext64l_r_offset;
-
 
8288
	  else if (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
-
 
8289
	    ext_r_off = ext64b_r_offset;
-
 
8290
	  else
-
 
8291
#endif
-
 
8292
	    abort ();
-
 
8293
	}
-
 
8294
 
-
 
8295
      /*  Must use a stable sort here.  A modified insertion sort,
-
 
8296
	  since the relocs are mostly sorted already.  */
-
 
8297
      elt_size = reldata->hdr->sh_entsize;
-
 
8298
      base = reldata->hdr->contents;
-
 
8299
      end = base + count * elt_size;
-
 
8300
      if (elt_size > sizeof (Elf64_External_Rela))
-
 
8301
	abort ();
-
 
8302
 
-
 
8303
      /* Ensure the first element is lowest.  This acts as a sentinel,
-
 
8304
	 speeding the main loop below.  */
-
 
8305
      r_off = (*ext_r_off) (base);
-
 
8306
      for (p = loc = base; (p += elt_size) < end; )
-
 
8307
	{
-
 
8308
	  bfd_vma r_off2 = (*ext_r_off) (p);
-
 
8309
	  if (r_off > r_off2)
-
 
8310
	    {
-
 
8311
	      r_off = r_off2;
-
 
8312
	      loc = p;
-
 
8313
	    }
-
 
8314
	}
-
 
8315
      if (loc != base)
-
 
8316
	{
-
 
8317
	  /* Don't just swap *base and *loc as that changes the order
-
 
8318
	     of the original base[0] and base[1] if they happen to
-
 
8319
	     have the same r_offset.  */
-
 
8320
	  bfd_byte onebuf[sizeof (Elf64_External_Rela)];
-
 
8321
	  memcpy (onebuf, loc, elt_size);
-
 
8322
	  memmove (base + elt_size, base, loc - base);
-
 
8323
	  memcpy (base, onebuf, elt_size);
-
 
8324
	}
-
 
8325
 
-
 
8326
      for (p = base + elt_size; (p += elt_size) < end; )
-
 
8327
	{
-
 
8328
	  /* base to p is sorted, *p is next to insert.  */
-
 
8329
	  r_off = (*ext_r_off) (p);
-
 
8330
	  /* Search the sorted region for location to insert.  */
-
 
8331
	  loc = p - elt_size;
-
 
8332
	  while (r_off < (*ext_r_off) (loc))
-
 
8333
	    loc -= elt_size;
-
 
8334
	  loc += elt_size;
-
 
8335
	  if (loc != p)
-
 
8336
	    {
-
 
8337
	      /* Chances are there is a run of relocs to insert here,
-
 
8338
		 from one of more input files.  Files are not always
-
 
8339
		 linked in order due to the way elf_link_input_bfd is
-
 
8340
		 called.  See pr17666.  */
-
 
8341
	      size_t sortlen = p - loc;
-
 
8342
	      bfd_vma r_off2 = (*ext_r_off) (loc);
-
 
8343
	      size_t runlen = elt_size;
-
 
8344
	      size_t buf_size = 96 * 1024;
-
 
8345
	      while (p + runlen < end
-
 
8346
		     && (sortlen <= buf_size
-
 
8347
			 || runlen + elt_size <= buf_size)
-
 
8348
		     && r_off2 > (*ext_r_off) (p + runlen))
-
 
8349
		runlen += elt_size;
-
 
8350
	      if (buf == NULL)
-
 
8351
		{
-
 
8352
		  buf = bfd_malloc (buf_size);
-
 
8353
		  if (buf == NULL)
-
 
8354
		    return FALSE;
-
 
8355
		}
-
 
8356
	      if (runlen < sortlen)
-
 
8357
		{
-
 
8358
		  memcpy (buf, p, runlen);
-
 
8359
		  memmove (loc + runlen, loc, sortlen);
-
 
8360
		  memcpy (loc, buf, runlen);
-
 
8361
		}
-
 
8362
	      else
-
 
8363
		{
-
 
8364
		  memcpy (buf, loc, sortlen);
-
 
8365
		  memmove (loc, p, runlen);
-
 
8366
		  memcpy (loc + runlen, buf, sortlen);
-
 
8367
		}
-
 
8368
	      p += runlen - elt_size;
-
 
8369
	    }
-
 
8370
	}
-
 
8371
      /* Hashes are no longer valid.  */
-
 
8372
      free (reldata->hashes);
-
 
8373
      reldata->hashes = NULL;
-
 
8374
      free (buf);
-
 
8375
    }
-
 
8376
  return TRUE;
8043
}
8377
}
Line 8044... Line 8378...
8044
 
8378
 
8045
struct elf_link_sort_rela
8379
struct elf_link_sort_rela
8046
{
8380
{
Line 8368... Line 8702...
8368
  free (sort);
8702
  free (sort);
8369
  *psec = dynamic_relocs;
8703
  *psec = dynamic_relocs;
8370
  return ret;
8704
  return ret;
8371
}
8705
}
Line 8372... Line -...
8372
 
-
 
8373
/* Flush the output symbols to the file.  */
-
 
8374
 
-
 
8375
static bfd_boolean
-
 
8376
elf_link_flush_output_syms (struct elf_final_link_info *flinfo,
-
 
8377
			    const struct elf_backend_data *bed)
-
 
8378
{
-
 
8379
  if (flinfo->symbuf_count > 0)
-
 
8380
    {
-
 
8381
      Elf_Internal_Shdr *hdr;
-
 
8382
      file_ptr pos;
-
 
8383
      bfd_size_type amt;
-
 
8384
 
-
 
8385
      hdr = &elf_tdata (flinfo->output_bfd)->symtab_hdr;
-
 
8386
      pos = hdr->sh_offset + hdr->sh_size;
-
 
8387
      amt = flinfo->symbuf_count * bed->s->sizeof_sym;
-
 
8388
      if (bfd_seek (flinfo->output_bfd, pos, SEEK_SET) != 0
-
 
8389
	  || bfd_bwrite (flinfo->symbuf, amt, flinfo->output_bfd) != amt)
-
 
8390
	return FALSE;
-
 
8391
 
-
 
8392
      hdr->sh_size += amt;
-
 
8393
      flinfo->symbuf_count = 0;
-
 
8394
    }
-
 
8395
 
-
 
8396
  return TRUE;
-
 
8397
}
-
 
8398
 
8706
 
Line 8399... Line 8707...
8399
/* Add a symbol to the output symbol table.  */
8707
/* Add a symbol to the output symbol string table.  */
8400
 
8708
 
8401
static int
8709
static int
8402
elf_link_output_sym (struct elf_final_link_info *flinfo,
8710
elf_link_output_symstrtab (struct elf_final_link_info *flinfo,
8403
		     const char *name,
8711
			   const char *name,
8404
		     Elf_Internal_Sym *elfsym,
8712
			   Elf_Internal_Sym *elfsym,
8405
		     asection *input_sec,
8713
			   asection *input_sec,
8406
		     struct elf_link_hash_entry *h)
-
 
8407
{
-
 
8408
  bfd_byte *dest;
8714
			   struct elf_link_hash_entry *h)
8409
  Elf_External_Sym_Shndx *destshndx;
8715
{
8410
  int (*output_symbol_hook)
8716
  int (*output_symbol_hook)
-
 
8717
    (struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *,
8411
    (struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *,
8718
     struct elf_link_hash_entry *);
-
 
8719
  struct elf_link_hash_table *hash_table;
-
 
8720
  const struct elf_backend_data *bed;
-
 
8721
  bfd_size_type strtabsize;
Line 8412... Line 8722...
8412
     struct elf_link_hash_entry *);
8722
 
8413
  const struct elf_backend_data *bed;
8723
  BFD_ASSERT (elf_onesymtab (flinfo->output_bfd));
8414
 
8724
 
8415
  bed = get_elf_backend_data (flinfo->output_bfd);
8725
  bed = get_elf_backend_data (flinfo->output_bfd);
8416
  output_symbol_hook = bed->elf_backend_link_output_symbol_hook;
8726
  output_symbol_hook = bed->elf_backend_link_output_symbol_hook;
8417
  if (output_symbol_hook != NULL)
8727
  if (output_symbol_hook != NULL)
8418
    {
8728
    {
8419
      int ret = (*output_symbol_hook) (flinfo->info, name, elfsym, input_sec, h);
8729
      int ret = (*output_symbol_hook) (flinfo->info, name, elfsym, input_sec, h);
Line 8420... Line 8730...
8420
      if (ret != 1)
8730
      if (ret != 1)
8421
	return ret;
8731
	return ret;
8422
    }
8732
    }
8423
 
8733
 
8424
  if (name == NULL || *name == '\0')
8734
  if (name == NULL
8425
    elfsym->st_name = 0;
8735
      || *name == '\0'
-
 
8736
      || (input_sec->flags & SEC_EXCLUDE))
-
 
8737
    elfsym->st_name = (unsigned long) -1;
-
 
8738
  else
8426
  else if (input_sec->flags & SEC_EXCLUDE)
8739
    {
8427
    elfsym->st_name = 0;
8740
      /* Call _bfd_elf_strtab_offset after _bfd_elf_strtab_finalize
8428
  else
8741
	 to get the final offset for st_name.  */
8429
    {
8742
      elfsym->st_name
8430
      elfsym->st_name = (unsigned long) _bfd_stringtab_add (flinfo->symstrtab,
8743
	= (unsigned long) _bfd_elf_strtab_add (flinfo->symstrtab,
Line 8431... Line 8744...
8431
							    name, TRUE, FALSE);
8744
					       name, FALSE);
-
 
8745
      if (elfsym->st_name == (unsigned long) -1)
-
 
8746
	return 0;
8432
      if (elfsym->st_name == (unsigned long) -1)
8747
    }
-
 
8748
 
-
 
8749
  hash_table = elf_hash_table (flinfo->info);
-
 
8750
  strtabsize = hash_table->strtabsize;
-
 
8751
  if (strtabsize <= hash_table->strtabcount)
-
 
8752
    {
-
 
8753
      strtabsize += strtabsize;
8433
	return 0;
8754
      hash_table->strtabsize = strtabsize;
8434
    }
8755
      strtabsize *= sizeof (*hash_table->strtab);
8435
 
8756
      hash_table->strtab
-
 
8757
	= (struct elf_sym_strtab *) bfd_realloc (hash_table->strtab,
-
 
8758
						 strtabsize);
-
 
8759
      if (hash_table->strtab == NULL)
-
 
8760
	return 0;
-
 
8761
    }
-
 
8762
  hash_table->strtab[hash_table->strtabcount].sym = *elfsym;
-
 
8763
  hash_table->strtab[hash_table->strtabcount].dest_index
-
 
8764
    = hash_table->strtabcount;
Line -... Line 8765...
-
 
8765
  hash_table->strtab[hash_table->strtabcount].destshndx_index
-
 
8766
    = flinfo->symshndxbuf ? bfd_get_symcount (flinfo->output_bfd) : 0;
-
 
8767
 
8436
  if (flinfo->symbuf_count >= flinfo->symbuf_size)
8768
  bfd_get_symcount (flinfo->output_bfd) += 1;
8437
    {
8769
  hash_table->strtabcount += 1;
-
 
8770
 
8438
      if (! elf_link_flush_output_syms (flinfo, bed))
8771
  return 1;
-
 
8772
}
8439
	return 0;
8773
 
-
 
8774
/* Swap symbols out to the symbol table and flush the output symbols to
-
 
8775
   the file.  */
-
 
8776
 
-
 
8777
static bfd_boolean
-
 
8778
elf_link_swap_symbols_out (struct elf_final_link_info *flinfo)
-
 
8779
{
-
 
8780
  struct elf_link_hash_table *hash_table = elf_hash_table (flinfo->info);
-
 
8781
  bfd_size_type amt, i;
-
 
8782
  const struct elf_backend_data *bed;
-
 
8783
  bfd_byte *symbuf;
-
 
8784
  Elf_Internal_Shdr *hdr;
8440
    }
8785
  file_ptr pos;
-
 
8786
  bfd_boolean ret;
-
 
8787
 
-
 
8788
  if (!hash_table->strtabcount)
-
 
8789
    return TRUE;
-
 
8790
 
-
 
8791
  BFD_ASSERT (elf_onesymtab (flinfo->output_bfd));
-
 
8792
 
-
 
8793
  bed = get_elf_backend_data (flinfo->output_bfd);
-
 
8794
 
8441
 
8795
  amt = bed->s->sizeof_sym * hash_table->strtabcount;
-
 
8796
  symbuf = (bfd_byte *) bfd_malloc (amt);
-
 
8797
  if (symbuf == NULL)
-
 
8798
    return FALSE;
-
 
8799
 
-
 
8800
  if (flinfo->symshndxbuf)
8442
  dest = flinfo->symbuf + flinfo->symbuf_count * bed->s->sizeof_sym;
8801
    {
-
 
8802
      amt = (sizeof (Elf_External_Sym_Shndx)
-
 
8803
	     * (bfd_get_symcount (flinfo->output_bfd)));
-
 
8804
      flinfo->symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt);
Line 8443... Line 8805...
8443
  destshndx = flinfo->symshndxbuf;
8805
      if (flinfo->symshndxbuf == NULL)
-
 
8806
	{
8444
  if (destshndx != NULL)
8807
	  free (symbuf);
8445
    {
8808
	  return FALSE;
8446
      if (bfd_get_symcount (flinfo->output_bfd) >= flinfo->shndxbuf_size)
8809
	}
8447
	{
8810
    }
8448
	  bfd_size_type amt;
8811
 
-
 
8812
  for (i = 0; i < hash_table->strtabcount; i++)
8449
 
8813
    {
-
 
8814
      struct elf_sym_strtab *elfsym = &hash_table->strtab[i];
-
 
8815
      if (elfsym->sym.st_name == (unsigned long) -1)
-
 
8816
	elfsym->sym.st_name = 0;
-
 
8817
      else
8450
	  amt = flinfo->shndxbuf_size * sizeof (Elf_External_Sym_Shndx);
8818
	elfsym->sym.st_name
-
 
8819
	  = (unsigned long) _bfd_elf_strtab_offset (flinfo->symstrtab,
8451
	  destshndx = (Elf_External_Sym_Shndx *) bfd_realloc (destshndx,
8820
						    elfsym->sym.st_name);
-
 
8821
      bed->s->swap_symbol_out (flinfo->output_bfd, &elfsym->sym,
-
 
8822
			       ((bfd_byte *) symbuf
-
 
8823
				+ (elfsym->dest_index
-
 
8824
				   * bed->s->sizeof_sym)),
-
 
8825
			       (flinfo->symshndxbuf
8452
                                                              amt * 2);
8826
				+ elfsym->destshndx_index));
-
 
8827
    }
-
 
8828
 
-
 
8829
  hdr = &elf_tdata (flinfo->output_bfd)->symtab_hdr;
8453
	  if (destshndx == NULL)
8830
  pos = hdr->sh_offset + hdr->sh_size;
-
 
8831
  amt = hash_table->strtabcount * bed->s->sizeof_sym;
-
 
8832
  if (bfd_seek (flinfo->output_bfd, pos, SEEK_SET) == 0
Line 8454... Line -...
8454
	    return 0;
-
 
8455
	  flinfo->symshndxbuf = destshndx;
8833
      && bfd_bwrite (symbuf, amt, flinfo->output_bfd) == amt)
8456
	  memset ((char *) destshndx + amt, 0, amt);
-
 
Line -... Line 8834...
-
 
8834
    {
-
 
8835
      hdr->sh_size += amt;
-
 
8836
      ret = TRUE;
8457
	  flinfo->shndxbuf_size *= 2;
8837
    }
8458
	}
8838
  else
Line 8459... Line 8839...
8459
      destshndx += bfd_get_symcount (flinfo->output_bfd);
8839
    ret = FALSE;
Line 8460... Line 8840...
8460
    }
8840
 
Line 8658... Line 9038...
8658
  Elf_Internal_Sym sym;
9038
  Elf_Internal_Sym sym;
8659
  asection *input_sec;
9039
  asection *input_sec;
8660
  const struct elf_backend_data *bed;
9040
  const struct elf_backend_data *bed;
8661
  long indx;
9041
  long indx;
8662
  int ret;
9042
  int ret;
-
 
9043
  /* A symbol is bound locally if it is forced local or it is locally
-
 
9044
     defined, hidden versioned, not referenced by shared library and
-
 
9045
     not exported when linking executable.  */
-
 
9046
  bfd_boolean local_bind = (h->forced_local
-
 
9047
			    || (bfd_link_executable (flinfo->info)
-
 
9048
				&& !flinfo->info->export_dynamic
-
 
9049
				&& !h->dynamic
-
 
9050
				&& !h->ref_dynamic
-
 
9051
				&& h->def_regular
-
 
9052
				&& h->versioned == versioned_hidden));
Line 8663... Line 9053...
8663
 
9053
 
8664
  if (h->root.type == bfd_link_hash_warning)
9054
  if (h->root.type == bfd_link_hash_warning)
8665
    {
9055
    {
8666
      h = (struct elf_link_hash_entry *) h->root.u.i.link;
9056
      h = (struct elf_link_hash_entry *) h->root.u.i.link;
Line 8669... Line 9059...
8669
    }
9059
    }
Line 8670... Line 9060...
8670
 
9060
 
8671
  /* Decide whether to output this symbol in this pass.  */
9061
  /* Decide whether to output this symbol in this pass.  */
8672
  if (eoinfo->localsyms)
9062
  if (eoinfo->localsyms)
8673
    {
9063
    {
8674
      if (!h->forced_local)
-
 
8675
	return TRUE;
-
 
8676
      if (eoinfo->second_pass
-
 
8677
	  && !((h->root.type == bfd_link_hash_defined
-
 
8678
		|| h->root.type == bfd_link_hash_defweak)
-
 
8679
	       && h->root.u.def.section->output_section != NULL))
9064
      if (!local_bind)
8680
	return TRUE;
9065
	return TRUE;
8681
    }
9066
    }
8682
  else
9067
  else
8683
    {
9068
    {
8684
      if (h->forced_local)
9069
      if (local_bind)
8685
	return TRUE;
9070
	return TRUE;
Line 8686... Line 9071...
8686
    }
9071
    }
Line 8722... Line 9107...
8722
	}
9107
	}
8723
    }
9108
    }
Line 8724... Line 9109...
8724
 
9109
 
8725
  /* We should also warn if a forced local symbol is referenced from
9110
  /* We should also warn if a forced local symbol is referenced from
8726
     shared libraries.  */
9111
     shared libraries.  */
8727
  if (!flinfo->info->relocatable
-
 
8728
      && flinfo->info->executable
9112
  if (bfd_link_executable (flinfo->info)
8729
      && h->forced_local
9113
      && h->forced_local
8730
      && h->ref_dynamic
9114
      && h->ref_dynamic
8731
      && h->def_regular
9115
      && h->def_regular
8732
      && !h->dynamic_def
9116
      && !h->dynamic_def
Line 8777... Line 9161...
8777
    strip = TRUE;
9161
    strip = TRUE;
8778
  else if ((h->root.type == bfd_link_hash_defined
9162
  else if ((h->root.type == bfd_link_hash_defined
8779
	    || h->root.type == bfd_link_hash_defweak)
9163
	    || h->root.type == bfd_link_hash_defweak)
8780
	   && ((flinfo->info->strip_discarded
9164
	   && ((flinfo->info->strip_discarded
8781
		&& discarded_section (h->root.u.def.section))
9165
		&& discarded_section (h->root.u.def.section))
-
 
9166
	       || ((h->root.u.def.section->flags & SEC_LINKER_CREATED) == 0
8782
	       || (h->root.u.def.section->owner != NULL
9167
		   && h->root.u.def.section->owner != NULL
8783
		   && (h->root.u.def.section->owner->flags & BFD_PLUGIN) != 0)))
9168
		   && (h->root.u.def.section->owner->flags & BFD_PLUGIN) != 0)))
8784
    strip = TRUE;
9169
    strip = TRUE;
8785
  else if ((h->root.type == bfd_link_hash_undefined
9170
  else if ((h->root.type == bfd_link_hash_undefined
8786
	    || h->root.type == bfd_link_hash_undefweak)
9171
	    || h->root.type == bfd_link_hash_undefweak)
8787
	   && h->root.u.undef.abfd != NULL
9172
	   && h->root.u.undef.abfd != NULL
Line 8800... Line 9185...
8800
    return TRUE;
9185
    return TRUE;
Line 8801... Line 9186...
8801
 
9186
 
8802
  sym.st_value = 0;
9187
  sym.st_value = 0;
8803
  sym.st_size = h->size;
9188
  sym.st_size = h->size;
8804
  sym.st_other = h->other;
9189
  sym.st_other = h->other;
8805
  if (h->forced_local)
9190
  if (local_bind)
8806
    {
9191
    {
8807
      sym.st_info = ELF_ST_INFO (STB_LOCAL, h->type);
9192
      sym.st_info = ELF_ST_INFO (STB_LOCAL, h->type);
8808
      /* Turn off visibility on local symbol.  */
9193
      /* Turn off visibility on local symbol.  */
8809
      sym.st_other &= ~ELF_ST_VISIBILITY (-1);
9194
      sym.st_other &= ~ELF_ST_VISIBILITY (-1);
Line 8836... Line 9221...
8836
    case bfd_link_hash_defweak:
9221
    case bfd_link_hash_defweak:
8837
      {
9222
      {
8838
	input_sec = h->root.u.def.section;
9223
	input_sec = h->root.u.def.section;
8839
	if (input_sec->output_section != NULL)
9224
	if (input_sec->output_section != NULL)
8840
	  {
9225
	  {
8841
	    if (eoinfo->localsyms && flinfo->filesym_count == 1)
-
 
8842
	      {
-
 
8843
		bfd_boolean second_pass_sym
-
 
8844
		  = (input_sec->owner == flinfo->output_bfd
-
 
8845
		     || input_sec->owner == NULL
-
 
8846
		     || (input_sec->flags & SEC_LINKER_CREATED) != 0
-
 
8847
		     || (input_sec->owner->flags & BFD_LINKER_CREATED) != 0);
-
 
8848
 
-
 
8849
		eoinfo->need_second_pass |= second_pass_sym;
-
 
8850
		if (eoinfo->second_pass != second_pass_sym)
-
 
8851
		  return TRUE;
-
 
8852
	      }
-
 
8853
 
-
 
8854
	    sym.st_shndx =
9226
	    sym.st_shndx =
8855
	      _bfd_elf_section_from_bfd_section (flinfo->output_bfd,
9227
	      _bfd_elf_section_from_bfd_section (flinfo->output_bfd,
8856
						 input_sec->output_section);
9228
						 input_sec->output_section);
8857
	    if (sym.st_shndx == SHN_BAD)
9229
	    if (sym.st_shndx == SHN_BAD)
8858
	      {
9230
	      {
Line 8866... Line 9238...
8866
 
9238
 
8867
	    /* ELF symbols in relocatable files are section relative,
9239
	    /* ELF symbols in relocatable files are section relative,
8868
	       but in nonrelocatable files they are virtual
9240
	       but in nonrelocatable files they are virtual
8869
	       addresses.  */
9241
	       addresses.  */
8870
	    sym.st_value = h->root.u.def.value + input_sec->output_offset;
9242
	    sym.st_value = h->root.u.def.value + input_sec->output_offset;
8871
	    if (!flinfo->info->relocatable)
9243
	    if (!bfd_link_relocatable (flinfo->info))
8872
	      {
9244
	      {
8873
		sym.st_value += input_sec->output_section->vma;
9245
		sym.st_value += input_sec->output_section->vma;
8874
		if (h->type == STT_TLS)
9246
		if (h->type == STT_TLS)
8875
		  {
9247
		  {
8876
		    asection *tls_sec = elf_hash_table (flinfo->info)->tls_sec;
9248
		    asection *tls_sec = elf_hash_table (flinfo->info)->tls_sec;
8877
		    if (tls_sec != NULL)
9249
		    if (tls_sec != NULL)
8878
		      sym.st_value -= tls_sec->vma;
-
 
8879
		    else
-
 
8880
		      {
-
 
8881
			/* The TLS section may have been garbage collected.  */
-
 
8882
			BFD_ASSERT (flinfo->info->gc_sections
-
 
8883
				    && !input_sec->gc_mark);
-
 
8884
		      }
9250
		      sym.st_value -= tls_sec->vma;
8885
		  }
9251
		  }
8886
	      }
9252
	      }
8887
	  }
9253
	  }
8888
	else
9254
	else
Line 8916... Line 9282...
8916
     symbol.  FIXME: Not calling elf_backend_finish_dynamic_symbol for
9282
     symbol.  FIXME: Not calling elf_backend_finish_dynamic_symbol for
8917
     forced local syms when non-shared is due to a historical quirk.
9283
     forced local syms when non-shared is due to a historical quirk.
8918
     STT_GNU_IFUNC symbol must go through PLT.  */
9284
     STT_GNU_IFUNC symbol must go through PLT.  */
8919
  if ((h->type == STT_GNU_IFUNC
9285
  if ((h->type == STT_GNU_IFUNC
8920
       && h->def_regular
9286
       && h->def_regular
8921
       && !flinfo->info->relocatable)
9287
       && !bfd_link_relocatable (flinfo->info))
8922
      || ((h->dynindx != -1
9288
      || ((h->dynindx != -1
8923
	   || h->forced_local)
9289
	   || h->forced_local)
8924
	  && ((flinfo->info->shared
9290
	  && ((bfd_link_pic (flinfo->info)
8925
	       && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
9291
	       && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
8926
		   || h->root.type != bfd_link_hash_undefweak))
9292
		   || h->root.type != bfd_link_hash_undefweak))
8927
	      || !h->forced_local)
9293
	      || !h->forced_local)
8928
	  && elf_hash_table (flinfo->info)->dynamic_sections_created))
9294
	  && elf_hash_table (flinfo->info)->dynamic_sections_created))
8929
    {
9295
    {
Line 8969... Line 9335...
8969
      && h->def_dynamic)
9335
      && h->def_dynamic)
8970
    sym.st_size = 0;
9336
    sym.st_size = 0;
Line 8971... Line 9337...
8971
 
9337
 
8972
  /* If a non-weak symbol with non-default visibility is not defined
9338
  /* If a non-weak symbol with non-default visibility is not defined
8973
     locally, it is a fatal error.  */
9339
     locally, it is a fatal error.  */
8974
  if (!flinfo->info->relocatable
9340
  if (!bfd_link_relocatable (flinfo->info)
8975
      && ELF_ST_VISIBILITY (sym.st_other) != STV_DEFAULT
9341
      && ELF_ST_VISIBILITY (sym.st_other) != STV_DEFAULT
8976
      && ELF_ST_BIND (sym.st_info) != STB_WEAK
9342
      && ELF_ST_BIND (sym.st_info) != STB_WEAK
8977
      && h->root.type == bfd_link_hash_undefined
9343
      && h->root.type == bfd_link_hash_undefined
8978
      && !h->def_regular)
9344
      && !h->def_regular)
Line 8992... Line 9358...
8992
    }
9358
    }
Line 8993... Line 9359...
8993
 
9359
 
8994
  /* If this symbol should be put in the .dynsym section, then put it
9360
  /* If this symbol should be put in the .dynsym section, then put it
8995
     there now.  We already know the symbol index.  We also fill in
9361
     there now.  We already know the symbol index.  We also fill in
8996
     the entry in the .hash section.  */
9362
     the entry in the .hash section.  */
8997
  if (flinfo->dynsym_sec != NULL
9363
  if (elf_hash_table (flinfo->info)->dynsym != NULL
8998
      && h->dynindx != -1
9364
      && h->dynindx != -1
8999
      && elf_hash_table (flinfo->info)->dynamic_sections_created)
9365
      && elf_hash_table (flinfo->info)->dynamic_sections_created)
9000
    {
9366
    {
Line 9001... Line 9367...
9001
      bfd_byte *esym;
9367
      bfd_byte *esym;
9002
 
9368
 
9003
      /* Since there is no version information in the dynamic string,
9369
      /* Since there is no version information in the dynamic string,
-
 
9370
	 if there is no version info in symbol version section, we will
-
 
9371
	 have a run-time problem if not linking executable, referenced
9004
	 if there is no version info in symbol version section, we will
9372
	 by shared library, not locally defined, or not bound locally.
-
 
9373
      */
-
 
9374
      if (h->verinfo.verdef == NULL
-
 
9375
	  && !local_bind
-
 
9376
	  && (!bfd_link_executable (flinfo->info)
9005
	 have a run-time problem.  */
9377
	      || h->ref_dynamic
9006
      if (h->verinfo.verdef == NULL)
9378
	      || !h->def_regular))
Line 9007... Line 9379...
9007
	{
9379
	{
9008
	  char *p = strrchr (h->root.root.string, ELF_VER_CHR);
9380
	  char *p = strrchr (h->root.root.string, ELF_VER_CHR);
Line 9016... Line 9388...
9016
	      return FALSE;
9388
	      return FALSE;
9017
	    }
9389
	    }
9018
	}
9390
	}
Line 9019... Line 9391...
9019
 
9391
 
-
 
9392
      sym.st_name = h->dynstr_index;
9020
      sym.st_name = h->dynstr_index;
9393
      esym = (elf_hash_table (flinfo->info)->dynsym->contents
9021
      esym = flinfo->dynsym_sec->contents + h->dynindx * bed->s->sizeof_sym;
9394
	      + h->dynindx * bed->s->sizeof_sym);
9022
      if (!check_dynsym (flinfo->output_bfd, &sym))
9395
      if (!check_dynsym (flinfo->output_bfd, &sym))
9023
	{
9396
	{
9024
	  eoinfo->failed = TRUE;
9397
	  eoinfo->failed = TRUE;
9025
	  return FALSE;
9398
	  return FALSE;
Line 9054... Line 9427...
9054
	  Elf_Internal_Versym iversym;
9427
	  Elf_Internal_Versym iversym;
9055
	  Elf_External_Versym *eversym;
9428
	  Elf_External_Versym *eversym;
Line 9056... Line 9429...
9056
 
9429
 
9057
	  if (!h->def_regular)
9430
	  if (!h->def_regular)
9058
	    {
9431
	    {
-
 
9432
	      if (h->verinfo.verdef == NULL
-
 
9433
		  || (elf_dyn_lib_class (h->verinfo.verdef->vd_bfd)
9059
	      if (h->verinfo.verdef == NULL)
9434
		      & (DYN_AS_NEEDED | DYN_DT_NEEDED | DYN_NO_NEEDED)))
9060
		iversym.vs_vers = 0;
9435
		iversym.vs_vers = 0;
9061
	      else
9436
	      else
9062
		iversym.vs_vers = h->verinfo.verdef->vd_exp_refno + 1;
9437
		iversym.vs_vers = h->verinfo.verdef->vd_exp_refno + 1;
9063
	    }
9438
	    }
Line 9069... Line 9444...
9069
		iversym.vs_vers = h->verinfo.vertree->vernum + 1;
9444
		iversym.vs_vers = h->verinfo.vertree->vernum + 1;
9070
	      if (flinfo->info->create_default_symver)
9445
	      if (flinfo->info->create_default_symver)
9071
		iversym.vs_vers++;
9446
		iversym.vs_vers++;
9072
	    }
9447
	    }
Line -... Line 9448...
-
 
9448
 
9073
 
9449
	  /* Turn on VERSYM_HIDDEN only if the hidden versioned symbol is
-
 
9450
	     defined locally.  */
9074
	  if (h->hidden)
9451
	  if (h->versioned == versioned_hidden && h->def_regular)
Line 9075... Line 9452...
9075
	    iversym.vs_vers |= VERSYM_HIDDEN;
9452
	    iversym.vs_vers |= VERSYM_HIDDEN;
9076
 
9453
 
9077
	  eversym = (Elf_External_Versym *) flinfo->symver_sec->contents;
9454
	  eversym = (Elf_External_Versym *) flinfo->symver_sec->contents;
Line 9083... Line 9460...
9083
  /* If we're stripping it, then it was just a dynamic symbol, and
9460
  /* If we're stripping it, then it was just a dynamic symbol, and
9084
     there's nothing else to do.  */
9461
     there's nothing else to do.  */
9085
  if (strip || (input_sec->flags & SEC_EXCLUDE) != 0)
9462
  if (strip || (input_sec->flags & SEC_EXCLUDE) != 0)
9086
    return TRUE;
9463
    return TRUE;
Line -... Line 9464...
-
 
9464
 
-
 
9465
  /* Output a FILE symbol so that following locals are not associated
-
 
9466
     with the wrong input file.  We need one for forced local symbols
-
 
9467
     if we've seen more than one FILE symbol or when we have exactly
-
 
9468
     one FILE symbol but global symbols are present in a file other
-
 
9469
     than the one with the FILE symbol.  We also need one if linker
-
 
9470
     defined symbols are present.  In practice these conditions are
-
 
9471
     always met, so just emit the FILE symbol unconditionally.  */
-
 
9472
  if (eoinfo->localsyms
-
 
9473
      && !eoinfo->file_sym_done
-
 
9474
      && eoinfo->flinfo->filesym_count != 0)
-
 
9475
    {
-
 
9476
      Elf_Internal_Sym fsym;
-
 
9477
 
-
 
9478
      memset (&fsym, 0, sizeof (fsym));
-
 
9479
      fsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
-
 
9480
      fsym.st_shndx = SHN_ABS;
-
 
9481
      if (!elf_link_output_symstrtab (eoinfo->flinfo, NULL, &fsym,
-
 
9482
				      bfd_und_section_ptr, NULL))
-
 
9483
	return FALSE;
-
 
9484
 
-
 
9485
      eoinfo->file_sym_done = TRUE;
-
 
9486
    }
9087
 
9487
 
9088
  indx = bfd_get_symcount (flinfo->output_bfd);
9488
  indx = bfd_get_symcount (flinfo->output_bfd);
-
 
9489
  ret = elf_link_output_symstrtab (flinfo, h->root.root.string, &sym,
9089
  ret = elf_link_output_sym (flinfo, h->root.root.string, &sym, input_sec, h);
9490
				   input_sec, h);
9090
  if (ret == 0)
9491
  if (ret == 0)
9091
    {
9492
    {
9092
      eoinfo->failed = TRUE;
9493
      eoinfo->failed = TRUE;
9093
      return FALSE;
9494
      return FALSE;
Line 9110... Line 9511...
9110
 
9511
 
9111
  switch (sec->sec_info_type)
9512
  switch (sec->sec_info_type)
9112
    {
9513
    {
9113
    case SEC_INFO_TYPE_STABS:
9514
    case SEC_INFO_TYPE_STABS:
-
 
9515
    case SEC_INFO_TYPE_EH_FRAME:
9114
    case SEC_INFO_TYPE_EH_FRAME:
9516
    case SEC_INFO_TYPE_EH_FRAME_ENTRY:
9115
      return TRUE;
9517
      return TRUE;
9116
    default:
9518
    default:
9117
      break;
9519
      break;
Line 9349... Line 9751...
9349
      /* See if we are discarding symbols with this name.  */
9751
      /* See if we are discarding symbols with this name.  */
9350
      if ((flinfo->info->strip == strip_some
9752
      if ((flinfo->info->strip == strip_some
9351
	   && (bfd_hash_lookup (flinfo->info->keep_hash, name, FALSE, FALSE)
9753
	   && (bfd_hash_lookup (flinfo->info->keep_hash, name, FALSE, FALSE)
9352
	       == NULL))
9754
	       == NULL))
9353
	  || (((flinfo->info->discard == discard_sec_merge
9755
	  || (((flinfo->info->discard == discard_sec_merge
9354
		&& (isec->flags & SEC_MERGE) && !flinfo->info->relocatable)
9756
		&& (isec->flags & SEC_MERGE)
-
 
9757
		&& !bfd_link_relocatable (flinfo->info))
9355
	       || flinfo->info->discard == discard_l)
9758
	       || flinfo->info->discard == discard_l)
9356
	      && bfd_is_local_label_name (input_bfd, name)))
9759
	      && bfd_is_local_label_name (input_bfd, name)))
9357
	continue;
9760
	continue;
Line 9358... Line 9761...
9358
 
9761
 
9359
      if (ELF_ST_TYPE (isym->st_info) == STT_FILE)
9762
      if (ELF_ST_TYPE (isym->st_info) == STT_FILE)
-
 
9763
	{
-
 
9764
	  if (input_bfd->lto_output)
-
 
9765
	    /* -flto puts a temp file name here.  This means builds
-
 
9766
	       are not reproducible.  Discard the symbol.  */
9360
	{
9767
	    continue;
9361
	  have_file_sym = TRUE;
9768
	  have_file_sym = TRUE;
9362
	  flinfo->filesym_count += 1;
9769
	  flinfo->filesym_count += 1;
9363
	}
9770
	}
9364
      if (!have_file_sym)
9771
      if (!have_file_sym)
Line 9372... Line 9779...
9372
	  have_file_sym = TRUE;
9779
	  have_file_sym = TRUE;
9373
	  flinfo->filesym_count += 1;
9780
	  flinfo->filesym_count += 1;
9374
	  memset (&osym, 0, sizeof (osym));
9781
	  memset (&osym, 0, sizeof (osym));
9375
	  osym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
9782
	  osym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
9376
	  osym.st_shndx = SHN_ABS;
9783
	  osym.st_shndx = SHN_ABS;
9377
	  if (!elf_link_output_sym (flinfo, input_bfd->filename, &osym,
9784
	  if (!elf_link_output_symstrtab (flinfo,
-
 
9785
					  (input_bfd->lto_output ? NULL
-
 
9786
					   : input_bfd->filename),
9378
				    bfd_abs_section_ptr, NULL))
9787
					  &osym, bfd_abs_section_ptr,
-
 
9788
					  NULL))
9379
	    return FALSE;
9789
	    return FALSE;
9380
	}
9790
	}
Line 9381... Line 9791...
9381
 
9791
 
Line 9393... Line 9803...
9393
	 BFD section with a reasonable value for output_offset; below
9803
	 BFD section with a reasonable value for output_offset; below
9394
	 we assume that they also have a reasonable value for
9804
	 we assume that they also have a reasonable value for
9395
	 output_section.  Any special sections must be set up to meet
9805
	 output_section.  Any special sections must be set up to meet
9396
	 these requirements.  */
9806
	 these requirements.  */
9397
      osym.st_value += isec->output_offset;
9807
      osym.st_value += isec->output_offset;
9398
      if (!flinfo->info->relocatable)
9808
      if (!bfd_link_relocatable (flinfo->info))
9399
	{
9809
	{
9400
	  osym.st_value += isec->output_section->vma;
9810
	  osym.st_value += isec->output_section->vma;
9401
	  if (ELF_ST_TYPE (osym.st_info) == STT_TLS)
9811
	  if (ELF_ST_TYPE (osym.st_info) == STT_TLS)
9402
	    {
9812
	    {
9403
	      /* STT_TLS symbols are relative to PT_TLS segment base.  */
9813
	      /* STT_TLS symbols are relative to PT_TLS segment base.  */
Line 9405... Line 9815...
9405
	      osym.st_value -= elf_hash_table (flinfo->info)->tls_sec->vma;
9815
	      osym.st_value -= elf_hash_table (flinfo->info)->tls_sec->vma;
9406
	    }
9816
	    }
9407
	}
9817
	}
Line 9408... Line 9818...
9408
 
9818
 
9409
      indx = bfd_get_symcount (output_bfd);
9819
      indx = bfd_get_symcount (output_bfd);
9410
      ret = elf_link_output_sym (flinfo, name, &osym, isec, NULL);
9820
      ret = elf_link_output_symstrtab (flinfo, name, &osym, isec, NULL);
9411
      if (ret == 0)
9821
      if (ret == 0)
9412
	return FALSE;
9822
	return FALSE;
9413
      else if (ret == 1)
9823
      else if (ret == 1)
9414
	*pindex = indx;
9824
	*pindex = indx;
Line 9437... Line 9847...
9437
	{
9847
	{
9438
	  /* This section was omitted from the link.  */
9848
	  /* This section was omitted from the link.  */
9439
	  continue;
9849
	  continue;
9440
	}
9850
	}
Line 9441... Line 9851...
9441
 
9851
 
9442
      if (flinfo->info->relocatable
9852
      if (bfd_link_relocatable (flinfo->info)
9443
	  && (o->flags & (SEC_LINKER_CREATED | SEC_GROUP)) == SEC_GROUP)
9853
	  && (o->flags & (SEC_LINKER_CREATED | SEC_GROUP)) == SEC_GROUP)
9444
	{
9854
	{
9445
	  /* Deal with the group signature symbol.  */
9855
	  /* Deal with the group signature symbol.  */
9446
	  struct bfd_elf_section_data *sec_data = elf_section_data (o);
9856
	  struct bfd_elf_section_data *sec_data = elf_section_data (o);
Line 9488... Line 9898...
9488
		    return FALSE;
9898
		    return FALSE;
Line 9489... Line 9899...
9489
 
9899
 
Line 9490... Line 9900...
9490
		  sym.st_value += o->output_offset;
9900
		  sym.st_value += o->output_offset;
9491
 
9901
 
-
 
9902
		  indx = bfd_get_symcount (output_bfd);
9492
		  indx = bfd_get_symcount (output_bfd);
9903
		  ret = elf_link_output_symstrtab (flinfo, name, &sym, o,
9493
		  ret = elf_link_output_sym (flinfo, name, &sym, o, NULL);
9904
						   NULL);
9494
		  if (ret == 0)
9905
		  if (ret == 0)
9495
		    return FALSE;
9906
		    return FALSE;
9496
		  else if (ret == 1)
9907
		  else if (ret == 1)
Line 9517... Line 9928...
9517
      /* Get the contents of the section.  They have been cached by a
9928
      /* Get the contents of the section.  They have been cached by a
9518
	 relaxation routine.  Note that o is a section in an input
9929
	 relaxation routine.  Note that o is a section in an input
9519
	 file, so the contents field will not have been set by any of
9930
	 file, so the contents field will not have been set by any of
9520
	 the routines which work on output files.  */
9931
	 the routines which work on output files.  */
9521
      if (elf_section_data (o)->this_hdr.contents != NULL)
9932
      if (elf_section_data (o)->this_hdr.contents != NULL)
-
 
9933
	{
9522
	contents = elf_section_data (o)->this_hdr.contents;
9934
	  contents = elf_section_data (o)->this_hdr.contents;
-
 
9935
	  if (bed->caches_rawsize
-
 
9936
	      && o->rawsize != 0
-
 
9937
	      && o->rawsize < o->size)
-
 
9938
	    {
-
 
9939
	      memcpy (flinfo->contents, contents, o->rawsize);
-
 
9940
	      contents = flinfo->contents;
-
 
9941
	    }
-
 
9942
	}
9523
      else
9943
      else
9524
	{
9944
	{
9525
	  contents = flinfo->contents;
9945
	  contents = flinfo->contents;
9526
	  if (! bfd_get_full_section_contents (input_bfd, o, &contents))
9946
	  if (! bfd_get_full_section_contents (input_bfd, o, &contents))
9527
	    return FALSE;
9947
	    return FALSE;
Line 9614... Line 10034...
9614
			 || h->root.type == bfd_link_hash_warning)
10034
			 || h->root.type == bfd_link_hash_warning)
9615
		    h = (struct elf_link_hash_entry *) h->root.u.i.link;
10035
		    h = (struct elf_link_hash_entry *) h->root.u.i.link;
Line 9616... Line 10036...
9616
 
10036
 
Line -... Line 10037...
-
 
10037
		  s_type = h->type;
-
 
10038
 
-
 
10039
		  /* If a plugin symbol is referenced from a non-IR file,
-
 
10040
		     mark the symbol as undefined.  Note that the
-
 
10041
		     linker may attach linker created dynamic sections
-
 
10042
		     to the plugin bfd.  Symbols defined in linker
-
 
10043
		     created sections are not plugin symbols.  */
-
 
10044
		  if (h->root.non_ir_ref
-
 
10045
		      && (h->root.type == bfd_link_hash_defined
-
 
10046
			  || h->root.type == bfd_link_hash_defweak)
-
 
10047
		      && (h->root.u.def.section->flags
-
 
10048
			  & SEC_LINKER_CREATED) == 0
-
 
10049
		      && h->root.u.def.section->owner != NULL
-
 
10050
		      && (h->root.u.def.section->owner->flags
-
 
10051
			  & BFD_PLUGIN) != 0)
-
 
10052
		    {
-
 
10053
		      h->root.type = bfd_link_hash_undefined;
-
 
10054
		      h->root.u.undef.abfd = h->root.u.def.section->owner;
9617
		  s_type = h->type;
10055
		    }
9618
 
10056
 
9619
		  ps = NULL;
10057
		  ps = NULL;
9620
		  if (h->root.type == bfd_link_hash_defined
10058
		  if (h->root.type == bfd_link_hash_defined
Line 9632... Line 10070...
9632
		  sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr,
10070
		  sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr,
9633
					       sym, *ps);
10071
					       sym, *ps);
9634
		}
10072
		}
Line 9635... Line 10073...
9635
 
10073
 
9636
	      if ((s_type == STT_RELC || s_type == STT_SRELC)
10074
	      if ((s_type == STT_RELC || s_type == STT_SRELC)
9637
		  && !flinfo->info->relocatable)
10075
		  && !bfd_link_relocatable (flinfo->info))
9638
		{
10076
		{
9639
		  bfd_vma val;
10077
		  bfd_vma val;
9640
		  bfd_vma dot = (rel->r_offset
10078
		  bfd_vma dot = (rel->r_offset
9641
				 + o->output_offset + o->output_section->vma);
10079
				 + o->output_offset + o->output_section->vma);
Line 9722... Line 10160...
9722
				     flinfo->sections);
10160
				     flinfo->sections);
9723
	  if (!ret)
10161
	  if (!ret)
9724
	    return FALSE;
10162
	    return FALSE;
Line 9725... Line 10163...
9725
 
10163
 
9726
	  if (ret == 2
10164
	  if (ret == 2
9727
	      || flinfo->info->relocatable
10165
	      || bfd_link_relocatable (flinfo->info)
9728
	      || flinfo->info->emitrelocations)
10166
	      || flinfo->info->emitrelocations)
9729
	    {
10167
	    {
9730
	      Elf_Internal_Rela *irela;
10168
	      Elf_Internal_Rela *irela;
9731
	      Elf_Internal_Rela *irelaend, *irelamid;
10169
	      Elf_Internal_Rela *irelaend, *irelamid;
Line 9753... Line 10191...
9753
		irelamid += (NUM_SHDR_ENTRIES (esdi->rel.hdr)
10191
		irelamid += (NUM_SHDR_ENTRIES (esdi->rel.hdr)
9754
			     * bed->s->int_rels_per_ext_rel);
10192
			     * bed->s->int_rels_per_ext_rel);
9755
	      rel_hash_list = rel_hash;
10193
	      rel_hash_list = rel_hash;
9756
	      rela_hash_list = NULL;
10194
	      rela_hash_list = NULL;
9757
	      last_offset = o->output_offset;
10195
	      last_offset = o->output_offset;
9758
	      if (!flinfo->info->relocatable)
10196
	      if (!bfd_link_relocatable (flinfo->info))
9759
		last_offset += o->output_section->vma;
10197
		last_offset += o->output_section->vma;
9760
	      for (next_erel = 0; irela < irelaend; irela++, next_erel++)
10198
	      for (next_erel = 0; irela < irelaend; irela++, next_erel++)
9761
		{
10199
		{
9762
		  unsigned long r_symndx;
10200
		  unsigned long r_symndx;
9763
		  asection *sec;
10201
		  asection *sec;
Line 9793... Line 10231...
9793
		    }
10231
		    }
Line 9794... Line 10232...
9794
 
10232
 
Line 9795... Line 10233...
9795
		  irela->r_offset += o->output_offset;
10233
		  irela->r_offset += o->output_offset;
9796
 
10234
 
9797
		  /* Relocs in an executable have to be virtual addresses.  */
10235
		  /* Relocs in an executable have to be virtual addresses.  */
Line 9798... Line 10236...
9798
		  if (!flinfo->info->relocatable)
10236
		  if (!bfd_link_relocatable (flinfo->info))
Line 9799... Line 10237...
9799
		    irela->r_offset += o->output_section->vma;
10237
		    irela->r_offset += o->output_section->vma;
Line 9921... Line 10359...
9921
							       osec);
10359
							       osec);
9922
			  if (sym.st_shndx == SHN_BAD)
10360
			  if (sym.st_shndx == SHN_BAD)
9923
			    return FALSE;
10361
			    return FALSE;
Line 9924... Line 10362...
9924
 
10362
 
9925
			  sym.st_value += sec->output_offset;
10363
			  sym.st_value += sec->output_offset;
9926
			  if (!flinfo->info->relocatable)
10364
			  if (!bfd_link_relocatable (flinfo->info))
9927
			    {
10365
			    {
9928
			      sym.st_value += osec->vma;
10366
			      sym.st_value += osec->vma;
9929
			      if (ELF_ST_TYPE (sym.st_info) == STT_TLS)
10367
			      if (ELF_ST_TYPE (sym.st_info) == STT_TLS)
9930
				{
10368
				{
Line 9936... Line 10374...
9936
						   ->tls_sec->vma);
10374
						   ->tls_sec->vma);
9937
				}
10375
				}
9938
			    }
10376
			    }
Line 9939... Line 10377...
9939
 
10377
 
9940
			  indx = bfd_get_symcount (output_bfd);
10378
			  indx = bfd_get_symcount (output_bfd);
-
 
10379
			  ret = elf_link_output_symstrtab (flinfo, name,
9941
			  ret = elf_link_output_sym (flinfo, name, &sym, sec,
10380
							   &sym, sec,
9942
						     NULL);
10381
							   NULL);
9943
			  if (ret == 0)
10382
			  if (ret == 0)
9944
			    return FALSE;
10383
			    return FALSE;
9945
			  else if (ret == 1)
10384
			  else if (ret == 1)
Line 10007... Line 10446...
10007
	    if (! _bfd_elf_write_section_eh_frame (output_bfd, flinfo->info,
10446
	    if (! _bfd_elf_write_section_eh_frame (output_bfd, flinfo->info,
10008
						   o, contents))
10447
						   o, contents))
10009
	      return FALSE;
10448
	      return FALSE;
10010
	  }
10449
	  }
10011
	  break;
10450
	  break;
-
 
10451
	case SEC_INFO_TYPE_EH_FRAME_ENTRY:
-
 
10452
	  {
-
 
10453
	    if (! _bfd_elf_write_section_eh_frame_entry (output_bfd,
-
 
10454
							 flinfo->info,
-
 
10455
							 o, contents))
-
 
10456
	      return FALSE;
-
 
10457
	  }
-
 
10458
	  break;
10012
	default:
10459
	default:
10013
	  {
10460
	  {
10014
	    /* FIXME: octets_per_byte.  */
10461
	    /* FIXME: octets_per_byte.  */
10015
	    if (! (o->flags & SEC_EXCLUDE))
10462
	    if (! (o->flags & SEC_EXCLUDE))
10016
	      {
10463
	      {
Line 10150... Line 10597...
10150
      bfd_boolean ok;
10597
      bfd_boolean ok;
10151
      const char *sym_name;
10598
      const char *sym_name;
Line 10152... Line 10599...
10152
 
10599
 
10153
      size = (bfd_size_type) bfd_get_reloc_size (howto);
10600
      size = (bfd_size_type) bfd_get_reloc_size (howto);
10154
      buf = (bfd_byte *) bfd_zmalloc (size);
10601
      buf = (bfd_byte *) bfd_zmalloc (size);
10155
      if (buf == NULL)
10602
      if (buf == NULL && size != 0)
10156
	return FALSE;
10603
	return FALSE;
10157
      rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
10604
      rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
10158
      switch (rstat)
10605
      switch (rstat)
10159
	{
10606
	{
Line 10188... Line 10635...
10188
 
10635
 
10189
  /* The address of a reloc is relative to the section in a
10636
  /* The address of a reloc is relative to the section in a
10190
     relocatable file, and is a virtual address in an executable
10637
     relocatable file, and is a virtual address in an executable
10191
     file.  */
10638
     file.  */
10192
  offset = link_order->offset;
10639
  offset = link_order->offset;
10193
  if (! info->relocatable)
10640
  if (! bfd_link_relocatable (info))
Line 10194... Line 10641...
10194
    offset += output_section->vma;
10641
    offset += output_section->vma;
10195
 
10642
 
10196
  for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
10643
  for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
Line 10376... Line 10823...
10376
elf_final_link_free (bfd *obfd, struct elf_final_link_info *flinfo)
10823
elf_final_link_free (bfd *obfd, struct elf_final_link_info *flinfo)
10377
{
10824
{
10378
  asection *o;
10825
  asection *o;
Line 10379... Line 10826...
10379
 
10826
 
10380
  if (flinfo->symstrtab != NULL)
10827
  if (flinfo->symstrtab != NULL)
10381
    _bfd_stringtab_free (flinfo->symstrtab);
10828
    _bfd_elf_strtab_free (flinfo->symstrtab);
10382
  if (flinfo->contents != NULL)
10829
  if (flinfo->contents != NULL)
10383
    free (flinfo->contents);
10830
    free (flinfo->contents);
10384
  if (flinfo->external_relocs != NULL)
10831
  if (flinfo->external_relocs != NULL)
10385
    free (flinfo->external_relocs);
10832
    free (flinfo->external_relocs);
Line 10393... Line 10840...
10393
    free (flinfo->internal_syms);
10840
    free (flinfo->internal_syms);
10394
  if (flinfo->indices != NULL)
10841
  if (flinfo->indices != NULL)
10395
    free (flinfo->indices);
10842
    free (flinfo->indices);
10396
  if (flinfo->sections != NULL)
10843
  if (flinfo->sections != NULL)
10397
    free (flinfo->sections);
10844
    free (flinfo->sections);
10398
  if (flinfo->symbuf != NULL)
-
 
10399
    free (flinfo->symbuf);
-
 
10400
  if (flinfo->symshndxbuf != NULL)
10845
  if (flinfo->symshndxbuf != NULL)
10401
    free (flinfo->symshndxbuf);
10846
    free (flinfo->symshndxbuf);
10402
  for (o = obfd->sections; o != NULL; o = o->next)
10847
  for (o = obfd->sections; o != NULL; o = o->next)
10403
    {
10848
    {
10404
      struct bfd_elf_section_data *esdo = elf_section_data (o);
10849
      struct bfd_elf_section_data *esdo = elf_section_data (o);
Line 10424... Line 10869...
10424
  bfd_size_type max_contents_size;
10869
  bfd_size_type max_contents_size;
10425
  bfd_size_type max_external_reloc_size;
10870
  bfd_size_type max_external_reloc_size;
10426
  bfd_size_type max_internal_reloc_count;
10871
  bfd_size_type max_internal_reloc_count;
10427
  bfd_size_type max_sym_count;
10872
  bfd_size_type max_sym_count;
10428
  bfd_size_type max_sym_shndx_count;
10873
  bfd_size_type max_sym_shndx_count;
10429
  file_ptr off;
-
 
10430
  Elf_Internal_Sym elfsym;
10874
  Elf_Internal_Sym elfsym;
10431
  unsigned int i;
10875
  unsigned int i;
10432
  Elf_Internal_Shdr *symtab_hdr;
10876
  Elf_Internal_Shdr *symtab_hdr;
10433
  Elf_Internal_Shdr *symtab_shndx_hdr;
10877
  Elf_Internal_Shdr *symtab_shndx_hdr;
10434
  Elf_Internal_Shdr *symstrtab_hdr;
-
 
10435
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
10878
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
10436
  struct elf_outext_info eoinfo;
10879
  struct elf_outext_info eoinfo;
10437
  bfd_boolean merged;
10880
  bfd_boolean merged;
10438
  size_t relativecount = 0;
10881
  size_t relativecount = 0;
10439
  asection *reldyn = 0;
10882
  asection *reldyn = 0;
Line 10443... Line 10886...
10443
  const char *std_attrs_section;
10886
  const char *std_attrs_section;
Line 10444... Line 10887...
10444
 
10887
 
10445
  if (! is_elf_hash_table (info->hash))
10888
  if (! is_elf_hash_table (info->hash))
Line 10446... Line 10889...
10446
    return FALSE;
10889
    return FALSE;
10447
 
10890
 
Line 10448... Line 10891...
10448
  if (info->shared)
10891
  if (bfd_link_pic (info))
10449
    abfd->flags |= DYNAMIC;
10892
    abfd->flags |= DYNAMIC;
Line 10450... Line 10893...
10450
 
10893
 
10451
  dynamic = elf_hash_table (info)->dynamic_sections_created;
10894
  dynamic = elf_hash_table (info)->dynamic_sections_created;
Line 10452... Line 10895...
10452
  dynobj = elf_hash_table (info)->dynobj;
10895
  dynobj = elf_hash_table (info)->dynobj;
10453
 
10896
 
10454
  emit_relocs = (info->relocatable
10897
  emit_relocs = (bfd_link_relocatable (info)
10455
		 || info->emitrelocations);
10898
		 || info->emitrelocations);
10456
 
10899
 
Line 10457... Line 10900...
10457
  flinfo.info = info;
10900
  flinfo.info = info;
10458
  flinfo.output_bfd = abfd;
10901
  flinfo.output_bfd = abfd;
10459
  flinfo.symstrtab = _bfd_elf_stringtab_init ();
-
 
10460
  if (flinfo.symstrtab == NULL)
10902
  flinfo.symstrtab = _bfd_elf_strtab_init ();
10461
    return FALSE;
10903
  if (flinfo.symstrtab == NULL)
10462
 
10904
    return FALSE;
10463
  if (! dynamic)
10905
 
10464
    {
10906
  if (! dynamic)
10465
      flinfo.dynsym_sec = NULL;
-
 
10466
      flinfo.hash_sec = NULL;
10907
    {
10467
      flinfo.symver_sec = NULL;
10908
      flinfo.hash_sec = NULL;
10468
    }
10909
      flinfo.symver_sec = NULL;
10469
  else
10910
    }
10470
    {
10911
  else
Line 10481... Line 10922...
10481
  flinfo.external_syms = NULL;
10922
  flinfo.external_syms = NULL;
10482
  flinfo.locsym_shndx = NULL;
10923
  flinfo.locsym_shndx = NULL;
10483
  flinfo.internal_syms = NULL;
10924
  flinfo.internal_syms = NULL;
10484
  flinfo.indices = NULL;
10925
  flinfo.indices = NULL;
10485
  flinfo.sections = NULL;
10926
  flinfo.sections = NULL;
10486
  flinfo.symbuf = NULL;
-
 
10487
  flinfo.symshndxbuf = NULL;
10927
  flinfo.symshndxbuf = NULL;
10488
  flinfo.symbuf_count = 0;
-
 
10489
  flinfo.shndxbuf_size = 0;
-
 
10490
  flinfo.filesym_count = 0;
10928
  flinfo.filesym_count = 0;
Line 10491... Line 10929...
10491
 
10929
 
10492
  /* The object attributes have been merged.  Remove the input
10930
  /* The object attributes have been merged.  Remove the input
10493
     sections from the link, and set the contents of the output
10931
     sections from the link, and set the contents of the output
Line 10565... Line 11003...
10565
		  || esdo->this_hdr.sh_type == SHT_RELA)
11003
		  || esdo->this_hdr.sh_type == SHT_RELA)
10566
		/* Some backends use reloc_count in relocation sections
11004
		/* Some backends use reloc_count in relocation sections
10567
		   to count particular types of relocs.  Of course,
11005
		   to count particular types of relocs.  Of course,
10568
		   reloc sections themselves can't have relocations.  */
11006
		   reloc sections themselves can't have relocations.  */
10569
		reloc_count = 0;
11007
		reloc_count = 0;
10570
	      else if (info->relocatable || info->emitrelocations)
11008
	      else if (emit_relocs)
10571
		reloc_count = sec->reloc_count;
11009
		reloc_count = sec->reloc_count;
10572
	      else if (bed->elf_backend_count_relocs)
11010
	      else if (bed->elf_backend_count_relocs)
10573
		reloc_count = (*bed->elf_backend_count_relocs) (info, sec);
11011
		reloc_count = (*bed->elf_backend_count_relocs) (info, sec);
Line 10574... Line 11012...
10574
 
11012
 
Line 10592... Line 11030...
10592
 
11030
 
10593
		  if (sym_count > max_sym_count)
11031
		  if (sym_count > max_sym_count)
Line 10594... Line 11032...
10594
		    max_sym_count = sym_count;
11032
		    max_sym_count = sym_count;
10595
 
11033
 
10596
		  if (sym_count > max_sym_shndx_count
11034
		  if (sym_count > max_sym_shndx_count
Line 10597... Line 11035...
10597
		      && elf_symtab_shndx (sec->owner) != 0)
11035
		      && elf_symtab_shndx_list (sec->owner) != NULL)
10598
		    max_sym_shndx_count = sym_count;
11036
		    max_sym_shndx_count = sym_count;
10599
 
11037
 
Line 10617... Line 11055...
10617
	  if (reloc_count == 0)
11055
	  if (reloc_count == 0)
10618
	    continue;
11056
	    continue;
Line 10619... Line 11057...
10619
 
11057
 
Line 10620... Line 11058...
10620
	  o->reloc_count += reloc_count;
11058
	  o->reloc_count += reloc_count;
10621
 
-
 
10622
	  if (p->type == bfd_indirect_link_order
11059
 
10623
	      && (info->relocatable || info->emitrelocations))
11060
	  if (p->type == bfd_indirect_link_order && emit_relocs)
10624
	    {
11061
	    {
10625
	      if (esdi->rel.hdr)
11062
	      if (esdi->rel.hdr)
10626
		esdo->rel.count += NUM_SHDR_ENTRIES (esdi->rel.hdr);
11063
		esdo->rel.count += NUM_SHDR_ENTRIES (esdi->rel.hdr);
Line 10653... Line 11090...
10653
      if ((o->flags & SEC_ALLOC) == 0
11090
      if ((o->flags & SEC_ALLOC) == 0
10654
	  && ! o->user_set_vma)
11091
	  && ! o->user_set_vma)
10655
	o->vma = 0;
11092
	o->vma = 0;
10656
    }
11093
    }
Line 10657... Line 11094...
10657
 
11094
 
10658
  if (! info->relocatable && merged)
11095
  if (! bfd_link_relocatable (info) && merged)
10659
    elf_link_hash_traverse (elf_hash_table (info),
11096
    elf_link_hash_traverse (elf_hash_table (info),
Line 10660... Line 11097...
10660
			    _bfd_elf_link_sec_merge_syms, abfd);
11097
			    _bfd_elf_link_sec_merge_syms, abfd);
10661
 
11098
 
10662
  /* Figure out the file positions for everything but the symbol table
11099
  /* Figure out the file positions for everything but the symbol table
10663
     and the relocs.  We set symcount to force assign_section_numbers
11100
     and the relocs.  We set symcount to force assign_section_numbers
10664
     to create a symbol table.  */
11101
     to create a symbol table.  */
10665
  bfd_get_symcount (abfd) = info->strip == strip_all ? 0 : 1;
11102
  bfd_get_symcount (abfd) = info->strip != strip_all || emit_relocs;
10666
  BFD_ASSERT (! abfd->output_has_begun);
11103
  BFD_ASSERT (! abfd->output_has_begun);
Line 10667... Line 11104...
10667
  if (! _bfd_elf_compute_section_file_positions (abfd, info))
11104
  if (! _bfd_elf_compute_section_file_positions (abfd, info))
Line 10684... Line 11121...
10684
 
11121
 
10685
      /* Now, reset REL_COUNT and REL_COUNT2 so that we can use them
11122
      /* Now, reset REL_COUNT and REL_COUNT2 so that we can use them
10686
	 to count upwards while actually outputting the relocations.  */
11123
	 to count upwards while actually outputting the relocations.  */
10687
      esdo->rel.count = 0;
11124
      esdo->rel.count = 0;
10688
      esdo->rela.count = 0;
-
 
Line -... Line 11125...
-
 
11125
      esdo->rela.count = 0;
-
 
11126
 
-
 
11127
      if (esdo->this_hdr.sh_offset == (file_ptr) -1)
-
 
11128
	{
10689
    }
11129
	  /* Cache the section contents so that they can be compressed
-
 
11130
	     later.  Use bfd_malloc since it will be freed by
-
 
11131
	     bfd_compress_section_contents.  */
-
 
11132
	  unsigned char *contents = esdo->this_hdr.contents;
-
 
11133
	  if ((o->flags & SEC_ELF_COMPRESS) == 0 || contents != NULL)
-
 
11134
	    abort ();
-
 
11135
	  contents
-
 
11136
	    = (unsigned char *) bfd_malloc (esdo->this_hdr.sh_size);
-
 
11137
	  if (contents == NULL)
-
 
11138
	    goto error_return;
-
 
11139
	  esdo->this_hdr.contents = contents;
Line 10690... Line 11140...
10690
 
11140
	}
10691
  _bfd_elf_assign_file_positions_for_relocs (abfd);
11141
    }
10692
 
11142
 
10693
  /* We have now assigned file positions for all the sections except
11143
  /* We have now assigned file positions for all the sections except
10694
     .symtab and .strtab.  We start the .symtab section at the current
11144
     .symtab, .strtab, and non-loaded reloc sections.  We start the
10695
     file position, and write directly to it.  We build the .strtab
11145
     .symtab section at the current file position, and write directly
10696
     section in memory.  */
11146
     to it.  We build the .strtab section in memory.  */
10697
  bfd_get_symcount (abfd) = 0;
11147
  bfd_get_symcount (abfd) = 0;
10698
  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
11148
  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
Line 10703... Line 11153...
10703
  /* sh_link is set in assign_section_numbers.  */
11153
  /* sh_link is set in assign_section_numbers.  */
10704
  /* sh_info is set below.  */
11154
  /* sh_info is set below.  */
10705
  /* sh_offset is set just below.  */
11155
  /* sh_offset is set just below.  */
10706
  symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align;
11156
  symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align;
Line -... Line 11157...
-
 
11157
 
-
 
11158
  if (max_sym_count < 20)
-
 
11159
    max_sym_count = 20;
-
 
11160
  elf_hash_table (info)->strtabsize = max_sym_count;
-
 
11161
  amt = max_sym_count * sizeof (struct elf_sym_strtab);
-
 
11162
  elf_hash_table (info)->strtab
-
 
11163
    = (struct elf_sym_strtab *) bfd_malloc (amt);
-
 
11164
  if (elf_hash_table (info)->strtab == NULL)
-
 
11165
    goto error_return;
-
 
11166
  /* The real buffer will be allocated in elf_link_swap_symbols_out.  */
-
 
11167
  flinfo.symshndxbuf
-
 
11168
    = (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF)
-
 
11169
       ? (Elf_External_Sym_Shndx *) -1 : NULL);
-
 
11170
 
-
 
11171
  if (info->strip != strip_all || emit_relocs)
10707
 
11172
    {
-
 
11173
      file_ptr off = elf_next_file_pos (abfd);
10708
  off = elf_next_file_pos (abfd);
11174
 
Line 10709... Line 11175...
10709
  off = _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE);
11175
      _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE);
10710
 
11176
 
10711
  /* Note that at this point elf_next_file_pos (abfd) is
11177
      /* Note that at this point elf_next_file_pos (abfd) is
Line 10712... Line -...
10712
     incorrect.  We do not yet know the size of the .symtab section.
-
 
10713
     We correct next_file_pos below, after we do know the size.  */
-
 
10714
 
-
 
10715
  /* Allocate a buffer to hold swapped out symbols.  This is to avoid
-
 
10716
     continuously seeking to the right position in the file.  */
-
 
10717
  if (! info->keep_memory || max_sym_count < 20)
-
 
10718
    flinfo.symbuf_size = 20;
-
 
10719
  else
-
 
10720
    flinfo.symbuf_size = max_sym_count;
-
 
10721
  amt = flinfo.symbuf_size;
-
 
10722
  amt *= bed->s->sizeof_sym;
-
 
10723
  flinfo.symbuf = (bfd_byte *) bfd_malloc (amt);
-
 
10724
  if (flinfo.symbuf == NULL)
-
 
10725
    goto error_return;
-
 
10726
  if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF))
-
 
10727
    {
-
 
10728
      /* Wild guess at number of output symbols.  realloc'd as needed.  */
-
 
10729
      amt = 2 * max_sym_count + elf_numsections (abfd) + 1000;
-
 
10730
      flinfo.shndxbuf_size = amt;
-
 
10731
      amt *= sizeof (Elf_External_Sym_Shndx);
-
 
10732
      flinfo.symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt);
-
 
10733
      if (flinfo.symshndxbuf == NULL)
-
 
10734
	goto error_return;
11178
	 incorrect.  We do not yet know the size of the .symtab section.
10735
    }
11179
	 We correct next_file_pos below, after we do know the size.  */
10736
 
-
 
10737
  /* Start writing out the symbol table.  The first symbol is always a
-
 
10738
     dummy symbol.  */
-
 
10739
  if (info->strip != strip_all
11180
 
10740
      || emit_relocs)
11181
      /* Start writing out the symbol table.  The first symbol is always a
10741
    {
11182
	 dummy symbol.  */
10742
      elfsym.st_value = 0;
11183
      elfsym.st_value = 0;
10743
      elfsym.st_size = 0;
11184
      elfsym.st_size = 0;
10744
      elfsym.st_info = 0;
11185
      elfsym.st_info = 0;
10745
      elfsym.st_other = 0;
11186
      elfsym.st_other = 0;
10746
      elfsym.st_shndx = SHN_UNDEF;
11187
      elfsym.st_shndx = SHN_UNDEF;
10747
      elfsym.st_target_internal = 0;
11188
      elfsym.st_target_internal = 0;
10748
      if (elf_link_output_sym (&flinfo, NULL, &elfsym, bfd_und_section_ptr,
-
 
Line 10749... Line 11189...
10749
			       NULL) != 1)
11189
      if (elf_link_output_symstrtab (&flinfo, NULL, &elfsym,
10750
	goto error_return;
11190
				     bfd_und_section_ptr, NULL) != 1)
10751
    }
11191
	goto error_return;
10752
 
11192
 
10753
  /* Output a symbol for each section.  We output these even if we are
11193
      /* Output a symbol for each section.  We output these even if we are
10754
     discarding local symbols, since they are used for relocs.  These
-
 
10755
     symbols have no names.  We store the index of each one in the
-
 
10756
     index field of the section, so that we can find it again when
11194
	 discarding local symbols, since they are used for relocs.  These
10757
     outputting relocs.  */
11195
	 symbols have no names.  We store the index of each one in the
10758
  if (info->strip != strip_all
11196
	 index field of the section, so that we can find it again when
10759
      || emit_relocs)
11197
	 outputting relocs.  */
10760
    {
11198
 
10761
      elfsym.st_size = 0;
11199
      elfsym.st_size = 0;
Line 10768... Line 11206...
10768
	  o = bfd_section_from_elf_index (abfd, i);
11206
	  o = bfd_section_from_elf_index (abfd, i);
10769
	  if (o != NULL)
11207
	  if (o != NULL)
10770
	    {
11208
	    {
10771
	      o->target_index = bfd_get_symcount (abfd);
11209
	      o->target_index = bfd_get_symcount (abfd);
10772
	      elfsym.st_shndx = i;
11210
	      elfsym.st_shndx = i;
10773
	      if (!info->relocatable)
11211
	      if (!bfd_link_relocatable (info))
10774
		elfsym.st_value = o->vma;
11212
		elfsym.st_value = o->vma;
10775
	      if (elf_link_output_sym (&flinfo, NULL, &elfsym, o, NULL) != 1)
11213
	      if (elf_link_output_symstrtab (&flinfo, NULL, &elfsym, o,
-
 
11214
					     NULL) != 1)
10776
		goto error_return;
11215
		goto error_return;
10777
	    }
11216
	    }
10778
	}
11217
	}
10779
    }
11218
    }
Line 10869... Line 11308...
10869
    {
11308
    {
10870
      if (!elf_fixup_link_order (abfd, o))
11309
      if (!elf_fixup_link_order (abfd, o))
10871
	return FALSE;
11310
	return FALSE;
10872
    }
11311
    }
Line -... Line 11312...
-
 
11312
 
-
 
11313
  if (!_bfd_elf_fixup_eh_frame_hdr (info))
-
 
11314
    return FALSE;
10873
 
11315
 
10874
  /* Since ELF permits relocations to be against local symbols, we
11316
  /* Since ELF permits relocations to be against local symbols, we
10875
     must have the local symbols available when we do the relocations.
11317
     must have the local symbols available when we do the relocations.
10876
     Since we would rather only read the local symbols once, and we
11318
     Since we would rather only read the local symbols once, and we
10877
     would rather not keep them in memory, we handle all the
11319
     would rather not keep them in memory, we handle all the
Line 10889... Line 11331...
10889
     it.  Fortunately, it only happens when performing a relocatable
11331
     it.  Fortunately, it only happens when performing a relocatable
10890
     link, which is not the common case.  FIXME: If keep_memory is set
11332
     link, which is not the common case.  FIXME: If keep_memory is set
10891
     we could write the relocs out and then read them again; I don't
11333
     we could write the relocs out and then read them again; I don't
10892
     know how bad the memory loss will be.  */
11334
     know how bad the memory loss will be.  */
Line 10893... Line 11335...
10893
 
11335
 
10894
  for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
11336
  for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
10895
    sub->output_has_begun = FALSE;
11337
    sub->output_has_begun = FALSE;
10896
  for (o = abfd->sections; o != NULL; o = o->next)
11338
  for (o = abfd->sections; o != NULL; o = o->next)
10897
    {
11339
    {
10898
      for (p = o->map_head.link_order; p != NULL; p = p->next)
11340
      for (p = o->map_head.link_order; p != NULL; p = p->next)
Line 10951... Line 11393...
10951
    }
11393
    }
Line 10952... Line 11394...
10952
 
11394
 
10953
  /* Free symbol buffer if needed.  */
11395
  /* Free symbol buffer if needed.  */
10954
  if (!info->reduce_memory_overheads)
11396
  if (!info->reduce_memory_overheads)
10955
    {
11397
    {
10956
      for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
11398
      for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
10957
	if (bfd_get_flavour (sub) == bfd_target_elf_flavour
11399
	if (bfd_get_flavour (sub) == bfd_target_elf_flavour
10958
	    && elf_tdata (sub)->symbuf)
11400
	    && elf_tdata (sub)->symbuf)
10959
	  {
11401
	  {
10960
	    free (elf_tdata (sub)->symbuf);
11402
	    free (elf_tdata (sub)->symbuf);
10961
	    elf_tdata (sub)->symbuf = NULL;
11403
	    elf_tdata (sub)->symbuf = NULL;
10962
	  }
11404
	  }
Line 10963... Line -...
10963
    }
-
 
10964
 
-
 
10965
  /* Output a FILE symbol so that following locals are not associated
-
 
10966
     with the wrong input file.  */
-
 
10967
  memset (&elfsym, 0, sizeof (elfsym));
-
 
10968
  elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
-
 
10969
  elfsym.st_shndx = SHN_ABS;
-
 
10970
 
-
 
10971
  if (flinfo.filesym_count > 1
-
 
10972
      && !elf_link_output_sym (&flinfo, NULL, &elfsym,
-
 
10973
			       bfd_und_section_ptr, NULL))
-
 
10974
    return FALSE;
11405
    }
10975
 
11406
 
10976
  /* Output any global symbols that got converted to local in a
11407
  /* Output any global symbols that got converted to local in a
10977
     version script or due to symbol visibility.  We do this in a
11408
     version script or due to symbol visibility.  We do this in a
10978
     separate step since ELF requires all local symbols to appear
11409
     separate step since ELF requires all local symbols to appear
10979
     prior to any global symbols.  FIXME: We should only do this if
11410
     prior to any global symbols.  FIXME: We should only do this if
10980
     some global symbols were, in fact, converted to become local.
11411
     some global symbols were, in fact, converted to become local.
10981
     FIXME: Will this work correctly with the Irix 5 linker?  */
11412
     FIXME: Will this work correctly with the Irix 5 linker?  */
10982
  eoinfo.failed = FALSE;
11413
  eoinfo.failed = FALSE;
10983
  eoinfo.flinfo = &flinfo;
-
 
10984
  eoinfo.localsyms = TRUE;
11414
  eoinfo.flinfo = &flinfo;
10985
  eoinfo.need_second_pass = FALSE;
11415
  eoinfo.localsyms = TRUE;
10986
  eoinfo.second_pass = FALSE;
11416
  eoinfo.file_sym_done = FALSE;
10987
  bfd_hash_traverse (&info->hash->table, elf_link_output_extsym, &eoinfo);
11417
  bfd_hash_traverse (&info->hash->table, elf_link_output_extsym, &eoinfo);
Line 10988... Line -...
10988
  if (eoinfo.failed)
-
 
10989
    return FALSE;
-
 
10990
 
-
 
10991
  if (flinfo.filesym_count == 1
-
 
10992
      && !elf_link_output_sym (&flinfo, NULL, &elfsym,
-
 
10993
			       bfd_und_section_ptr, NULL))
-
 
10994
    return FALSE;
-
 
10995
 
-
 
10996
  if (eoinfo.need_second_pass)
-
 
10997
    {
-
 
10998
      eoinfo.second_pass = TRUE;
-
 
10999
      bfd_hash_traverse (&info->hash->table, elf_link_output_extsym, &eoinfo);
-
 
11000
      if (eoinfo.failed)
-
 
11001
	return FALSE;
11418
  if (eoinfo.failed)
11002
    }
11419
    return FALSE;
11003
 
11420
 
-
 
11421
  /* If backend needs to output some local symbols not present in the hash
11004
  /* If backend needs to output some local symbols not present in the hash
11422
     table, do it now.  */
11005
     table, do it now.  */
11423
  if (bed->elf_backend_output_arch_local_syms
11006
  if (bed->elf_backend_output_arch_local_syms)
11424
      && (info->strip != strip_all || emit_relocs))
11007
    {
11425
    {
Line 11008... Line 11426...
11008
      typedef int (*out_sym_func)
11426
      typedef int (*out_sym_func)
-
 
11427
	(void *, const char *, Elf_Internal_Sym *, asection *,
11009
	(void *, const char *, Elf_Internal_Sym *, asection *,
11428
	 struct elf_link_hash_entry *);
11010
	 struct elf_link_hash_entry *);
11429
 
11011
 
11430
      if (! ((*bed->elf_backend_output_arch_local_syms)
Line 11012... Line 11431...
11012
      if (! ((*bed->elf_backend_output_arch_local_syms)
11431
	     (abfd, info, &flinfo,
11013
	     (abfd, info, &flinfo, (out_sym_func) elf_link_output_sym)))
11432
	      (out_sym_func) elf_link_output_symstrtab)))
Line 11021... Line 11440...
11021
 
11440
 
11022
  /* The sh_info field records the index of the first non local symbol.  */
11441
  /* The sh_info field records the index of the first non local symbol.  */
Line 11023... Line 11442...
11023
  symtab_hdr->sh_info = bfd_get_symcount (abfd);
11442
  symtab_hdr->sh_info = bfd_get_symcount (abfd);
11024
 
11443
 
11025
  if (dynamic
11444
  if (dynamic
-
 
11445
      && elf_hash_table (info)->dynsym != NULL
11026
      && flinfo.dynsym_sec != NULL
11446
      && (elf_hash_table (info)->dynsym->output_section
11027
      && flinfo.dynsym_sec->output_section != bfd_abs_section_ptr)
11447
	  != bfd_abs_section_ptr))
11028
    {
11448
    {
11029
      Elf_Internal_Sym sym;
11449
      Elf_Internal_Sym sym;
Line 11030... Line 11450...
11030
      bfd_byte *dynsym = flinfo.dynsym_sec->contents;
11450
      bfd_byte *dynsym = elf_hash_table (info)->dynsym->contents;
-
 
11451
      long last_local = 0;
11031
      long last_local = 0;
11452
 
11032
 
11453
      /* Write out the section symbols for the output sections.  */
11033
      /* Write out the section symbols for the output sections.  */
11454
      if (bfd_link_pic (info)
Line 11034... Line 11455...
11034
      if (info->shared || elf_hash_table (info)->is_relocatable_executable)
11455
	  || elf_hash_table (info)->is_relocatable_executable)
11035
	{
11456
	{
Line 11097... Line 11518...
11097
	      dest = dynsym + e->dynindx * bed->s->sizeof_sym;
11518
	      dest = dynsym + e->dynindx * bed->s->sizeof_sym;
11098
	      bed->s->swap_symbol_out (abfd, &sym, dest, 0);
11519
	      bed->s->swap_symbol_out (abfd, &sym, dest, 0);
11099
	    }
11520
	    }
11100
	}
11521
	}
Line 11101... Line 11522...
11101
 
11522
 
11102
      elf_section_data (flinfo.dynsym_sec->output_section)->this_hdr.sh_info =
11523
      elf_section_data (elf_hash_table (info)->dynsym->output_section)->this_hdr.sh_info =
11103
	last_local + 1;
11524
	last_local + 1;
Line 11104... Line 11525...
11104
    }
11525
    }
11105
 
11526
 
Line 11111... Line 11532...
11111
  if (eoinfo.failed)
11532
  if (eoinfo.failed)
11112
    return FALSE;
11533
    return FALSE;
Line 11113... Line 11534...
11113
 
11534
 
11114
  /* If backend needs to output some symbols not present in the hash
11535
  /* If backend needs to output some symbols not present in the hash
11115
     table, do it now.  */
11536
     table, do it now.  */
-
 
11537
  if (bed->elf_backend_output_arch_syms
11116
  if (bed->elf_backend_output_arch_syms)
11538
      && (info->strip != strip_all || emit_relocs))
11117
    {
11539
    {
11118
      typedef int (*out_sym_func)
11540
      typedef int (*out_sym_func)
11119
	(void *, const char *, Elf_Internal_Sym *, asection *,
11541
	(void *, const char *, Elf_Internal_Sym *, asection *,
Line 11120... Line 11542...
11120
	 struct elf_link_hash_entry *);
11542
	 struct elf_link_hash_entry *);
-
 
11543
 
11121
 
11544
      if (! ((*bed->elf_backend_output_arch_syms)
11122
      if (! ((*bed->elf_backend_output_arch_syms)
11545
	     (abfd, info, &flinfo,
11123
	     (abfd, info, &flinfo, (out_sym_func) elf_link_output_sym)))
11546
	      (out_sym_func) elf_link_output_symstrtab)))
Line 11124... Line 11547...
11124
	return FALSE;
11547
	return FALSE;
-
 
11548
    }
-
 
11549
 
-
 
11550
  /* Finalize the .strtab section.  */
11125
    }
11551
  _bfd_elf_strtab_finalize (flinfo.symstrtab);
11126
 
11552
 
Line 11127... Line 11553...
11127
  /* Flush all symbols to the file.  */
11553
  /* Swap out the .strtab section. */
-
 
11554
  if (!elf_link_swap_symbols_out (&flinfo))
-
 
11555
    return FALSE;
-
 
11556
 
-
 
11557
  /* Now we know the size of the symtab section.  */
11128
  if (! elf_link_flush_output_syms (&flinfo, bed))
11558
  if (bfd_get_symcount (abfd) > 0)
-
 
11559
    {
Line 11129... Line 11560...
11129
    return FALSE;
11560
      /* Finish up and write out the symbol string table (.strtab)
11130
 
11561
	 section.  */
11131
  /* Now we know the size of the symtab section.  */
11562
      Elf_Internal_Shdr *symstrtab_hdr;
11132
  off += symtab_hdr->sh_size;
11563
      file_ptr off = symtab_hdr->sh_offset + symtab_hdr->sh_size;
11133
 
11564
 
11134
  symtab_shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
11565
      symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr;
11135
  if (symtab_shndx_hdr->sh_name != 0)
11566
      if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0)
Line 11146... Line 11577...
11146
      if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
11577
	  if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
11147
	  || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
11578
	      || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
11148
	return FALSE;
11579
	    return FALSE;
11149
    }
11580
	}
Line 11150... Line -...
11150
 
-
 
11151
 
-
 
11152
  /* Finish up and write out the symbol string table (.strtab)
-
 
11153
     section.  */
11581
 
11154
  symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
11582
      symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
11155
  /* sh_name was set in prep_headers.  */
11583
      /* sh_name was set in prep_headers.  */
11156
  symstrtab_hdr->sh_type = SHT_STRTAB;
11584
      symstrtab_hdr->sh_type = SHT_STRTAB;
11157
  symstrtab_hdr->sh_flags = 0;
11585
      symstrtab_hdr->sh_flags = 0;
11158
  symstrtab_hdr->sh_addr = 0;
11586
      symstrtab_hdr->sh_addr = 0;
11159
  symstrtab_hdr->sh_size = _bfd_stringtab_size (flinfo.symstrtab);
11587
      symstrtab_hdr->sh_size = _bfd_elf_strtab_size (flinfo.symstrtab);
11160
  symstrtab_hdr->sh_entsize = 0;
11588
      symstrtab_hdr->sh_entsize = 0;
11161
  symstrtab_hdr->sh_link = 0;
11589
      symstrtab_hdr->sh_link = 0;
11162
  symstrtab_hdr->sh_info = 0;
11590
      symstrtab_hdr->sh_info = 0;
11163
  /* sh_offset is set just below.  */
11591
      /* sh_offset is set just below.  */
Line 11164... Line 11592...
11164
  symstrtab_hdr->sh_addralign = 1;
11592
      symstrtab_hdr->sh_addralign = 1;
-
 
11593
 
11165
 
11594
      off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr,
Line 11166... Line -...
11166
  off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, off, TRUE);
-
 
11167
  elf_next_file_pos (abfd) = off;
-
 
11168
 
11595
						       off, TRUE);
11169
  if (bfd_get_symcount (abfd) > 0)
11596
      elf_next_file_pos (abfd) = off;
11170
    {
11597
 
11171
      if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0
11598
      if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0
Line 11172... Line 11599...
11172
	  || ! _bfd_stringtab_emit (abfd, flinfo.symstrtab))
11599
	  || ! _bfd_elf_strtab_emit (abfd, flinfo.symstrtab))
11173
	return FALSE;
11600
	return FALSE;
11174
    }
11601
    }
11175
 
11602
 
-
 
11603
  /* Adjust the relocs to have the correct symbol indices.  */
11176
  /* Adjust the relocs to have the correct symbol indices.  */
11604
  for (o = abfd->sections; o != NULL; o = o->next)
11177
  for (o = abfd->sections; o != NULL; o = o->next)
11605
    {
Line -... Line 11606...
-
 
11606
      struct bfd_elf_section_data *esdo = elf_section_data (o);
11178
    {
11607
      bfd_boolean sort;
11179
      struct bfd_elf_section_data *esdo = elf_section_data (o);
11608
      if ((o->flags & SEC_RELOC) == 0)
-
 
11609
	continue;
11180
      if ((o->flags & SEC_RELOC) == 0)
11610
 
11181
	continue;
11611
      sort = bed->sort_relocs_p == NULL || (*bed->sort_relocs_p) (o);
-
 
11612
      if (esdo->rel.hdr != NULL
Line 11182... Line 11613...
11182
 
11613
	  && !elf_link_adjust_relocs (abfd, &esdo->rel, sort))
11183
      if (esdo->rel.hdr != NULL)
11614
	return FALSE;
11184
	elf_link_adjust_relocs (abfd, &esdo->rel);
11615
      if (esdo->rela.hdr != NULL
11185
      if (esdo->rela.hdr != NULL)
11616
	  && !elf_link_adjust_relocs (abfd, &esdo->rela, sort))
Line 11372... Line 11803...
11372
    {
11803
    {
11373
      if (! (*bed->elf_backend_finish_dynamic_sections) (abfd, info))
11804
      if (! (*bed->elf_backend_finish_dynamic_sections) (abfd, info))
11374
	goto error_return;
11805
	goto error_return;
Line 11375... Line 11806...
11375
 
11806
 
11376
      /* Check for DT_TEXTREL (late, in case the backend removes it).  */
11807
      /* Check for DT_TEXTREL (late, in case the backend removes it).  */
11377
      if (((info->warn_shared_textrel && info->shared)
11808
      if (((info->warn_shared_textrel && bfd_link_pic (info))
11378
	   || info->error_textrel)
11809
	   || info->error_textrel)
11379
	  && (o = bfd_get_linker_section (dynobj, ".dynamic")) != NULL)
11810
	  && (o = bfd_get_linker_section (dynobj, ".dynamic")) != NULL)
11380
	{
11811
	{
Line 11428... Line 11859...
11428
	    }
11859
	    }
11429
	  else
11860
	  else
11430
	    {
11861
	    {
11431
	      /* The contents of the .dynstr section are actually in a
11862
	      /* The contents of the .dynstr section are actually in a
11432
		 stringtab.  */
11863
		 stringtab.  */
-
 
11864
	      file_ptr off;
-
 
11865
 
11433
	      off = elf_section_data (o->output_section)->this_hdr.sh_offset;
11866
	      off = elf_section_data (o->output_section)->this_hdr.sh_offset;
11434
	      if (bfd_seek (abfd, off, SEEK_SET) != 0
11867
	      if (bfd_seek (abfd, off, SEEK_SET) != 0
11435
		  || ! _bfd_elf_strtab_emit (abfd,
11868
		  || ! _bfd_elf_strtab_emit (abfd,
11436
					     elf_hash_table (info)->dynstr))
11869
					     elf_hash_table (info)->dynstr))
11437
		goto error_return;
11870
		goto error_return;
11438
	    }
11871
	    }
11439
	}
11872
	}
11440
    }
11873
    }
Line 11441... Line 11874...
11441
 
11874
 
11442
  if (info->relocatable)
11875
  if (bfd_link_relocatable (info))
11443
    {
11876
    {
Line 11444... Line 11877...
11444
      bfd_boolean failed = FALSE;
11877
      bfd_boolean failed = FALSE;
11445
 
11878
 
Line 11621... Line 12054...
11621
		       struct bfd_link_info *info ATTRIBUTE_UNUSED,
12054
		       struct bfd_link_info *info ATTRIBUTE_UNUSED,
11622
		       Elf_Internal_Rela *rel ATTRIBUTE_UNUSED,
12055
		       Elf_Internal_Rela *rel ATTRIBUTE_UNUSED,
11623
		       struct elf_link_hash_entry *h,
12056
		       struct elf_link_hash_entry *h,
11624
		       Elf_Internal_Sym *sym)
12057
		       Elf_Internal_Sym *sym)
11625
{
12058
{
11626
  const char *sec_name;
-
 
11627
 
-
 
11628
  if (h != NULL)
12059
  if (h != NULL)
11629
    {
12060
    {
11630
      switch (h->root.type)
12061
      switch (h->root.type)
11631
	{
12062
	{
11632
	case bfd_link_hash_defined:
12063
	case bfd_link_hash_defined:
Line 11634... Line 12065...
11634
	  return h->root.u.def.section;
12065
	  return h->root.u.def.section;
Line 11635... Line 12066...
11635
 
12066
 
11636
	case bfd_link_hash_common:
12067
	case bfd_link_hash_common:
Line 11637... Line -...
11637
	  return h->root.u.c.p->section;
-
 
11638
 
-
 
11639
	case bfd_link_hash_undefined:
-
 
11640
	case bfd_link_hash_undefweak:
-
 
11641
	  /* To work around a glibc bug, keep all XXX input sections
-
 
11642
	     when there is an as yet undefined reference to __start_XXX
-
 
11643
	     or __stop_XXX symbols.  The linker will later define such
-
 
11644
	     symbols for orphan input sections that have a name
-
 
11645
	     representable as a C identifier.  */
-
 
11646
	  if (strncmp (h->root.root.string, "__start_", 8) == 0)
-
 
11647
	    sec_name = h->root.root.string + 8;
-
 
11648
	  else if (strncmp (h->root.root.string, "__stop_", 7) == 0)
-
 
11649
	    sec_name = h->root.root.string + 7;
-
 
11650
	  else
-
 
11651
	    sec_name = NULL;
-
 
11652
 
-
 
11653
	  if (sec_name && *sec_name != '\0')
-
 
11654
	    {
-
 
11655
	      bfd *i;
-
 
11656
 
-
 
11657
	      for (i = info->input_bfds; i; i = i->link_next)
-
 
11658
		{
-
 
11659
		  sec = bfd_get_section_by_name (i, sec_name);
-
 
11660
		  if (sec)
-
 
11661
		    sec->flags |= SEC_KEEP;
-
 
11662
		}
-
 
11663
	    }
-
 
11664
	  break;
12068
	  return h->root.u.c.p->section;
11665
 
12069
 
11666
	default:
12070
	default:
11667
	  break;
12071
	  break;
11668
	}
12072
	}
Line 11678... Line 12082...
11678
   the relocation symbol, or NULL if no section contains it.  */
12082
   the relocation symbol, or NULL if no section contains it.  */
Line 11679... Line 12083...
11679
 
12083
 
11680
asection *
12084
asection *
11681
_bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
12085
_bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
11682
		       elf_gc_mark_hook_fn gc_mark_hook,
12086
		       elf_gc_mark_hook_fn gc_mark_hook,
-
 
12087
		       struct elf_reloc_cookie *cookie,
11683
		       struct elf_reloc_cookie *cookie)
12088
		       bfd_boolean *start_stop)
11684
{
12089
{
11685
  unsigned long r_symndx;
12090
  unsigned long r_symndx;
Line 11686... Line 12091...
11686
  struct elf_link_hash_entry *h;
12091
  struct elf_link_hash_entry *h;
Line 11691... Line 12096...
11691
 
12096
 
11692
  if (r_symndx >= cookie->locsymcount
12097
  if (r_symndx >= cookie->locsymcount
11693
      || ELF_ST_BIND (cookie->locsyms[r_symndx].st_info) != STB_LOCAL)
12098
      || ELF_ST_BIND (cookie->locsyms[r_symndx].st_info) != STB_LOCAL)
11694
    {
12099
    {
-
 
12100
      h = cookie->sym_hashes[r_symndx - cookie->extsymoff];
-
 
12101
      if (h == NULL)
-
 
12102
	{
-
 
12103
	  info->callbacks->einfo (_("%F%P: corrupt input: %B\n"),
-
 
12104
				  sec->owner);
-
 
12105
	  return NULL;
11695
      h = cookie->sym_hashes[r_symndx - cookie->extsymoff];
12106
	}
11696
      while (h->root.type == bfd_link_hash_indirect
12107
      while (h->root.type == bfd_link_hash_indirect
11697
	     || h->root.type == bfd_link_hash_warning)
12108
	     || h->root.type == bfd_link_hash_warning)
11698
	h = (struct elf_link_hash_entry *) h->root.u.i.link;
12109
	h = (struct elf_link_hash_entry *) h->root.u.i.link;
11699
      h->mark = 1;
12110
      h->mark = 1;
11700
      /* If this symbol is weak and there is a non-weak definition, we
12111
      /* If this symbol is weak and there is a non-weak definition, we
11701
	 keep the non-weak definition because many backends put
12112
	 keep the non-weak definition because many backends put
11702
	 dynamic reloc info on the non-weak definition for code
12113
	 dynamic reloc info on the non-weak definition for code
11703
	 handling copy relocs.  */
12114
	 handling copy relocs.  */
11704
      if (h->u.weakdef != NULL)
12115
      if (h->u.weakdef != NULL)
-
 
12116
	h->u.weakdef->mark = 1;
-
 
12117
 
-
 
12118
      if (start_stop != NULL
-
 
12119
	  && (h->root.type == bfd_link_hash_undefined
-
 
12120
	      || h->root.type == bfd_link_hash_undefweak))
-
 
12121
	{
-
 
12122
	  /* To work around a glibc bug, mark all XXX input sections
-
 
12123
	     when there is an as yet undefined reference to __start_XXX
-
 
12124
	     or __stop_XXX symbols.  The linker will later define such
-
 
12125
	     symbols for orphan input sections that have a name
-
 
12126
	     representable as a C identifier.  */
-
 
12127
	  const char *sec_name = NULL;
-
 
12128
	  if (strncmp (h->root.root.string, "__start_", 8) == 0)
-
 
12129
	    sec_name = h->root.root.string + 8;
-
 
12130
	  else if (strncmp (h->root.root.string, "__stop_", 7) == 0)
-
 
12131
	    sec_name = h->root.root.string + 7;
-
 
12132
 
-
 
12133
	  if (sec_name != NULL && *sec_name != '\0')
-
 
12134
	    {
-
 
12135
	      bfd *i;
-
 
12136
 
-
 
12137
	      for (i = info->input_bfds; i != NULL; i = i->link.next)
-
 
12138
		{
-
 
12139
		  asection *s = bfd_get_section_by_name (i, sec_name);
-
 
12140
		  if (s != NULL && !s->gc_mark)
-
 
12141
		    {
-
 
12142
		      *start_stop = TRUE;
-
 
12143
		      return s;
-
 
12144
		    }
-
 
12145
		}
-
 
12146
	    }
-
 
12147
	}
11705
	h->u.weakdef->mark = 1;
12148
 
11706
      return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);
12149
      return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);
Line 11707... Line 12150...
11707
    }
12150
    }
11708
 
12151
 
Line 11719... Line 12162...
11719
			asection *sec,
12162
			asection *sec,
11720
			elf_gc_mark_hook_fn gc_mark_hook,
12163
			elf_gc_mark_hook_fn gc_mark_hook,
11721
			struct elf_reloc_cookie *cookie)
12164
			struct elf_reloc_cookie *cookie)
11722
{
12165
{
11723
  asection *rsec;
12166
  asection *rsec;
-
 
12167
  bfd_boolean start_stop = FALSE;
Line 11724... Line 12168...
11724
 
12168
 
-
 
12169
  rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie, &start_stop);
-
 
12170
  while (rsec != NULL)
11725
  rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie);
12171
    {
11726
  if (rsec && !rsec->gc_mark)
12172
      if (!rsec->gc_mark)
11727
    {
12173
	{
11728
      if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour
12174
	  if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour
11729
	  || (rsec->owner->flags & DYNAMIC) != 0)
12175
	      || (rsec->owner->flags & DYNAMIC) != 0)
11730
	rsec->gc_mark = 1;
12176
	    rsec->gc_mark = 1;
11731
      else if (!_bfd_elf_gc_mark (info, rsec, gc_mark_hook))
12177
	  else if (!_bfd_elf_gc_mark (info, rsec, gc_mark_hook))
11732
	return FALSE;
12178
	    return FALSE;
-
 
12179
	}
-
 
12180
      if (!start_stop)
-
 
12181
	break;
-
 
12182
      rsec = bfd_get_next_section_by_name (rsec->owner, rsec);
11733
    }
12183
    }
11734
  return TRUE;
12184
  return TRUE;
Line 11735... Line 12185...
11735
}
12185
}
11736
 
12186
 
Line 11790... Line 12240...
11790
	    ret = FALSE;
12240
	    ret = FALSE;
11791
	  fini_reloc_cookie_for_section (&cookie, eh_frame);
12241
	  fini_reloc_cookie_for_section (&cookie, eh_frame);
11792
	}
12242
	}
11793
    }
12243
    }
Line -... Line 12244...
-
 
12244
 
-
 
12245
  eh_frame = elf_section_eh_frame_entry (sec);
-
 
12246
  if (ret && eh_frame && !eh_frame->gc_mark)
-
 
12247
    if (!_bfd_elf_gc_mark (info, eh_frame, gc_mark_hook))
-
 
12248
      ret = FALSE;
11794
 
12249
 
11795
  return ret;
12250
  return ret;
Line -... Line 12251...
-
 
12251
}
-
 
12252
 
-
 
12253
/* Scan and mark sections in a special or debug section group.  */
-
 
12254
 
-
 
12255
static void
-
 
12256
_bfd_elf_gc_mark_debug_special_section_group (asection *grp)
-
 
12257
{
-
 
12258
  /* Point to first section of section group.  */
-
 
12259
  asection *ssec;
-
 
12260
  /* Used to iterate the section group.  */
-
 
12261
  asection *msec;
-
 
12262
 
-
 
12263
  bfd_boolean is_special_grp = TRUE;
-
 
12264
  bfd_boolean is_debug_grp = TRUE;
-
 
12265
 
-
 
12266
  /* First scan to see if group contains any section other than debug
-
 
12267
     and special section.  */
-
 
12268
  ssec = msec = elf_next_in_group (grp);
-
 
12269
  do
-
 
12270
    {
-
 
12271
      if ((msec->flags & SEC_DEBUGGING) == 0)
-
 
12272
	is_debug_grp = FALSE;
-
 
12273
 
-
 
12274
      if ((msec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) != 0)
-
 
12275
	is_special_grp = FALSE;
-
 
12276
 
-
 
12277
      msec = elf_next_in_group (msec);
-
 
12278
    }
-
 
12279
  while (msec != ssec);
-
 
12280
 
-
 
12281
  /* If this is a pure debug section group or pure special section group,
-
 
12282
     keep all sections in this group.  */
-
 
12283
  if (is_debug_grp || is_special_grp)
-
 
12284
    {
-
 
12285
      do
-
 
12286
	{
-
 
12287
	  msec->gc_mark = 1;
-
 
12288
	  msec = elf_next_in_group (msec);
-
 
12289
	}
-
 
12290
      while (msec != ssec);
-
 
12291
    }
11796
}
12292
}
Line 11797... Line 12293...
11797
 
12293
 
11798
/* Keep debug and special sections.  */
12294
/* Keep debug and special sections.  */
11799
 
12295
 
11800
bfd_boolean
12296
bfd_boolean
11801
_bfd_elf_gc_mark_extra_sections (struct bfd_link_info *info,
12297
_bfd_elf_gc_mark_extra_sections (struct bfd_link_info *info,
Line 11802... Line 12298...
11802
				 elf_gc_mark_hook_fn mark_hook ATTRIBUTE_UNUSED)
12298
				 elf_gc_mark_hook_fn mark_hook ATTRIBUTE_UNUSED)
11803
{
12299
{
11804
  bfd *ibfd;
12300
  bfd *ibfd;
11805
 
12301
 
11806
  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
12302
  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
Line 11833... Line 12329...
11833
	 toss out the debug and special sections.  */
12329
	 toss out the debug and special sections.  */
11834
      if (!some_kept)
12330
      if (!some_kept)
11835
	continue;
12331
	continue;
Line 11836... Line 12332...
11836
 
12332
 
11837
      /* Keep debug and special sections like .comment when they are
12333
      /* Keep debug and special sections like .comment when they are
-
 
12334
	 not part of a group.  Also keep section groups that contain
11838
	 not part of a group, or when we have single-member groups.  */
12335
	 just debug sections or special sections.  */
-
 
12336
      for (isec = ibfd->sections; isec != NULL; isec = isec->next)
11839
      for (isec = ibfd->sections; isec != NULL; isec = isec->next)
12337
	{
11840
	if ((elf_next_in_group (isec) == NULL
12338
	  if ((isec->flags & SEC_GROUP) != 0)
11841
	     || elf_next_in_group (isec) == isec)
12339
	    _bfd_elf_gc_mark_debug_special_section_group (isec);
11842
	    && ((isec->flags & SEC_DEBUGGING) != 0
12340
	  else if (((isec->flags & SEC_DEBUGGING) != 0
-
 
12341
		    || (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0)
11843
		|| (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0))
12342
		   && elf_next_in_group (isec) == NULL)
-
 
12343
	    isec->gc_mark = 1;
Line 11844... Line 12344...
11844
	  isec->gc_mark = 1;
12344
	}
11845
 
12345
 
Line 11846... Line 12346...
11846
      if (! debug_frag_seen)
12346
      if (! debug_frag_seen)
Line 11875... Line 12375...
11875
		if (dlen > ilen
12375
		if (dlen > ilen
11876
		    && strncmp (dsec->name + (dlen - ilen),
12376
		    && strncmp (dsec->name + (dlen - ilen),
11877
				isec->name, ilen) == 0)
12377
				isec->name, ilen) == 0)
11878
		  {
12378
		  {
11879
		    dsec->gc_mark = 0;
12379
		    dsec->gc_mark = 0;
11880
		    break;
-
 
11881
		  }
12380
		  }
11882
	      }
12381
	      }
11883
	  }
12382
	  }
11884
    }
12383
    }
11885
  return TRUE;
12384
  return TRUE;
Line 11898... Line 12397...
11898
elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
12397
elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
11899
{
12398
{
11900
  if (!h->mark
12399
  if (!h->mark
11901
      && (((h->root.type == bfd_link_hash_defined
12400
      && (((h->root.type == bfd_link_hash_defined
11902
	    || h->root.type == bfd_link_hash_defweak)
12401
	    || h->root.type == bfd_link_hash_defweak)
11903
	   && !(h->def_regular
12402
	   && !((h->def_regular || ELF_COMMON_DEF_P (h))
11904
		&& h->root.u.def.section->gc_mark))
12403
		&& h->root.u.def.section->gc_mark))
11905
	  || h->root.type == bfd_link_hash_undefined
12404
	  || h->root.type == bfd_link_hash_undefined
11906
	  || h->root.type == bfd_link_hash_undefweak))
12405
	  || h->root.type == bfd_link_hash_undefweak))
11907
    {
12406
    {
11908
      struct elf_gc_sweep_symbol_info *inf;
12407
      struct elf_gc_sweep_symbol_info *inf;
Line 11929... Line 12428...
11929
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
12428
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
11930
  gc_sweep_hook_fn gc_sweep_hook = bed->gc_sweep_hook;
12429
  gc_sweep_hook_fn gc_sweep_hook = bed->gc_sweep_hook;
11931
  unsigned long section_sym_count;
12430
  unsigned long section_sym_count;
11932
  struct elf_gc_sweep_symbol_info sweep_info;
12431
  struct elf_gc_sweep_symbol_info sweep_info;
Line 11933... Line 12432...
11933
 
12432
 
11934
  for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
12433
  for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
11935
    {
12434
    {
Line 11936... Line 12435...
11936
      asection *o;
12435
      asection *o;
-
 
12436
 
11937
 
12437
      if (bfd_get_flavour (sub) != bfd_target_elf_flavour
Line 11938... Line 12438...
11938
      if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
12438
	  || !(*bed->relocs_compatible) (sub->xvec, abfd->xvec))
11939
	continue;
12439
	continue;
11940
 
12440
 
Line 11966... Line 12466...
11966
 
12466
 
11967
	  /* But we also have to update some of the relocation
12467
	  /* But we also have to update some of the relocation
11968
	     info we collected before.  */
12468
	     info we collected before.  */
11969
	  if (gc_sweep_hook
12469
	  if (gc_sweep_hook
11970
	      && (o->flags & SEC_RELOC) != 0
12470
	      && (o->flags & SEC_RELOC) != 0
-
 
12471
	      && o->reloc_count != 0
-
 
12472
	      && !((info->strip == strip_all || info->strip == strip_debugger)
11971
	      && o->reloc_count > 0
12473
		   && (o->flags & SEC_DEBUGGING) != 0)
11972
	      && !bfd_is_abs_section (o->output_section))
12474
	      && !bfd_is_abs_section (o->output_section))
11973
	    {
12475
	    {
11974
	      Elf_Internal_Rela *internal_relocs;
12476
	      Elf_Internal_Rela *internal_relocs;
Line 12114... Line 12616...
12114
 
12616
 
12115
bfd_boolean
12617
bfd_boolean
12116
bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
12618
bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
12117
{
12619
{
-
 
12620
  struct bfd_link_info *info = (struct bfd_link_info *) inf;
Line 12118... Line 12621...
12118
  struct bfd_link_info *info = (struct bfd_link_info *) inf;
12621
  struct bfd_elf_dynamic_list *d = info->dynamic_list;
12119
 
12622
 
12120
  if ((h->root.type == bfd_link_hash_defined
12623
  if ((h->root.type == bfd_link_hash_defined
12121
       || h->root.type == bfd_link_hash_defweak)
12624
       || h->root.type == bfd_link_hash_defweak)
12122
      && (h->ref_dynamic
-
 
12123
	  || ((!info->executable || info->export_dynamic)
12625
      && (h->ref_dynamic
12124
	      && h->def_regular
12626
	  || ((h->def_regular || ELF_COMMON_DEF_P (h))
-
 
12627
	      && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
-
 
12628
	      && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
-
 
12629
	      && (!bfd_link_executable (info)
-
 
12630
		  || info->export_dynamic
12125
	      && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
12631
		  || (h->dynamic
-
 
12632
		      && d != NULL
12126
	      && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
12633
		      && (*d->match) (&d->head, NULL, h->root.root.string)))
12127
	      && (strchr (h->root.root.string, ELF_VER_CHR) != NULL
12634
	      && (h->versioned >= versioned
12128
		  || !bfd_hide_sym_by_version (info->version_info,
12635
		  || !bfd_hide_sym_by_version (info->version_info,
Line 12129... Line 12636...
12129
					       h->root.root.string)))))
12636
					       h->root.root.string)))))
Line 12153... Line 12660...
12153
	  && !bfd_is_abs_section (h->root.u.def.section))
12660
	  && !bfd_is_abs_section (h->root.u.def.section))
12154
	h->root.u.def.section->flags |= SEC_KEEP;
12661
	h->root.u.def.section->flags |= SEC_KEEP;
12155
    }
12662
    }
12156
}
12663
}
Line -... Line 12664...
-
 
12664
 
-
 
12665
bfd_boolean
-
 
12666
bfd_elf_parse_eh_frame_entries (bfd *abfd ATTRIBUTE_UNUSED,
-
 
12667
				struct bfd_link_info *info)
-
 
12668
{
-
 
12669
  bfd *ibfd = info->input_bfds;
-
 
12670
 
-
 
12671
  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
-
 
12672
    {
-
 
12673
      asection *sec;
-
 
12674
      struct elf_reloc_cookie cookie;
-
 
12675
 
-
 
12676
      if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
-
 
12677
	continue;
-
 
12678
 
-
 
12679
      if (!init_reloc_cookie (&cookie, info, ibfd))
-
 
12680
	return FALSE;
-
 
12681
 
-
 
12682
      for (sec = ibfd->sections; sec; sec = sec->next)
-
 
12683
	{
-
 
12684
	  if (CONST_STRNEQ (bfd_section_name (ibfd, sec), ".eh_frame_entry")
-
 
12685
	      && init_reloc_cookie_rels (&cookie, info, ibfd, sec))
-
 
12686
	    {
-
 
12687
	      _bfd_elf_parse_eh_frame_entry (info, sec, &cookie);
-
 
12688
	      fini_reloc_cookie_rels (&cookie, sec);
-
 
12689
	    }
-
 
12690
	}
-
 
12691
    }
-
 
12692
  return TRUE;
-
 
12693
}
12157
 
12694
 
Line 12158... Line 12695...
12158
/* Do mark and sweep of unused sections.  */
12695
/* Do mark and sweep of unused sections.  */
12159
 
12696
 
12160
bfd_boolean
12697
bfd_boolean
12161
bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
12698
bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
12162
{
12699
{
12163
  bfd_boolean ok = TRUE;
12700
  bfd_boolean ok = TRUE;
12164
  bfd *sub;
12701
  bfd *sub;
-
 
12702
  elf_gc_mark_hook_fn gc_mark_hook;
Line 12165... Line 12703...
12165
  elf_gc_mark_hook_fn gc_mark_hook;
12703
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
12166
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
12704
  struct elf_link_hash_table *htab;
12167
 
12705
 
12168
  if (!bed->can_gc_sections
12706
  if (!bed->can_gc_sections
12169
      || !is_elf_hash_table (info->hash))
12707
      || !is_elf_hash_table (info->hash))
12170
    {
12708
    {
Line 12171... Line 12709...
12171
      (*_bfd_error_handler)(_("Warning: gc-sections option ignored"));
12709
      (*_bfd_error_handler)(_("Warning: gc-sections option ignored"));
-
 
12710
      return TRUE;
Line 12172... Line 12711...
12172
      return TRUE;
12711
    }
12173
    }
12712
 
12174
 
12713
  bed->gc_keep (info);
12175
  bed->gc_keep (info);
12714
  htab = elf_hash_table (info);
-
 
12715
 
12176
 
12716
  /* Try to parse each bfd's .eh_frame section.  Point elf_eh_frame_section
12177
  /* Try to parse each bfd's .eh_frame section.  Point elf_eh_frame_section
12717
     at the .eh_frame section if we can mark the FDEs individually.  */
12178
     at the .eh_frame section if we can mark the FDEs individually.  */
12718
  for (sub = info->input_bfds;
Line 12179... Line 12719...
12179
  _bfd_elf_begin_eh_frame_parsing (info);
12719
       info->eh_frame_hdr_type != COMPACT_EH_HDR && sub != NULL;
Line 12188... Line 12728...
12188
	  _bfd_elf_parse_eh_frame (sub, info, sec, &cookie);
12728
	  _bfd_elf_parse_eh_frame (sub, info, sec, &cookie);
12189
	  if (elf_section_data (sec)->sec_info
12729
	  if (elf_section_data (sec)->sec_info
12190
	      && (sec->flags & SEC_LINKER_CREATED) == 0)
12730
	      && (sec->flags & SEC_LINKER_CREATED) == 0)
12191
	    elf_eh_frame_section (sub) = sec;
12731
	    elf_eh_frame_section (sub) = sec;
12192
	  fini_reloc_cookie_for_section (&cookie, sec);
12732
	  fini_reloc_cookie_for_section (&cookie, sec);
12193
	  sec = bfd_get_next_section_by_name (sec);
12733
	  sec = bfd_get_next_section_by_name (NULL, sec);
12194
	}
12734
	}
12195
    }
12735
    }
12196
  _bfd_elf_end_eh_frame_parsing (info);
-
 
Line 12197... Line 12736...
12197
 
12736
 
12198
  /* Apply transitive closure to the vtable entry usage info.  */
12737
  /* Apply transitive closure to the vtable entry usage info.  */
12199
  elf_link_hash_traverse (elf_hash_table (info),
-
 
12200
			  elf_gc_propagate_vtable_entries_used,
-
 
12201
			  &ok);
12738
  elf_link_hash_traverse (htab, elf_gc_propagate_vtable_entries_used, &ok);
12202
  if (!ok)
12739
  if (!ok)
Line 12203... Line 12740...
12203
    return FALSE;
12740
    return FALSE;
12204
 
12741
 
12205
  /* Kill the vtable relocations that were not used.  */
-
 
12206
  elf_link_hash_traverse (elf_hash_table (info),
-
 
12207
			  elf_gc_smash_unused_vtentry_relocs,
12742
  /* Kill the vtable relocations that were not used.  */
12208
			  &ok);
12743
  elf_link_hash_traverse (htab, elf_gc_smash_unused_vtentry_relocs, &ok);
Line 12209... Line 12744...
12209
  if (!ok)
12744
  if (!ok)
12210
    return FALSE;
12745
    return FALSE;
12211
 
12746
 
12212
  /* Mark dynamically referenced symbols.  */
-
 
12213
  if (elf_hash_table (info)->dynamic_sections_created)
-
 
Line 12214... Line 12747...
12214
    elf_link_hash_traverse (elf_hash_table (info),
12747
  /* Mark dynamically referenced symbols.  */
12215
			    bed->gc_mark_dynamic_ref,
12748
  if (htab->dynamic_sections_created)
12216
			    info);
12749
    elf_link_hash_traverse (htab, bed->gc_mark_dynamic_ref, info);
12217
 
12750
 
12218
  /* Grovel through relocs to find out who stays ...  */
12751
  /* Grovel through relocs to find out who stays ...  */
Line 12219... Line 12752...
12219
  gc_mark_hook = bed->gc_mark_hook;
12752
  gc_mark_hook = bed->gc_mark_hook;
-
 
12753
  for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
12220
  for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
12754
    {
Line 12221... Line 12755...
12221
    {
12755
      asection *o;
12222
      asection *o;
12756
 
12223
 
12757
      if (bfd_get_flavour (sub) != bfd_target_elf_flavour
Line 12287... Line 12821...
12287
  return FALSE;
12821
  return FALSE;
Line 12288... Line 12822...
12288
 
12822
 
12289
 win:
12823
 win:
12290
  if (!child->vtable)
12824
  if (!child->vtable)
12291
    {
12825
    {
12292
      child->vtable = (struct elf_link_virtual_table_entry *)
12826
      child->vtable = ((struct elf_link_virtual_table_entry *)
12293
          bfd_zalloc (abfd, sizeof (*child->vtable));
12827
		       bfd_zalloc (abfd, sizeof (*child->vtable)));
12294
      if (!child->vtable)
12828
      if (!child->vtable)
12295
	return FALSE;
12829
	return FALSE;
12296
    }
12830
    }
12297
  if (!h)
12831
  if (!h)
Line 12320... Line 12854...
12320
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
12854
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
12321
  unsigned int log_file_align = bed->s->log_file_align;
12855
  unsigned int log_file_align = bed->s->log_file_align;
Line 12322... Line 12856...
12322
 
12856
 
12323
  if (!h->vtable)
12857
  if (!h->vtable)
12324
    {
12858
    {
12325
      h->vtable = (struct elf_link_virtual_table_entry *)
12859
      h->vtable = ((struct elf_link_virtual_table_entry *)
12326
          bfd_zalloc (abfd, sizeof (*h->vtable));
12860
		   bfd_zalloc (abfd, sizeof (*h->vtable)));
12327
      if (!h->vtable)
12861
      if (!h->vtable)
12328
	return FALSE;
12862
	return FALSE;
Line 12329... Line 12863...
12329
    }
12863
    }
Line 12524... Line 13058...
12524
    gotoff = 0;
13058
    gotoff = 0;
12525
  else
13059
  else
12526
    gotoff = bed->got_header_size;
13060
    gotoff = bed->got_header_size;
Line 12527... Line 13061...
12527
 
13061
 
12528
  /* Do the local .got entries first.  */
13062
  /* Do the local .got entries first.  */
12529
  for (i = info->input_bfds; i; i = i->link_next)
13063
  for (i = info->input_bfds; i; i = i->link.next)
12530
    {
13064
    {
12531
      bfd_signed_vma *local_got;
13065
      bfd_signed_vma *local_got;
12532
      bfd_size_type j, locsymcount;
13066
      bfd_size_type j, locsymcount;
Line 12613... Line 13147...
12613
		 || h->root.type == bfd_link_hash_warning)
13147
		 || h->root.type == bfd_link_hash_warning)
12614
	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
13148
	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
Line 12615... Line 13149...
12615
 
13149
 
12616
	  if ((h->root.type == bfd_link_hash_defined
13150
	  if ((h->root.type == bfd_link_hash_defined
-
 
13151
	       || h->root.type == bfd_link_hash_defweak)
-
 
13152
	      && (h->root.u.def.section->owner != rcookie->abfd
12617
	       || h->root.type == bfd_link_hash_defweak)
13153
		  || h->root.u.def.section->kept_section != NULL
12618
	      && discarded_section (h->root.u.def.section))
13154
		  || discarded_section (h->root.u.def.section)))
12619
	    return TRUE;
-
 
12620
	  else
-
 
12621
	    return FALSE;
13155
	    return TRUE;
12622
	}
13156
	}
12623
      else
13157
      else
12624
	{
13158
	{
12625
	  /* It's not a relocation against a global symbol,
13159
	  /* It's not a relocation against a global symbol,
Line 12629... Line 13163...
12629
	  Elf_Internal_Sym *isym;
13163
	  Elf_Internal_Sym *isym;
Line 12630... Line 13164...
12630
 
13164
 
12631
	  /* Need to: get the symbol; get the section.  */
13165
	  /* Need to: get the symbol; get the section.  */
12632
	  isym = &rcookie->locsyms[r_symndx];
13166
	  isym = &rcookie->locsyms[r_symndx];
-
 
13167
	  isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx);
-
 
13168
	  if (isec != NULL
12633
	  isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx);
13169
	      && (isec->kept_section != NULL
12634
	  if (isec != NULL && discarded_section (isec))
13170
		  || discarded_section (isec)))
12635
	    return TRUE;
13171
	    return TRUE;
12636
	}
13172
	}
12637
      return FALSE;
13173
      return FALSE;
12638
    }
13174
    }
12639
  return FALSE;
13175
  return FALSE;
Line 12640... Line 13176...
12640
}
13176
}
12641
 
13177
 
12642
/* Discard unneeded references to discarded sections.
13178
/* Discard unneeded references to discarded sections.
12643
   Returns TRUE if any section's size was changed.  */
13179
   Returns -1 on error, 1 if any section's size was changed, 0 if
Line 12644... Line 13180...
12644
/* This function assumes that the relocations are in sorted order,
13180
   nothing changed.  This function assumes that the relocations are in
12645
   which is true for all known assemblers.  */
13181
   sorted order, which is true for all known assemblers.  */
12646
 
13182
 
12647
bfd_boolean
13183
int
12648
bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
13184
bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
12649
{
-
 
12650
  struct elf_reloc_cookie cookie;
13185
{
12651
  asection *stab, *eh;
13186
  struct elf_reloc_cookie cookie;
Line 12652... Line 13187...
12652
  const struct elf_backend_data *bed;
13187
  asection *o;
12653
  bfd *abfd;
13188
  bfd *abfd;
12654
  bfd_boolean ret = FALSE;
13189
  int changed = 0;
Line 12655... Line 13190...
12655
 
13190
 
12656
  if (info->traditional_format
13191
  if (info->traditional_format
12657
      || !is_elf_hash_table (info->hash))
13192
      || !is_elf_hash_table (info->hash))
12658
    return FALSE;
-
 
12659
 
13193
    return 0;
Line 12660... Line 13194...
12660
  _bfd_elf_begin_eh_frame_parsing (info);
13194
 
12661
  for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next)
-
 
12662
    {
-
 
12663
      if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
-
 
12664
	continue;
13195
  o = bfd_get_section_by_name (output_bfd, ".stab");
12665
 
-
 
12666
      bed = get_elf_backend_data (abfd);
-
 
12667
 
13196
  if (o != NULL)
12668
      eh = NULL;
-
 
12669
      if (!info->relocatable)
-
 
12670
	{
-
 
12671
	  eh = bfd_get_section_by_name (abfd, ".eh_frame");
-
 
12672
	  while (eh != NULL
-
 
12673
		 && (eh->size == 0
-
 
12674
		     || bfd_is_abs_section (eh->output_section)))
13197
    {
12675
	    eh = bfd_get_next_section_by_name (eh);
-
 
12676
	}
13198
      asection *i;
12677
 
-
 
12678
      stab = bfd_get_section_by_name (abfd, ".stab");
-
 
12679
      if (stab != NULL
-
 
12680
	  && (stab->size == 0
-
 
12681
	      || bfd_is_abs_section (stab->output_section)
-
 
12682
	      || stab->sec_info_type != SEC_INFO_TYPE_STABS))
13199
 
Line -... Line 13200...
-
 
13200
      for (i = o->map_head.s; i != NULL; i = i->map_head.s)
12683
	stab = NULL;
13201
	{
12684
 
13202
	  if (i->size == 0
Line 12685... Line 13203...
12685
      if (stab == NULL
13203
	      || i->reloc_count == 0
12686
	  && eh == NULL
13204
	      || i->sec_info_type != SEC_INFO_TYPE_STABS)
12687
	  && bed->elf_backend_discard_info == NULL)
-
 
12688
	continue;
13205
	    continue;
12689
 
13206
 
12690
      if (!init_reloc_cookie (&cookie, info, abfd))
13207
	  abfd = i->owner;
12691
	return FALSE;
13208
	  if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
12692
 
13209
	    continue;
12693
      if (stab != NULL
13210
 
-
 
13211
	  if (!init_reloc_cookie_for_section (&cookie, info, i))
12694
	  && stab->reloc_count > 0
13212
	    return -1;
-
 
13213
 
12695
	  && init_reloc_cookie_rels (&cookie, info, abfd, stab))
13214
	  if (_bfd_discard_section_stabs (abfd, i,
Line 12696... Line 13215...
12696
	{
13215
					  elf_section_data (i)->sec_info,
-
 
13216
					  bfd_elf_reloc_symbol_deleted_p,
12697
	  if (_bfd_discard_section_stabs (abfd, stab,
13217
					  &cookie))
-
 
13218
	    changed = 1;
12698
					  elf_section_data (stab)->sec_info,
13219
 
-
 
13220
	  fini_reloc_cookie_for_section (&cookie, i);
-
 
13221
	}
-
 
13222
    }
-
 
13223
 
-
 
13224
  o = NULL;
-
 
13225
  if (info->eh_frame_hdr_type != COMPACT_EH_HDR)
-
 
13226
    o = bfd_get_section_by_name (output_bfd, ".eh_frame");
-
 
13227
  if (o != NULL)
-
 
13228
    {
-
 
13229
      asection *i;
-
 
13230
 
-
 
13231
      for (i = o->map_head.s; i != NULL; i = i->map_head.s)
-
 
13232
	{
-
 
13233
	  if (i->size == 0)
12699
					  bfd_elf_reloc_symbol_deleted_p,
13234
	    continue;
12700
					  &cookie))
13235
 
12701
	    ret = TRUE;
13236
	  abfd = i->owner;
12702
	  fini_reloc_cookie_rels (&cookie, stab);
13237
	  if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
12703
	}
13238
	    continue;
-
 
13239
 
12704
 
13240
	  if (!init_reloc_cookie_for_section (&cookie, info, i))
12705
      while (eh != NULL
-
 
-
 
13241
	    return -1;
12706
	     && init_reloc_cookie_rels (&cookie, info, abfd, eh))
13242
 
Line -... Line 13243...
-
 
13243
	  _bfd_elf_parse_eh_frame (abfd, info, i, &cookie);
-
 
13244
	  if (_bfd_elf_discard_section_eh_frame (abfd, info, i,
-
 
13245
						 bfd_elf_reloc_symbol_deleted_p,
-
 
13246
						 &cookie))
-
 
13247
	    changed = 1;
-
 
13248
 
-
 
13249
	  fini_reloc_cookie_for_section (&cookie, i);
-
 
13250
	}
-
 
13251
    }
12707
	{
13252
 
-
 
13253
  for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next)
-
 
13254
    {
-
 
13255
      const struct elf_backend_data *bed;
-
 
13256
 
12708
	  _bfd_elf_parse_eh_frame (abfd, info, eh, &cookie);
13257
      if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
12709
	  if (_bfd_elf_discard_section_eh_frame (abfd, info, eh,
13258
	continue;
Line 12710... Line 13259...
12710
						 bfd_elf_reloc_symbol_deleted_p,
13259
 
12711
						 &cookie))
13260
      bed = get_elf_backend_data (abfd);
-
 
13261
 
-
 
13262
      if (bed->elf_backend_discard_info != NULL)
-
 
13263
	{
12712
	    ret = TRUE;
13264
	  if (!init_reloc_cookie (&cookie, info, abfd))
Line 12713... Line 13265...
12713
	  fini_reloc_cookie_rels (&cookie, eh);
13265
	    return -1;
12714
	  eh = bfd_get_next_section_by_name (eh);
13266
 
12715
	}
13267
	  if ((*bed->elf_backend_discard_info) (abfd, &cookie, info))
12716
 
13268
	    changed = 1;
Line 12717... Line 13269...
12717
      if (bed->elf_backend_discard_info != NULL
13269
 
12718
	  && (*bed->elf_backend_discard_info) (abfd, &cookie, info))
13270
	  fini_reloc_cookie (&cookie, abfd);
Line 12719... Line 13271...
12719
	ret = TRUE;
13271
	}
12720
 
13272
    }
12721
      fini_reloc_cookie (&cookie, abfd);
13273
 
Line 13009... Line 13561...
13009
    }
13561
    }
Line 13010... Line 13562...
13010
 
13562
 
13011
  return reloc_sec;
13563
  return reloc_sec;
Line 13012... Line 13564...
13012
}
13564
}
-
 
13565
 
-
 
13566
/* Copy the ELF symbol type and other attributes for a linker script
-
 
13567
   assignment from HSRC to HDEST.  Generally this should be treated as
13013
 
13568
   if we found a strong non-dynamic definition for HDEST (except that
13014
/* Copy the ELF symbol type associated with a linker hash entry.  */
13569
   ld ignores multiple definition errors).  */
13015
void
13570
void
13016
_bfd_elf_copy_link_hash_symbol_type (bfd *abfd ATTRIBUTE_UNUSED,
13571
_bfd_elf_copy_link_hash_symbol_type (bfd *abfd,
13017
    struct bfd_link_hash_entry * hdest,
13572
				     struct bfd_link_hash_entry *hdest,
13018
    struct bfd_link_hash_entry * hsrc)
13573
				     struct bfd_link_hash_entry *hsrc)
13019
{
13574
{
-
 
13575
  struct elf_link_hash_entry *ehdest = (struct elf_link_hash_entry *) hdest;
Line 13020... Line 13576...
13020
  struct elf_link_hash_entry *ehdest = (struct elf_link_hash_entry *)hdest;
13576
  struct elf_link_hash_entry *ehsrc = (struct elf_link_hash_entry *) hsrc;
13021
  struct elf_link_hash_entry *ehsrc = (struct elf_link_hash_entry *)hsrc;
13577
  Elf_Internal_Sym isym;
-
 
13578
 
-
 
13579
  ehdest->type = ehsrc->type;
-
 
13580
  ehdest->target_internal = ehsrc->target_internal;
13022
 
13581
 
Line 13023... Line 13582...
13023
  ehdest->type = ehsrc->type;
13582
  isym.st_other = ehsrc->other;
Line 13024... Line 13583...
13024
  ehdest->target_internal = ehsrc->target_internal;
13583
  elf_merge_st_other (abfd, ehdest, &isym, NULL, TRUE, FALSE);