* elf.c (_bfd_elf_rela_local_sym): Set kept_section for excluded
authorAlan Modra <amodra@gmail.com>
Mon, 3 May 2004 14:52:02 +0000 (14:52 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 3 May 2004 14:52:02 +0000 (14:52 +0000)
SEC_MERGE sections.
* elflink.c (elf_link_input_bfd): Adjust output reloc index for
those against discarded link-once and SEC_MERGE section symbols.

bfd/ChangeLog
bfd/elflink.c

index b5e5523768c0a4679e017b677a43f3c2f49bbf72..e22588861f963d48196e4028e63e16267de5f8f3 100644 (file)
@@ -1,3 +1,10 @@
+2004-05-03  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf.c (_bfd_elf_rela_local_sym): Set kept_section for excluded
+       SEC_MERGE sections.
+       * elflink.c (elf_link_input_bfd): Adjust output reloc index for
+       those against discarded link-once and SEC_MERGE section symbols.
+
 2004-05-02  H.J. Lu  <hongjiu.lu@intel.com>
 
        * section.c (bfd_get_section_by_name_if): New.
index a4adaf52f21989036a54760a62f732b220955098..32f42641689637c73f1573b56aae7df2d06c50b0 100644 (file)
@@ -6763,13 +6763,10 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
                    {
                      /* I suppose the backend ought to fill in the
                         section of any STT_SECTION symbol against a
-                        processor specific section.  If we have
-                        discarded a section, the output_section will
-                        be the absolute section.  */
-                     if (bfd_is_abs_section (sec)
-                         || (sec != NULL
-                             && bfd_is_abs_section (sec->output_section)))
-                       r_symndx = 0;
+                        processor specific section.  */
+                     r_symndx = 0;
+                     if (bfd_is_abs_section (sec))
+                       ;
                      else if (sec == NULL || sec->owner == NULL)
                        {
                          bfd_set_error (bfd_error_bad_value);
@@ -6777,8 +6774,25 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
                        }
                      else
                        {
-                         r_symndx = sec->output_section->target_index;
-                         BFD_ASSERT (r_symndx != 0);
+                         asection *osec = sec->output_section;
+
+                         /* If we have discarded a section, the output
+                            section will be the absolute section.  In
+                            case of discarded link-once and discarded
+                            SEC_MERGE sections, use the kept section.  */
+                         if (bfd_is_abs_section (osec)
+                             && sec->kept_section != NULL
+                             && sec->kept_section->output_section != NULL)
+                           {
+                             osec = sec->kept_section->output_section;
+                             irela->r_addend -= osec->vma;
+                           }
+
+                         if (!bfd_is_abs_section (osec))
+                           {
+                             r_symndx = osec->target_index;
+                             BFD_ASSERT (r_symndx != 0);
+                           }
                        }
 
                      /* Adjust the addend according to where the