summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2018-05-15 08:34:29 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2018-05-15 08:34:29 +0000
commit7be3817f26f6b284f0c5a14ac6794240a003cf51 (patch)
tree7d20c11e108ec76106ab8a2dc22906511d9a6d0a
parentd51fd3fc496fbf4e9a1a578539adceab056c8869 (diff)
DWARF calculate the number of indexed addresses.
The length in the .debug_addr unit header was calculated using the number of elements in the addr_index_table. This is wrong because the entries in the table are refcounted and only those with a refcount > 0 are actually put in the index. Add a helper function count_index_addrs to get the correct number of addresses in the index. gcc/ChangeLog: * dwarf2out.c (count_index_addrs): New function. (dwarf2out_finish): Use count_index_addrs to calculate addrs_length. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@260251 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/dwarf2out.c21
2 files changed, 24 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 17f2cfd3ec18..7e145f4c7e87 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-14 Mark Wielaard <mark@klomp.org>
+
+ * dwarf2out.c (count_index_addrs): New function.
+ (dwarf2out_finish): Use count_index_addrs to calculate addrs_length.
+
2018-05-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/83648
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index a92b0ce0b98c..7ced2b181951 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -28820,6 +28820,19 @@ output_addr_table_entry (addr_table_entry **slot, unsigned int *cur_index)
return 1;
}
+/* A helper function for dwarf2out_finish. Counts the number
+ of indexed addresses. Must match the logic of the functions
+ output_addr_table_entry above. */
+int
+count_index_addrs (addr_table_entry **slot, unsigned int *last_idx)
+{
+ addr_table_entry *entry = *slot;
+
+ if (entry->refcount > 0)
+ *last_idx += 1;
+ return 1;
+}
+
/* Produce the .debug_addr section. */
static void
@@ -31306,8 +31319,12 @@ dwarf2out_finish (const char *)
DWARF5 specifies a small header when address tables are used. */
if (dwarf_version >= 5)
{
- unsigned long addrs_length
- = addr_index_table->elements () * DWARF2_ADDR_SIZE + 4;
+ unsigned int last_idx = 0;
+ unsigned long addrs_length;
+
+ addr_index_table->traverse_noresize
+ <unsigned int *, count_index_addrs> (&last_idx);
+ addrs_length = last_idx * DWARF2_ADDR_SIZE + 4;
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,