diff mbox series

Add order verification

Message ID 20200801155914.GA92020@kam.mff.cuni.cz
State New
Headers show
Series Add order verification | expand

Commit Message

Jan Hubicka Aug. 1, 2020, 3:59 p.m. UTC
Hi,
while looking into the chromium build issue I noticed that order can get
pretty large.  This patch adds checking so we know if it ever overflows
or if someone uses it incorrectly (the second is important since one
uninitialized order may disturb lto streaming)

Honza

gcc/ChangeLog:

2020-08-01  Jan Hubicka  <hubicka@ucw.cz>

	* symtab.c (symtab_node::verify_base): Verify order.
	(symtab_node::verify_symtab_nodes): Verify order.
diff mbox series

Patch

diff --git a/gcc/symtab.c b/gcc/symtab.c
index 0e852d4c24d..d7dfbb676df 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -1085,6 +1085,11 @@  symtab_node::verify_base (void)
       error ("node has unknown type");
       error_found = true;
     }
+  if (order < 0 || order >= symtab->order)
+    {
+      error ("node has invalid order %i", order);
+      error_found = true;
+    }
    
   if (symtab->state != LTO_STREAMING)
     {
@@ -1326,6 +1331,14 @@  symtab_node::verify_symtab_nodes (void)
 {
   symtab_node *node;
   hash_map<tree, symtab_node *> comdat_head_map (251);
+  asm_node *anode;
+
+  for (anode = symtab->first_asm_symbol (); anode; anode = anode->next)
+    if (anode->order < 0 || anode->order >= symtab->order)
+       {
+	  error ("invalid order in asm node %i", anode->order);
+	  internal_error ("symtab_node::verify failed");
+       }
 
   FOR_EACH_SYMBOL (node)
     {