This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Fix bug with grouping sections.
- From: Cary Coutant <ccoutant at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 23 Jun 2016 16:46:03 -0000
- Subject: [binutils-gdb] Fix bug with grouping sections.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3ca25b560af813ca576821b500a0f0885829b500
commit 3ca25b560af813ca576821b500a0f0885829b500
Author: Cary Coutant <ccoutant@gmail.com>
Date: Thu Jun 23 09:45:25 2016 -0700
Fix bug with grouping sections.
The fix for PR 15370 did not correctly check all patterns in a group,
but instead threw all unassigned sections into the group. This patch
fixes that.
2016-06-23 Cary Coutant <ccoutant@gmail.com>
Igor Kudrin <ikudrin@accesssoftek.com>
gold/
PR gold/15370
* script-sections.cc
(Output_section_element_input::set_section_addresses): Keep bin_count
separate from input_pattern_count.
* testsuite/script_test_12.t: Add another section .x4.
* testsuite/script_test_12i.t: Likewise.
* testsuite/script_test_12a.c: Likewise.
* testsuite/script_test_12b.c: Likewise.
Diff:
---
gold/ChangeLog | 12 ++++++++++++
gold/script-sections.cc | 13 +++++++------
gold/testsuite/script_test_12.t | 1 +
gold/testsuite/script_test_12a.c | 1 +
gold/testsuite/script_test_12b.c | 1 +
gold/testsuite/script_test_12i.t | 1 +
6 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 012b682..0bf521d 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,15 @@
+2016-06-23 Cary Coutant <ccoutant@gmail.com>
+ Igor Kudrin <ikudrin@accesssoftek.com>
+
+ PR gold/15370
+ * script-sections.cc
+ (Output_section_element_input::set_section_addresses): Keep bin_count
+ separate from input_pattern_count.
+ * testsuite/script_test_12.t: Add another section .x4.
+ * testsuite/script_test_12i.t: Likewise.
+ * testsuite/script_test_12a.c: Likewise.
+ * testsuite/script_test_12b.c: Likewise.
+
2016-06-23 Igor Kudrin <ikudrin@accesssoftek.com>
* gold-threads.cc (impl_threads::Lock_impl_threads): Fix typos.
diff --git a/gold/script-sections.cc b/gold/script-sections.cc
index c42827f..ef82953 100644
--- a/gold/script-sections.cc
+++ b/gold/script-sections.cc
@@ -1595,6 +1595,7 @@ Output_section_element_input::set_section_addresses(
typedef std::vector<std::vector<Input_section_info> > Matching_sections;
size_t input_pattern_count = this->input_section_patterns_.size();
+ size_t bin_count = 1;
bool any_patterns_with_sort = false;
for (size_t i = 0; i < input_pattern_count; ++i)
{
@@ -1602,9 +1603,9 @@ Output_section_element_input::set_section_addresses(
if (isp.sort != SORT_WILDCARD_NONE)
any_patterns_with_sort = true;
}
- if (input_pattern_count == 0 || !any_patterns_with_sort)
- input_pattern_count = 1;
- Matching_sections matching_sections(input_pattern_count);
+ if (any_patterns_with_sort)
+ bin_count = input_pattern_count;
+ Matching_sections matching_sections(bin_count);
// Look through the list of sections for this output section. Add
// each one which matches to one of the elements of
@@ -1661,11 +1662,11 @@ Output_section_element_input::set_section_addresses(
break;
}
- if (i >= this->input_section_patterns_.size())
+ if (i >= input_pattern_count)
++p;
else
{
- if (!any_patterns_with_sort)
+ if (i >= bin_count)
i = 0;
matching_sections[i].push_back(isi);
p = input_sections->erase(p);
@@ -1679,7 +1680,7 @@ Output_section_element_input::set_section_addresses(
// output section.
uint64_t dot = *dot_value;
- for (size_t i = 0; i < input_pattern_count; ++i)
+ for (size_t i = 0; i < bin_count; ++i)
{
if (matching_sections[i].empty())
continue;
diff --git a/gold/testsuite/script_test_12.t b/gold/testsuite/script_test_12.t
index d434f20..4579c58 100644
--- a/gold/testsuite/script_test_12.t
+++ b/gold/testsuite/script_test_12.t
@@ -57,6 +57,7 @@ SECTIONS
test_array_start = .;
*(.x1 .x2 .x3);
test_array_end = .;
+ *(.x4);
}
.bss : { *(.bss) }
diff --git a/gold/testsuite/script_test_12a.c b/gold/testsuite/script_test_12a.c
index 0eed0c2..ed1be68 100644
--- a/gold/testsuite/script_test_12a.c
+++ b/gold/testsuite/script_test_12a.c
@@ -73,3 +73,4 @@ main(void)
int a1[] __attribute((section(".x1"))) = { 0x01, 0x02, 0x03, 0x04 };
int a2[] __attribute((section(".x2"))) = { 0x11, 0x12, 0x13, 0x14};
int a3[] __attribute((section(".x3"))) = { 0x21, 0x22, 0x23, 0x24 };
+int a4[] __attribute((section(".x4"))) = { 0xff, 0xff, 0xff, 0xff };
diff --git a/gold/testsuite/script_test_12b.c b/gold/testsuite/script_test_12b.c
index a69866e..e31f73d 100644
--- a/gold/testsuite/script_test_12b.c
+++ b/gold/testsuite/script_test_12b.c
@@ -1,3 +1,4 @@
int b1[] __attribute((section(".x1"))) = { 0x85, 0x86, 0x87, 0x88 };
int b2[] __attribute((section(".x2"))) = { 0x95, 0x96, 0x97, 0x98 };
int b3[] __attribute((section(".x3"))) = { 0xa5, 0xa6, 0xa7, 0xa8 };
+int b4[] __attribute((section(".x4"))) = { 0xff, 0xff, 0xff, 0xff };
diff --git a/gold/testsuite/script_test_12i.t b/gold/testsuite/script_test_12i.t
index 8d6183a..af19cd6 100644
--- a/gold/testsuite/script_test_12i.t
+++ b/gold/testsuite/script_test_12i.t
@@ -57,6 +57,7 @@ SECTIONS
test_array_start = .;
*(.x1) *(.x2) *(.x3)
test_array_end = .;
+ *(.x4);
}
.bss : { *(.bss) }