This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFC][GOLD] ARM: Add cantunwind when unwind info does not match start of section
- From: Yury Usishchev <y dot usishchev at samsung dot com>
- To: Doug Kwan <dougkwan at google dot com> (éæå)
- Cc: Binutils <binutils at sourceware dot org>
- Date: Tue, 16 Feb 2016 23:28:02 +0300
- Subject: Re: [RFC][GOLD] ARM: Add cantunwind when unwind info does not match start of section
- Authentication-results: sourceware.org; auth=none
- References: <87si0zcudv dot fsf at samsung dot com> <87oabncu8c dot fsf at samsung dot com> <CAJimCsF56-vPj_L32uUy41SaBYN-4cBz4MKT0Cg=Q2uKBw-mZA at mail dot gmail dot com> <87y4aqclft dot fsf at samsung dot com>
Hello Doug!
Could you review this patch?
Original thread can be found here: https://sourceware.org/ml/binutils/2016-02/msg00164.html
I attached the patch here as well.
BR,
Yury Usishchev
>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
Yury Usishchev <y.usishchev@samsung.com> writes:
> 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