Fix xtensa ld segfault when linking linux modules
authorMax Filippov <jcmvbkbc@gmail.com>
Wed, 9 Jul 2014 21:47:33 +0000 (01:47 +0400)
committerMax Filippov <jcmvbkbc@gmail.com>
Thu, 10 Jul 2014 15:22:07 +0000 (19:22 +0400)
is_inconsistent_linkonce_section makes an assumption that section name
that starts with ".gnu.linkonce.prop." has one more dot in its suffix.
However gas generates such section name by insertion of "prop." right
after ".gnu.linkonce." part of the name of the original section. So, for
section named ".gnu.linkonce.this_module" corresponding property section
name does not satisfy the assumption. Such section names are common in
linux modules. This bug was exposed by the patch "a35d5e8 Fix alignment
for the first section frag on xtensa", that makes gas produce property
section for each section that has ".align" directive in it.

Use suffix that immediately follows ".gnu.linkonce.prop." when there are
no more dots following it.

2014-07-10  Max Filippov  <jcmvbkbc@gmail.com>

ld/
    * emultempl/xtensaelf.em (is_inconsistent_linkonce_section):
    correctly handle missing dot in section name after
    ".gnu.linkonce.prop.".

ld/ChangeLog
ld/emultempl/xtensaelf.em

index 279ece8..a39e29e 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-10  Max Filippov  <jcmvbkbc@gmail.com>
+
+       * emultempl/xtensaelf.em (is_inconsistent_linkonce_section):
+       correctly handle missing dot in section name after
+       ".gnu.linkonce.prop.".
+
 2014-07-08  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
        * scripttempl/avr.sc: Remove KEEP for .data and
index 151eea4..948d18d 100644 (file)
@@ -1310,7 +1310,7 @@ is_inconsistent_linkonce_section (asection *sec)
      for Tensilica's XCC compiler.  */
   name = sec_name + linkonce_len;
   if (CONST_STRNEQ (name, "prop."))
-    name = strchr (name + 5, '.') + 1;
+    name = strchr (name + 5, '.') ? strchr (name + 5, '.') + 1 : name + 5;
   else if (name[1] == '.'
           && (name[0] == 'p' || name[0] == 'e' || name[0] == 'h'))
     name += 2;