OSDN Git Service

* merge.c (_bfd_merged_section_offset): Remove "addend" param.
authoramodra <amodra>
Sat, 22 May 2004 01:56:30 +0000 (01:56 +0000)
committeramodra <amodra>
Sat, 22 May 2004 01:56:30 +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 824a23c..e78e132 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 0317e35..e5ab09e 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 bdd3450..980dcb9 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 01c66b5..21785d5 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 cee5909..37540aa 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 20d9083..26b2e45 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 6d3a335..956727d 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 86819ff..96776ca 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 89f45cd..3811523 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;