This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH v2] ARM: Fix elf32_arm_count_additional_relocs
- From: Akihiko Odaki <akihiko dot odaki dot 4i at stu dot hosei dot ac dot jp>
- To: binutils at sourceware dot org
- Cc: Renlin Li <renlin dot li at foss dot arm dot com>, Paul Brook <paul at codesourcery dot com>, Yury Usishchev <y dot usishchev at samsung dot com>, Nicholas Clifton <nickc at redhat dot com>, Richard Earnshaw <Richard dot Earnshaw at arm dot com>, Akihiko Odaki <akihiko dot odaki dot 4i at stu dot hosei dot ac dot jp>
- Date: Fri, 23 Sep 2016 13:39:36 +0900
- Subject: [PATCH v2] ARM: Fix elf32_arm_count_additional_relocs
- Authentication-results: sourceware.org; auth=none
- Authentication-results: mailgw04.hosei.ac.jp; sender-id=none header.from=akihiko dot odaki dot 4i at stu dot hosei dot ac dot jp; spf=none smtp.mfrom=akihiko dot odaki dot 4i at stu dot hosei dot ac dot jp
- References: <20160922015207.24667-1-akihiko.odaki.4i@stu.hosei.ac.jp>
---
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