* elf32-s390.c (elf_s390_relocate_section): Don't recalculate symbol
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 20 Nov 2003 09:54:07 +0000 (09:54 +0000)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 20 Nov 2003 09:54:07 +0000 (09:54 +0000)
section for reloc output and subtract the output section's address
from the addend when converting a relocation into one against a
section symbol.
* elf64-s390.c (elf_s390_relocate_section): Likewise.

bfd/ChangeLog
bfd/elf32-s390.c
bfd/elf64-s390.c

index 11f75b2cf806fbdd6413a072f9f52a7323d49319..ad3d9ac726aa7486f4c68ad78567b2d9f24a4aa9 100644 (file)
@@ -1,3 +1,11 @@
+2003-11-20  Martin Schwidefsky  <schwidefsky@de.ibm.com>
+
+       * elf32-s390.c (elf_s390_relocate_section): Don't recalculate symbol
+       section for reloc output and subtract the output section's address
+       from the addend when converting a relocation into one against a
+       section symbol.
+       * elf64-s390.c (elf_s390_relocate_section): Likewise.
+
 2003-11-18  James E Wilson  <wilson@specifixinc.com>
 
        * elfxx-ia64.c (get_fptr): For fptr_rel, use dynobj not abfd.
index 32bf8bf1aeaf7426fb335b71e26c924df8f1c61d..189c828aa627cd4b771f73257ed12288483b9bf4 100644 (file)
@@ -2627,26 +2627,17 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
              else
                {
                  /* This symbol is local, or marked to become local.  */
+                 outrel.r_addend = relocation + rel->r_addend;
                  if (r_type == R_390_32)
                    {
                      relocate = TRUE;
                      outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
-                     outrel.r_addend = relocation + rel->r_addend;
                    }
                  else
                    {
                      long sindx;
 
-                     if (h == NULL)
-                       sec = local_sections[r_symndx];
-                     else
-                       {
-                         BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                     || (h->root.type
-                                         == bfd_link_hash_defweak));
-                         sec = h->root.u.def.section;
-                       }
-                     if (sec != NULL && bfd_is_abs_section (sec))
+                     if (bfd_is_abs_section (sec))
                        sindx = 0;
                      else if (sec == NULL || sec->owner == NULL)
                        {
@@ -2660,9 +2651,16 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
                          osec = sec->output_section;
                          sindx = elf_section_data (osec)->dynindx;
                          BFD_ASSERT (sindx > 0);
+
+                         /* We are turning this relocation into one
+                            against a section symbol, so subtract out
+                            the output section's address but not the
+                            offset of the input section in the output
+                            section.  */
+
+                         outrel.r_addend -= osec->vma;
                        }
                      outrel.r_info = ELF32_R_INFO (sindx, r_type);
-                     outrel.r_addend = relocation + rel->r_addend;
                    }
                }
 
index 8b521be6336e1e3d3914fc690e2e23b95127e648..e14a0fc4c7952f38a0c14e4b5da8117fcc8c1390 100644 (file)
@@ -2606,26 +2606,17 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
              else
                {
                  /* This symbol is local, or marked to become local.  */
+                 outrel.r_addend = relocation + rel->r_addend;
                  if (r_type == R_390_64)
                    {
                      relocate = TRUE;
                      outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
-                     outrel.r_addend = relocation + rel->r_addend;
                    }
                  else
                    {
                      long sindx;
 
-                     if (h == NULL)
-                       sec = local_sections[r_symndx];
-                     else
-                       {
-                         BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                     || (h->root.type
-                                         == bfd_link_hash_defweak));
-                         sec = h->root.u.def.section;
-                       }
-                     if (sec != NULL && bfd_is_abs_section (sec))
+                     if (bfd_is_abs_section (sec))
                        sindx = 0;
                      else if (sec == NULL || sec->owner == NULL)
                        {
@@ -2639,9 +2630,16 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
                          osec = sec->output_section;
                          sindx = elf_section_data (osec)->dynindx;
                          BFD_ASSERT (sindx > 0);
+
+                         /* We are turning this relocation into one
+                            against a section symbol, so subtract out
+                            the output section's address but not the
+                            offset of the input section in the output
+                            section.  */
+
+                         outrel.r_addend -= osec->vma;
                        }
                      outrel.r_info = ELF64_R_INFO (sindx, r_type);
-                     outrel.r_addend = relocation + rel->r_addend;
                    }
                }