elf2flt
elf2flt copied to clipboard
.ARM.exidx RO data section is incorrectly mapped to data
Hi,
Starting with Binutils 2.33.1, elf2flt segfault while building busybox: "ld (ld-elf2flt): /builds/kubu93/toolchains-builder/build/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
Can you have a look ?
Best regards, Romain
Hi Romain,
On 18/10/19 5:43 am, Romain Naour wrote:
Starting with Binutils 2.33.1, elf2flt segfault while building busybox: "ld (ld-elf2flt): /builds/kubu93/toolchains-builder/build/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
Can you have a look ?
Ok, sure looks like a problem. I can reproduce it with binutils-2.33.1.
Attached is a proposed fix. I have tested and confirmed it fixes the problem for arm targets. I still need to do further testing on other architecture targets though.
Regards Greg
Hi Greg,
Thanks for your reply. But I didn't received your patch, can you send it again ?
Best regards, Romain
Hi Romain,
On 4/11/19 8:12 am, Romain Naour wrote:
Hi Greg,
Thanks for your reply. But I didn't received your patch, can you send it again ?
I guess gitbub dropped the attachment. Here it is inline - hopefully not too white-space mangled.
Regards Greg
From 73325b7f209e0f68887333385184af275531427d Mon Sep 17 00:00:00 2001 From: Greg Ungerer [email protected] Date: Wed, 30 Oct 2019 16:08:19 +1000 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
Signed-off-by: Greg Ungerer [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) || -
else if (a->flags & SEC_DATA) sectionp = data + (a->vma - data_vma); -- 2.17.1((a->flags & (SEC_DATA | SEC_READONLY)) == (SEC_DATA | SEC_READONLY)))) sectionp = text + (a->vma - text_vma);
Hi, I just perform the test to use the patch for a build configured for ARM Cortex-M4 Test realised with:
- 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
Best regards, Christophe
Hi,
It seems this patch introduce some regressions [1]
The toolchain is using gcc 8.3, binutils 2.32, uClibc-ng 1.0.32.
(verbose build while building binutils package) Invoking: 'output/host/m68k-buildroot-uclinux-uclibc/bin/elf2flt' '-a' '-o' 'readelf' '-r' 'readelf.gdb' ld (ld-elf2flt): output/host/m68k-buildroot-uclinux-uclibc/bin/elf2flt terminated with signal 11 [Segmentation fault], core dumped collect2: error: ld returned 1 exit status
By running manually the elf2flt tool from the binutils build directory:
'output/host/m68k-buildroot-uclinux-uclibc/bin/elf2flt' '-a' '-o' 'readelf' '-r' 'readelf.gdb' [...] SECTION: .tm_clone_table [0x2185af0]: flags=0x123 vma=0x84384 RELOCS: .tm_clone_table [0x2185af0]: flags=0x123 vma=0x84384 SECTION: .eh_frame [0x2185c20]: flags=0x12f vma=0x84384 RELOCS: .eh_frame [0x2185c20]: flags=0x12f vma=0x84384 Segmentation fault (core dumped)
As far I can tell, the crash occur from elf2flt.c line 1569
If I remove this patch, the build complete correctly.
[1] http://lists.busybox.net/pipermail/buildroot/2020-February/274593.html [2] https://github.com/uclinux-dev/elf2flt/blob/master/elf2flt.c#L1569
Best regards, Romain
Hello, I proposed a patch [1] to avoid moving readonly .eh_frame section to "text" section. Thoughts ?
[1] http://patchwork.ozlabs.org/patch/1242367/
just to be clear, buildroot is an unrelated project to elf2flt. patches need to be submitted here to be merged here.
that said, i have no idea about this particular bug with ARM.
i think Greg fixed this now with recent commits