This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2] ARM: Fix elf32_arm_count_additional_relocs


---
 bfd/elf32-arm.c                 | 2 +-
 ld/ChangeLog                    | 7 +++++++
 ld/testsuite/ld-arm/arm-elf.exp | 8 ++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 3d4a458..5041dab 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -18172,7 +18172,7 @@ elf32_arm_count_additional_relocs (asection *sec)
 {
   struct _arm_elf_section_data *arm_data;
   arm_data = get_arm_elf_section_data (sec);
-  return arm_data->additional_reloc_count;
+  return arm_data ? arm_data->additional_reloc_count : 0;
 }
 
 /* Called to set the sh_flags, sh_link and sh_info fields of OSECTION which
diff --git a/ld/ChangeLog b/ld/ChangeLog
index a251a21..f1574ef 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2016-09-23  Akihiko Odaki  <akihiko.odaki.4i@stu.hosei.ac.jp>
+
+	* elf32-arm.c (elf32_arm_count_additional_relocs): Check if the section
+	data exists.
+	* testsuite/arm-elf.exp: Expect to link even section without the section
+	data.
+
 2016-09-06  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
 	Backport from mainline
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index a5d4c87..063abd3 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -989,3 +989,11 @@ set arm_unwind_tests {
      "unwind-mix"}
 }
 run_ld_link_tests $arm_unwind_tests
+
+# Link section without a section data. Binary (-b binary) should not have a
+# section data and incremental linking (-r) will prevent from adding one.
+# Such a case should be concerned to eliminate the wrong assumption that the
+# section data always exists.
+if { ![ld_simple_link $ld raw "-b binary -r $srcdir/$subdir/arm-elf.exp"] } {
+    fail "raw section linking"
+}
-- 
2.9.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]