* merge.c (_bfd_merged_section_offset): Remove "addend" param.
authorAlan Modra <amodra@gmail.com>
Sat, 22 May 2004 01:56:31 +0000 (01:56 +0000)
committerAlan Modra <amodra@gmail.com>
Sat, 22 May 2004 01:56:31 +0000 (01:56 +0000)
* libbfd-in.h (_bfd_merged_section_offset): Adjust prototype.
* libbfd.h: Regenerate.
* elf.c (_bfd_elf_rela_local_sym): Adjust call.
(_bfd_elf_rel_local_sym): Likewise.
* elflink.c (_bfd_elf_link_sec_merge_syms): Likewise.
(elf_link_input_bfd): Likewise.
* elf32-ppc.c (ppc_elf_relax_section): Likewise.
* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
* elfxx-ia64.c (elfNN_ia64_relax_section): Likewise.
(elfNN_ia64_relocate_section): Likewise.

bfd/ChangeLog
bfd/elf.c
bfd/elf32-ppc.c
bfd/elf64-alpha.c
bfd/elflink.c
bfd/elfxx-ia64.c
bfd/libbfd-in.h
bfd/libbfd.h
bfd/merge.c

index 824a23c42ed8b537a96e0c81c48758dbc3082e24..e78e132da9158ce252fdba57e2c926a6df9ac1e2 100644 (file)
@@ -1,3 +1,17 @@
+2004-05-22  Alan Modra  <amodra@bigpond.net.au>
+
+       * merge.c (_bfd_merged_section_offset): Remove "addend" param.
+       * libbfd-in.h (_bfd_merged_section_offset): Adjust prototype.
+       * libbfd.h: Regenerate.
+       * elf.c (_bfd_elf_rela_local_sym): Adjust call.
+       (_bfd_elf_rel_local_sym): Likewise.
+       * elflink.c (_bfd_elf_link_sec_merge_syms): Likewise.
+       (elf_link_input_bfd): Likewise.
+       * elf32-ppc.c (ppc_elf_relax_section): Likewise.
+       * elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
+       * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise.
+       (elfNN_ia64_relocate_section): Likewise.
+
 2004-05-21  Andy Chittenden  <achittenden@bluearc.com>
 
        * hash.c (bfd_default_hash_table_size): New variable.
index 0317e354a7703153052600d12e2e48fe60de7fc8..e5ab09e3f0be46ffd46f1c6ee2a035ef1e63b1a9 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7537,9 +7537,18 @@ _bfd_elf_rela_local_sym (bfd *abfd,
       rel->r_addend =
        _bfd_merged_section_offset (abfd, psec,
                                    elf_section_data (sec)->sec_info,
-                                   sym->st_value + rel->r_addend,
-                                   0);
-      sec = *psec;
+                                   sym->st_value + rel->r_addend);
+      if (sec != *psec)
+       {
+         /* If we have changed the section, and our original section is
+            marked with SEC_EXCLUDE, it means that the original
+            SEC_MERGE section has been completely subsumed in some
+            other SEC_MERGE section.  In this case, we need to leave
+            some info around for --emit-relocs.  */
+         if ((sec->flags & SEC_EXCLUDE) != 0)
+           sec->kept_section = *psec;
+         sec = *psec;
+       }
       rel->r_addend -= relocation;
       rel->r_addend += sec->output_section->vma + sec->output_offset;
     }
@@ -7559,7 +7568,7 @@ _bfd_elf_rel_local_sym (bfd *abfd,
 
   return _bfd_merged_section_offset (abfd, psec,
                                     elf_section_data (sec)->sec_info,
-                                    sym->st_value + addend, 0);
+                                    sym->st_value + addend);
 }
 
 bfd_vma
index bdd3450f4ab7766d414662feaa7705ff18e8c4ef..980dcb9996b43abe637771299ea2c403ff51c884 100644 (file)
@@ -1811,7 +1811,7 @@ ppc_elf_relax_section (bfd *abfd,
       if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
        toff = _bfd_merged_section_offset (abfd, &tsec,
                                           elf_section_data (tsec)->sec_info,
-                                          toff, 0);
+                                          toff);
 
       symaddr = tsec->output_section->vma + tsec->output_offset + toff;
 
index 01c66b5dcff3b72e7ac68dfc4e0389f17f2ee686..21785d50c30609ee5824e080b5eda5c297f8580f 100644 (file)
@@ -4381,8 +4381,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                    _bfd_merged_section_offset (output_bfd, &msec,
                                                elf_section_data (sec)->
                                                  sec_info,
-                                               sym->st_value + ent->addend,
-                                               (bfd_vma) 0);
+                                               sym->st_value + ent->addend);
                  ent->addend -= sym->st_value;
                  ent->addend += msec->output_section->vma
                                 + msec->output_offset
