2011-04-18 Kai Tietz <ktietz@redhat.com>
authorKai Tietz <kai.tietz@onevision.com>
Mon, 18 Apr 2011 15:40:27 +0000 (15:40 +0000)
committerKai Tietz <kai.tietz@onevision.com>
Mon, 18 Apr 2011 15:40:27 +0000 (15:40 +0000)
        * deffilep.y (def_aligncomm): Avoid duplets.

ld/ChangeLog
ld/deffilep.y

index d2db3fd00f5c5cfd8c2e291ef42997ad7c9657ca..26164a9a794a72c6992e00c77b1ab95b36c5ac0a 100644 (file)
@@ -1,5 +1,7 @@
 2011-04-18  Kai Tietz  <ktietz@redhat.com>
 
+       * deffilep.y (def_aligncomm): Avoid duplets.
+
        * deffilep.y (def_pool_str): New type.
        (pool_strs): Local static.
        (def_pool_alloc): Local function.
index c1c95d2872ecca1f3baa33d4fac4f9764c80ff7f..58f3dd27b78bd54fe62504fb7f5ec1422c1a31b8 100644 (file)
@@ -1095,13 +1095,39 @@ def_directive (char *str)
 static void
 def_aligncomm (char *str, int align)
 {
-  def_file_aligncomm *c = xmalloc (sizeof (def_file_aligncomm));
+  def_file_aligncomm *c, *p;
+  
+  p = NULL;
+  c = def->aligncomms;
+  while (c != NULL)
+    {
+      int e = strcmp (c->symbol_name, str);
+      if (!e)
+       {
+         /* Not sure if we want to allow here duplicates with
+            different alignments, but for now we keep them.  */
+         e = (int) c->alignment - align;
+         if (!e)
+           return;
+       }
+      if (e > 0)
+        break;
+      c = (p = c)->next;
+    }
 
+  c = xmalloc (sizeof (def_file_aligncomm));
   c->symbol_name = xstrdup (str);
   c->alignment = (unsigned int) align;
-
-  c->next = def->aligncomms;
-  def->aligncomms = c;
+  if (!p)
+    {
+      c->next = def->aligncomms;
+      def->aligncomms = c;
+    }
+  else
+    {
+      c->next = p->next;
+      p->next = c;
+    }
 }
 
 static int