2004-06-07 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / bfd / elflink.c
index 32f42641689637c73f1573b56aae7df2d06c50b0..436ff840e6d2364fd3800a1b11df6bcabca7dda0 100644 (file)
@@ -622,8 +622,36 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd, struct bfd_link_info *info)
     {
       asection *p;
       for (p = output_bfd->sections; p ; p = p->next)
-       if ((p->flags & SEC_EXCLUDE) == 0)
-         elf_section_data (p)->dynindx = ++dynsymcount;
+       if ((p->flags & SEC_EXCLUDE) == 0
+           && (p->flags & SEC_ALLOC) != 0)
+         switch (elf_section_data (p)->this_hdr.sh_type)
+           {
+           case SHT_PROGBITS:
+           case SHT_NOBITS:
+             /* If sh_type is yet undecided, assume it could be
+                SHT_PROGBITS/SHT_NOBITS.  */
+           case SHT_NULL:
+             if (strcmp (p->name, ".got") == 0
+                 || strcmp (p->name, ".got.plt") == 0
+                 || strcmp (p->name, ".plt") == 0)
+               {
+                 asection *ip;
+                 bfd *dynobj = elf_hash_table (info)->dynobj;
+
+                 if (dynobj != NULL
+                     && (ip = bfd_get_section_by_name (dynobj, p->name))
+                        != NULL
+                     && (ip->flags & SEC_LINKER_CREATED)
+                     && ip->output_section == p)
+                   continue;
+               }
+             elf_section_data (p)->dynindx = ++dynsymcount;
+             break;
+             /* There shouldn't be section relative relocations
+                against any other section.  */
+           default:
+             break;
+           }
     }
 
   if (elf_hash_table (info)->dynlocal)
@@ -2334,7 +2362,7 @@ _bfd_elf_link_sec_merge_syms (struct elf_link_hash_entry *h, void *data)
        _bfd_merged_section_offset (output_bfd,
                                    &h->root.u.def.section,
                                    elf_section_data (sec)->sec_info,
-                                   h->root.u.def.value, 0);
+                                   h->root.u.def.value);
     }
 
   return TRUE;
@@ -4099,28 +4127,6 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
        }
     }
 
-  if (! info->relocatable
-      && ! dynamic
-      && is_elf_hash_table (hash_table))
-    {
-      asection *s;
-
-      for (s = abfd->sections; s != NULL; s = s->next)
-       if ((s->flags & SEC_MERGE) != 0
-           && !bfd_is_abs_section (s->output_section))
-         {
-           struct bfd_elf_section_data *secdata;
-
-           secdata = elf_section_data (s);
-           if (! _bfd_merge_section (abfd,
-                                     & hash_table->merge_info,
-                                     s, &secdata->sec_info))
-             goto error_return;
-           else if (secdata->sec_info)
-             s->sec_info_type = ELF_INFO_TYPE_MERGE;
-         }
-    }
-
   if (is_elf_hash_table (hash_table))
     {
       /* Add this bfd to the loaded list.  */
@@ -4621,6 +4627,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
   if (!is_elf_hash_table (info->hash))
     return TRUE;
 
+  elf_tdata (output_bfd)->relro = info->relro;
   if (info->execstack)
     elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
   else if (info->noexecstack)
@@ -6363,7 +6370,7 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
            isym->st_value =
              _bfd_merged_section_offset (output_bfd, &isec,
                                          elf_section_data (isec)->sec_info,
-                                         isym->st_value, 0);
+                                         isym->st_value);
        }
       else if (isym->st_shndx == SHN_ABS)
        isec = bfd_abs_section_ptr;
@@ -7654,16 +7661,18 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
              bfd_byte *dest;
              long dynindx;
 
-             indx = elf_section_data (s)->this_idx;
              dynindx = elf_section_data (s)->dynindx;
+             if (dynindx <= 0)
+               continue;
+             indx = elf_section_data (s)->this_idx;
              BFD_ASSERT (indx > 0);
              sym.st_shndx = indx;
              sym.st_value = s->vma;
              dest = dynsym + dynindx * bed->s->sizeof_sym;
+             if (last_local < dynindx)
+               last_local = dynindx;
              bed->s->swap_symbol_out (abfd, &sym, dest, 0);
            }
-
-         last_local = bfd_count_sections (abfd);
        }
 
       /* Write out the local dynsyms.  */
This page took 0.026005 seconds and 4 git commands to generate.