index cee59096a522f79d07c95841371829c7b303ca0c..37540aa871d8ef427460f4ac09404484cec3a58b 100644 (file)
@@ -2362,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;
@@ -6392,7 +6392,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;
index 20d90831f124e538444e432fc8f7c84bb9e29c40..26b2e455488740767bf8e3f9a3976f73fa6b2732 100644 (file)
@@ -913,8 +913,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
       if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
        toff = _bfd_merged_section_offset (abfd, &tsec,
                                           elf_section_data (tsec)->sec_info,
-                                          toff + irel->r_addend,
-                                          (bfd_vma) 0);
+                                          toff + irel->r_addend);
       else
        toff += irel->r_addend;
 
@@ -3963,8 +3962,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
                                                    elf_section_data (msec)->
                                                    sec_info,
                                                    sym->st_value
-                                                   + dynent->addend,
-                                                   (bfd_vma) 0);
+                                                   + dynent->addend);
                      dynent->addend -= sym->st_value;
                      dynent->addend += msec->output_section->vma
                                        + msec->output_offset
index 6d3a335eafbc24ac6856eb62345fa227e1c8b064..956727d4324eee9ba11e21168c8fbc22b3177cb5 100644 (file)
@@ -538,7 +538,7 @@ extern bfd_boolean _bfd_write_merged_section
 /* Find an offset within a modified SEC_MERGE section.  */
 
 extern bfd_vma _bfd_merged_section_offset
-  (bfd *, asection **, void *, bfd_vma, bfd_vma);
+  (bfd *, asection **, void *, bfd_vma);
 
 /* Create a string table.  */
 extern struct bfd_strtab_hash *_bfd_stringtab_init
index 86819ff03e211771c1d6085d82a70f63d01cc19e..96776cac65d26d184eb33830ad522ecefa65f3cc 100644 (file)
@@ -543,7 +543,7 @@ extern bfd_boolean _bfd_write_merged_section
 /* Find an offset within a modified SEC_MERGE section.  */
 
 extern bfd_vma _bfd_merged_section_offset
-  (bfd *, asection **, void *, bfd_vma, bfd_vma);
+  (bfd *, asection **, void *, bfd_vma);
 
 /* Create a string table.  */
 extern struct bfd_strtab_hash *_bfd_stringtab_init
index 89f45cd521a2f64fa2bbf314bc324a1b0572b811..3811523ecc917a42e87a23c5f723d95a57652882 100644 (file)
@@ -780,7 +780,7 @@ _bfd_write_merged_section (bfd *output_bfd, asection *sec, void *psecinfo)
 
 bfd_vma
 _bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
-                           void *psecinfo, bfd_vma offset, bfd_vma addend)
+                           void *psecinfo, bfd_vma offset)
 {
   struct sec_merge_sec_info *secinfo;
   struct sec_merge_hash_entry *entry;
@@ -789,13 +789,13 @@ _bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
 
   secinfo = (struct sec_merge_sec_info *) psecinfo;
 
-  if (offset + addend >= sec->_raw_size)
+  if (offset >= sec->_raw_size)
     {
-      if (offset + addend > sec->_raw_size)
+      if (offset > sec->_raw_size)
        {
          (*_bfd_error_handler)
-           (_("%s: access beyond end of merged section (%ld + %ld)"),
-            bfd_get_filename (sec->owner), (long) offset, (long) addend);
+           (_("%s: access beyond end of merged section (%ld)"),
+            bfd_get_filename (sec->owner), (long) offset);
        }
       return (secinfo->first ? sec->_cooked_size : 0);
     }
@@ -804,15 +804,14 @@ _bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
     {
       if (sec->entsize == 1)
        {
-         p = secinfo->contents + offset + addend - 1;
+         p = secinfo->contents + offset - 1;
          while (p >= secinfo->contents && *p)
            --p;
          ++p;
        }
       else
        {
-         p = secinfo->contents
-             + ((offset + addend) / sec->entsize) * sec->entsize;
+         p = secinfo->contents + (offset / sec->entsize) * sec->entsize;
          p -= sec->entsize;
          while (p >= secinfo->contents)
            {
@@ -830,8 +829,7 @@ _bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
     }
   else
     {
-      p = secinfo->contents
-         + ((offset + addend) / sec->entsize) * sec->entsize;
+      p = secinfo->contents + (offset / sec->entsize) * sec->entsize;
     }
   entry = sec_merge_hash_lookup (secinfo->htab, p, 0, FALSE);
   if (!entry)
@@ -845,9 +843,8 @@ _bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
       if (! secinfo->htab->first)
        abort ();
       entry = secinfo->htab->first;
-      p = secinfo->contents
-         + ((offset + addend) / sec->entsize + 1) * sec->entsize
-         - entry->len;
+      p = (secinfo->contents + (offset / sec->entsize + 1) * sec->entsize
+          - entry->len);
     }
 
   *psec = entry->secinfo->sec;