Do away with hash table line lookup in dwarf2dbg.c
authorAlan Modra <amodra@gmail.com>
Sat, 27 Sep 2014 02:54:32 +0000 (12:24 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 27 Sep 2014 06:48:30 +0000 (16:18 +0930)
Hash lookup is silly when we can attach the line table info directly
to sections instead.  Worse, hash lookup fails when we have multiple
sections with the same name.

gas/
* dwarf2dbg.c (all_segs_hash): Delete.
(get_line_subseg): Delete last_seg, last_subseg, last_line_subseg.
Retrieve line_seg for section via seg_info.
* subsegs.h (segment_info_typet): Add dwarf2_line_seg.
gas/testsuite/
* gas/elf/group2.d, * gas/elf/group2.s: New test.
* gas/elf/elf.exp: Run it.

gas/ChangeLog
gas/dwarf2dbg.c
gas/subsegs.h
gas/testsuite/ChangeLog
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/group2.d [new file with mode: 0644]
gas/testsuite/gas/elf/group2.s [new file with mode: 0644]

index 7471e5389e9a958397b35bb446909a45d4a87283..ec11c6347784c7615130f5aa18bb4ea721339c9c 100644 (file)
@@ -1,3 +1,10 @@
+2014-09-27  Alan Modra  <amodra@gmail.com>
+
+       * dwarf2dbg.c (all_segs_hash): Delete.
+       (get_line_subseg): Delete last_seg, last_subseg, last_line_subseg.
+       Retrieve line_seg for section via seg_info.
+       * subsegs.h (segment_info_typet): Add dwarf2_line_seg.
+
 2014-09-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gas/17421
index 5cc466237c84af22b3ccedd0f12fbf564e605aec..3067b8c24b40440f2d70b4cb543574d64e46472f 100644 (file)
@@ -186,9 +186,6 @@ struct line_seg {
 
 /* Collects data for all line table entries during assembly.  */
 static struct line_seg *all_segs;
-/* Hash used to quickly lookup a segment by name, avoiding the need to search
-   through the all_segs list.  */
-static struct hash_control *all_segs_hash;
 static struct line_seg **last_seg_ptr;
 
 struct file_entry {
@@ -248,17 +245,9 @@ generic_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
 static struct line_subseg *
 get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p)
 {
-  static segT last_seg;
-  static subsegT last_subseg;
-  static struct line_subseg *last_line_subseg;
-
-  struct line_seg *s;
+  struct line_seg *s = seg_info (seg)->dwarf2_line_seg;
   struct line_subseg **pss, *lss;
 
-  if (seg == last_seg && subseg == last_subseg)
-    return last_line_subseg;
-
-  s = (struct line_seg *) hash_find (all_segs_hash, seg->name);
   if (s == NULL)
     {
       if (!create_p)
@@ -270,7 +259,7 @@ get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p)
       s->head = NULL;
       *last_seg_ptr = s;
       last_seg_ptr = &s->next;
-      hash_insert (all_segs_hash, seg->name, s);
+      seg_info (seg)->dwarf2_line_seg = s;
     }
   gas_assert (seg == s->seg);
 
@@ -291,10 +280,6 @@ get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p)
   *pss = lss;
 
  found_subseg:
-  last_seg = seg;
-  last_subseg = subseg;
-  last_line_subseg = lss;
-
   return lss;
 }
 
@@ -1847,7 +1832,6 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
 void
 dwarf2_init (void)
 {
-  all_segs_hash = hash_new ();
   last_seg_ptr = &all_segs;
 }
 
index e3ba8c7027eb98beb045a9849e10511167f686d1..8b2fd098ae1081bbb25a9a66af9b2bdec60fd44d 100644 (file)
@@ -90,6 +90,9 @@ typedef struct segment_info_struct {
      this section.  sym->bsym and bfd_section->symbol should be the same.  */
   symbolS *sym;
 
+  /* Used by dwarf2dbg.c for this section's line table entries.  */
+  void *dwarf2_line_seg;
+
   union {
     /* Current size of section holding stabs strings.  */
     unsigned long stab_string_size;
index e740c02a4ed611045b204df0dd36e9337cf94eea..5d74ceaacec02923b2399eb61b9e904c7bfa25db 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-27  Alan Modra  <amodra@gmail.com>
+
+       * gas/elf/group2.d, * gas/elf/group2.s: New test.
+       * gas/elf/elf.exp: Run it.
+
 2014-09-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gas/17421
index f17f7e00b3e8ff6ff65611636799dc215430b32c..af5dbb2a6a25a0cc5feddfd0e722a9417ee1f2ef 100644 (file)
@@ -110,6 +110,7 @@ if { [is_elf_format] } then {
     run_dump_test "group0c"
     run_dump_test "group1a"
     run_dump_test "group1b"
+    run_dump_test "group2"
     case $target_triplet in {
        { hppa64*-*-hpux* } { }
        default {
diff --git a/gas/testsuite/gas/elf/group2.d b/gas/testsuite/gas/elf/group2.d
new file mode 100644 (file)
index 0000000..1cea13c
--- /dev/null
@@ -0,0 +1,12 @@
+#readelf: -SW
+#name: debug info in group section and non-group section with same name
+#source: group2.s
+# The RX port uses non-standard section names.
+#not-target: rx-*
+
+#...
+[      ]*\[.*\][       ]+\.group[      ]+GROUP.*
+#...
+[      ]*\[.*\][       ]+\.text\.startup[      ]+PROGBITS.*[   ]+AXG[  ]+.*
+[      ]*\[.*\][       ]+\.text\.startup[      ]+PROGBITS.*[   ]+AX[   ]+.*
+#pass
diff --git a/gas/testsuite/gas/elf/group2.s b/gas/testsuite/gas/elf/group2.s
new file mode 100644 (file)
index 0000000..1e1c951
--- /dev/null
@@ -0,0 +1,9 @@
+ .file 1 "test.c"
+
+ .section .text.startup,"axG",%progbits,test,comdat
+ .loc 1 1
+ .org 8
+
+ .section .text.startup,"ax",%progbits
+ .loc 1 1
+ .org 8
This page took 0.0298 seconds and 4 git commands to generate.