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]

Re: [RFC][GOLD] ARM: Add cantunwind when unwind info does not match start of section


Hello!

Thanks for the explanation.

> +      if (first_word)
>
> When the condition is not a bool, I prefer using "!= 0".
Done.

BR,
Yury Usishchev

gold/
2016-02-11 Yury Usishchev <y.usishchev@samsung.com>

	PR gold/19611
	* arm.cc (fix_exidx_coverage): Insert cantunwind when address in
	first unwind entry does not match start of section.
	* testsuite/Makefile.am (arm_exidx_test.stdout): Add dump of unwind info
	* testsuite/Makefile.in: Regenerate
	* testsuite/arm_exidx_test.c: Add sections to test unwind info merging
	* testsuite/arm_exidx_test.sh: Add check for correct unwind info merging
>From 1d2f13e866ec3f636fef3cbf8a0f649c4d08ebba Mon Sep 17 00:00:00 2001
From: Yury Usishchev <y.usishchev@samsung.com>
Date: Wed, 10 Feb 2016 20:16:48 +0300
Subject: [PATCH] ARM: Add cantunwind when unwind info does not match start of
 section

---
 gold/arm.cc                      | 13 +++++++++++++
 gold/testsuite/Makefile.am       |  2 +-
 gold/testsuite/Makefile.in       |  2 +-
 gold/testsuite/arm_exidx_test.s  | 32 ++++++++++++++++++++++++++++++++
 gold/testsuite/arm_exidx_test.sh |  2 ++
 5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/gold/arm.cc b/gold/arm.cc
index ed13c87..dab062f 100644
--- a/gold/arm.cc
+++ b/gold/arm.cc
@@ -6022,6 +6022,19 @@ Arm_output_section<big_endian>::fix_exidx_coverage(
       const unsigned char* exidx_contents =
 	exidx_relobj->section_contents(exidx_shndx, &exidx_size, false);
 
+      // first_word is start address of first unwind entry in current input
+      // section.  If first_word is not zero then unwind info in this section
+      // does not cover start of section.  In this case we may need to add
+      // cantunwind to have consistent unwind info in output.
+      typedef typename elfcpp::Swap<32, big_endian>::Valtype Valtype;
+      const Valtype* wv = reinterpret_cast<const Valtype*>(exidx_contents);
+      uint32_t first_word = elfcpp::Swap<32, big_endian>::readval(wv);
+      if (first_word != 0)
+	{
+	  exidx_fixup.add_exidx_cantunwind_as_needed();
+	}
+
+
       // Fix up coverage and append input section to output data list.
       Arm_exidx_section_offset_map* section_offset_map = NULL;
       uint32_t deleted_bytes =
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index ca24205..98c5e96 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -3238,7 +3238,7 @@ check_SCRIPTS += arm_exidx_test.sh
 check_DATA += arm_exidx_test.stdout
 
 arm_exidx_test.stdout: arm_exidx_test.so
-	$(TEST_READELF) -Sr $< > $@
+	$(TEST_READELF) -Sru $< > $@
 
 arm_exidx_test.so: arm_exidx_test.o ../ld-new
 	../ld-new -shared -o $@ $<
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 253493f..4b61208 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -6781,7 +6781,7 @@ uninstall-am:
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	$(TEST_AS) -o $@ $<
 
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_exidx_test.stdout: arm_exidx_test.so
-@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	$(TEST_READELF) -Sr $< > $@
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	$(TEST_READELF) -Sru $< > $@
 
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_exidx_test.so: arm_exidx_test.o ../ld-new
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	../ld-new -shared -o $@ $<
diff --git a/gold/testsuite/arm_exidx_test.s b/gold/testsuite/arm_exidx_test.s
index 8e550e4..13f7d8b 100644
--- a/gold/testsuite/arm_exidx_test.s
+++ b/gold/testsuite/arm_exidx_test.s
@@ -23,6 +23,38 @@ empty:
         .fnend
         .size   empty, .-empty
 
+	.section        .text.start,"ax",%progbits
+	.align	2
+	.global start
+	.type start, %function
+start:
+	bx lr
+
+	.global	start1
+	.type	start1, %function
+start1:
+	.fnstart
+	.save {r4, lr}
+	.vsave {d0}
+	.vsave {d4}
+	bx lr
+	.fnend
+
+	.section        .text.end,"ax",%progbits
+	.align	2
+	.global end
+	.type end, %function
+end:
+	bx lr
+
+	.global another
+	.type another, %function
+another:
+	.fnstart
+	.save {r4, lr}
+	bx lr
+	.fnend
+
 # Check that no dynamic relocations for __exidx_start and __exidx_stop
 # generated.
 	.data
diff --git a/gold/testsuite/arm_exidx_test.sh b/gold/testsuite/arm_exidx_test.sh
index 699bdd1..6e8ae1a 100755
--- a/gold/testsuite/arm_exidx_test.sh
+++ b/gold/testsuite/arm_exidx_test.sh
@@ -56,5 +56,7 @@ check arm_exidx_test.stdout ".* .ARM.exidx .* ARM_EXIDX .* AL .*"
 check arm_exidx_test.stdout ".* .ARM.extab .* PROGBITS .* A .*"
 check_not arm_exidx_test.stdout ".* .* R_ARM_GLOB_DAT .* __exidx_start"
 check_not arm_exidx_test.stdout ".* .* R_ARM_GLOB_DAT .* __exidx_end"
+check arm_exidx_test.stdout ".*end.*cantunwind.*"
+check_not arm_exidx_test.stdout ".*start.*cantunwind.*"
 
 exit 0
-- 
2.7.1


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