This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Xtensa] fix missing .gnu.linkonce.p.* sections


I've committed this patch to fix a problem regarding Xtensa property tables in the change from 2006-04-14. The previous code worked correctly for ".gnu.linkonce.prop.*" sections, but for the older-style ".gnu.linkonce.p.*" sections, it failed to allocate enough space for the name of the corresponding ".gnu.linkonce.t.*" section and it was missing the ".t" in that name. Because the section names were wrong, the ".p" sections were always being found inconsistent and removed.

Tested for regressions by running the testsuite for an xtensa-linux target.

2006-07-24 Bob Wilson <bob.wilson@acm.org>

	* emultempl/xtensaelf.em (is_inconsistent_linkonce_section): Add space
	in dep_sec_name for null terminator.  Make sure dep_sec_name has a
	".t" linkonce tag.

Index: emultempl/xtensaelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/xtensaelf.em,v
retrieving revision 1.12
diff -u -p -r1.12 xtensaelf.em
--- emultempl/xtensaelf.em	14 Apr 2006 21:31:16 -0000	1.12
+++ emultempl/xtensaelf.em	25 Jul 2006 00:10:07 -0000
@@ -1200,7 +1200,7 @@ is_inconsistent_linkonce_section (asecti
 {
   bfd *abfd = sec->owner;
   const char *sec_name = bfd_get_section_name (abfd, sec);
-  char *prop_tag = 0;
+  const char *name = 0;
 
   if ((bfd_get_section_flags (abfd, sec) & SEC_LINK_ONCE) == 0
       || strncmp (sec_name, ".gnu.linkonce.", linkonce_len) != 0)
@@ -1208,20 +1208,20 @@ is_inconsistent_linkonce_section (asecti
 
   /* Check if this is an Xtensa property section.  */
   if (strncmp (sec_name + linkonce_len, "p.", 2) == 0)
-    prop_tag = "p.";
+    name = sec_name + linkonce_len + 2;
   else if (strncmp (sec_name + linkonce_len, "prop.", 5) == 0)
-    prop_tag = "prop.";
-  if (prop_tag)
+    name = strchr (sec_name + linkonce_len + 5, '.') + 1;
+
+  if (name)
     {
-      int tag_len = strlen (prop_tag);
-      char *dep_sec_name = xmalloc (strlen (sec_name));
+      char *dep_sec_name = xmalloc (strlen (sec_name) + 1);
       asection *dep_sec;
 
       /* Get the associated linkonce text section and check if it is
 	 included in the link.  If not, this section is inconsistent
 	 and should be stripped.  */
-      strcpy (dep_sec_name, ".gnu.linkonce.");
-      strcat (dep_sec_name, sec_name + linkonce_len + tag_len);
+      strcpy (dep_sec_name, ".gnu.linkonce.t.");
+      strcat (dep_sec_name, name);
       dep_sec = bfd_get_section_by_name (abfd, dep_sec_name);
       if (dep_sec == NULL || ! input_section_linked (dep_sec))
 	{

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]