Skip to contentSkip to conversation

package/elf2flt: .ARM.exidx RO data section is incorrectly mapped to data

PATCH New Romain Naour 3 participants 3 messages Nov 6, 2019 – Nov 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/elf2flt: .ARM.exidx RO data section is incorrectly mapped to data

Starting with Binutils 2.33.1, elf2flt segfault while building busybox:
"ld (ld-elf2flt):
/opt/armv7m--uclibc--bleeding-edge-2/arm-buildroot-uclinux-uclibcgnueabi/bin/elf2flt

This was reported to the Binutils mailing list and it's seems an elf2flt issue with .ARM.exidx RO data section as explained
by: https://sourceware.org/ml/binutils/2019-10/msg00132.html

Apply the patch provided by Greg Ungerer [1] and tested by Christophe Priouzeau using stm32f469_disco_defconfig on stm32f469-disco board.

Fixes:
https://gitlab.com/kubu93/toolchains-builder/-/jobs/319395300

[1] https://github.com/uclinux-dev/elf2flt/issues/12

Cc Christophe Priouzeau <[email protected]>
---
 ...t-fix-relocations-for-read-only-data.patch | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 package/elf2flt/0002-elf2flt-fix-relocations-for-read-only-data.patch
package/elf2flt/0002-elf2flt-fix-relocations-for-read-only-data.patch new file +58 -0
new file mode 100644
index 0000000000..6cb3a55433
@@ -0,0 +1,58 @@
+From 6006e8d789f7a1129414fb3a8c930b094af0cafa Mon Sep 17 00:00:00 2001
+From: Greg Ungerer <[email protected]>
+Date: Wed, 6 Nov 2019 21:19:24 +0100
+Subject: [PATCH] elf2flt: fix relocations for read-only data
+
+Readonly data sections are mapped into the "text" section in the
+elf2flt.ld linker script. The relocation generation code is not handling
+that case properly though, and is actually mapping any data section type
+into the "data" section of the target binary.
+
+This problem case has been detected with elf2flt core dumping when used
+with binutils-2.33.1 (on ARM architecture targets). See thread at:
+
+   https://sourceware.org/ml/binutils/2019-10/msg00132.html
+
+Tested by Christophe Priouzeau [1]
+
+* binutils 2.33.1
+* buildroot 2019.11-rc1
+* patch on top of elf2flt (patch available on this thread)
+* configuration: stm32f469-disco with initramfs configuration on buildroot
+
+Result:
+Build: OK, all the binaries are generated
+Runtime test on stm32f469-disco: OK
+
+[1] https://github.com/uclinux-dev/elf2flt/issues/12
+
+Signed-off-by: Greg Ungerer <[email protected]>
+Signed-off-by: Romain Naour <[email protected]>
+Cc: Christophe Priouzeau <[email protected]>
+---
+ elf2flt.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/elf2flt.c b/elf2flt.c
+index 67f720a..8973cef 100644
+--- a/elf2flt.c
++++ b/elf2flt.c
+@@ -418,10 +418,12 @@ output_relocs (
+ //		continue;
+ 
+ 	/*
+-	 *	Only relocate things in the data sections if we are PIC/GOT.
+-	 *	otherwise do text as well
++	 * Only relocate things in the writable data sections if we are PIC/GOT.
++	 * Otherwise do text (and read only data) as well.
+ 	 */
+-	if ((!pic_with_got || ALWAYS_RELOC_TEXT) && (a->flags & SEC_CODE))
++	if ((!pic_with_got || ALWAYS_RELOC_TEXT) &&
++	    ((a->flags & SEC_CODE) ||
++	    ((a->flags & (SEC_DATA | SEC_READONLY)) == (SEC_DATA | SEC_READONLY))))
+ 		sectionp = text + (a->vma - text_vma);
+ 	else if (a->flags & SEC_DATA)
+ 		sectionp = data + (a->vma - data_vma);
+-- 
+2.21.0
+
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 package/elf2flt: .ARM.exidx RO data section is incorrectly mapped to data

Quoted 12 lines · On Wed, 6 Nov 2019 22:19:13 +0100 Romain Naour <[email protected]> wrote:

Starting with Binutils 2.33.1, elf2flt segfault while building busybox:
"ld (ld-elf2flt):
/opt/armv7m--uclibc--bleeding-edge-2/arm-buildroot-uclinux-uclibcgnueabi/bin/elf2flt

This was reported to the Binutils mailing list and it's seems an elf2flt issue with .ARM.exidx RO data section as explained
by: https://sourceware.org/ml/binutils/2019-10/msg00132.html

Apply the patch provided by Greg Ungerer [1] and tested by Christophe Priouzeau using stm32f469_disco_defconfig on stm32f469-disco board.

Quoted 7 lines

Fixes:
https://gitlab.com/kubu93/toolchains-builder/-/jobs/319395300

[1] https://github.com/uclinux-dev/elf2flt/issues/12

Cc Christophe Priouzeau <[email protected]>

Thanks a lot for this patch! Good to see that some people are active maintaining elf2flt.

While you're in touch with people with elf2flt knowledge, could you have a look at
http://lists.busybox.net/pipermail/buildroot/2019-June/253203.html ? I'm pretty sure for someone with ARM/elf2flt knowledge it's fairly easy to fix.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 package/elf2flt: .ARM.exidx RO data section is incorrectly mapped to data

In reply to Romain Naour
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Romain" == Romain Naour <[email protected]> writes:

Starting with Binutils 2.33.1, elf2flt segfault while building busybox:
"ld (ld-elf2flt):
/opt/armv7m--uclibc--bleeding-edge-2/arm-buildroot-uclinux-uclibcgnueabi/bin/elf2flt

This was reported to the Binutils mailing list and it's seems an elf2flt issue with .ARM.exidx RO data section as explained
by: https://sourceware.org/ml/binutils/2019-10/msg00132.html

Apply the patch provided by Greg Ungerer [1] and tested by Christophe Priouzeau using stm32f469_disco_defconfig on stm32f469-disco board.

Quoted 7 lines

Fixes:
https://gitlab.com/kubu93/toolchains-builder/-/jobs/319395300

[1] https://github.com/uclinux-dev/elf2flt/issues/12

Cc Christophe Priouzeau <[email protected]>

Committed to 2019.02.x and 2019.08.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard