http://sourceware.org/bugzilla/show_bug.cgi?id=13899

Jan Waclawek <konfera at efton dot sk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |konfera at efton dot sk

--- Comment #4 from Jan Waclawek <konfera at efton dot sk> 2012-05-09 07:59:38 
UTC ---
During relax, if a call is shrunk to rcall, the relocs are modified accordingly
in elf32_avr_relax_delete_bytes(). This assumes that the relocs in case are
permanently kept in memory, which apparently ceased to be the case somewhere
between version 2.21 and 2.22 for reasons to me unknown. This has been noticed
also as http://sourceware.org/bugzilla/show_bug.cgi?id=13612, but "fix" for
http://sourceware.org/bugzilla/show_bug.cgi?id=12161 covered this up, by
loading the relocs, but they were not loaded permanently (keep-memory parameter
is FALSE).

Note that this did not occur with avr6 architecture, where stubs section is
created (unless --no-stubs is used); again I don't quite understand the
mechanisms behind this (sidenote: gs() is not appropriate for avr5
architecture).

The remedy is again surprisingly simple: _bfd_elf_link_read_relocs() has to be
called with keep-memory TRUE. (The below patch removes also the unneeded free()
and adds a couple of diagnostic printouts). While will probably increase memory
usage, in typical programs where multiple shrinks occur it should decrease the
linking time.

--- ../../elf32-avr.c    Mon May  7 05:27:50 2012
+++ elf32-avr.c    Wed May  9 09:12:47 2012
@@ -1513,7 +1513,11 @@
        irel = elf_section_data (isec)->relocs;
        /* PR 12161: Read in the relocs for this section if necessary.  */
        if (irel == NULL)
-     irel = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL, FALSE);
+       {
+         irel = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL, TRUE);
+         if (debug_relax)
+           printf ("Relocs read in for %sec \n", isec->name);
+       }

        for (irelend = irel + isec->reloc_count;
             irel < irelend;
@@ -1573,8 +1577,6 @@
           the addend.  */
      }

-       if (elf_section_data (isec)->relocs == NULL)
-     free (irelend - isec->reloc_count);
      }
   }

@@ -2276,6 +2278,8 @@
   return TRUE;

  error_return:
+  if (debug_relax)
+    printf ("Something went wrong during relaxing...\n");
   if (isymbuf != NULL
       && symtab_hdr->contents != (unsigned char *) isymbuf)
     free (isymbuf);

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to