bfin: fix two issues with internal toolchain
RFC PATCH 1/1 bfin: fix two issues with internal toolchain
Allows to compile DWARF EH.
---
Hi,
this is my present work on the Blackfin C++ issues with the internal toolchain. There is still following problem:
$ ./output/host/usr/bin/bfin-buildroot-linux-uclibc-g++ -o foo foo.cc
/home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/lib/libstdc++.so:
undefined reference to `_Unwind_GetRegionStart'
..
$ cat foo.cc
#include <iostream>
int main(void) { std::cout << "hello, world\n"; }But libstdc++ should search for __Unwind_GetRegionStart:
nm /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/lib/libstdc++.so|grep _Unwind_GetRegionStart<
U __Unwind_GetRegionStart
And libgcc_s.so.1 provides it:
./output/host/usr/bin/bfin-buildroot-linux-uclibc-nm ./output/host/usr/bfin-buildroot-linux-uclibc/sysroot/lib/libgcc_s.so.1|grep _Unwind_GetRegionStart00005d0c t __Unwind_GetRegionStart
So why is ld trying to find _Unwind_GetRegionStart instead of __Unwind_GetRegionStart when linking?
Does ld ignores __USER_LABEL_PREFIX__?
Any ideas and help is really appreciated.
Here are some g++ verbose output logs from internal and external buildroot toolchain:
http://debug.openadk.org/buildroot/
--- package/gcc/6.1.0/892-disable-dwarf-bfin.patch | 24 ------------- package/gcc/6.1.0/892-fix-dwarf-fdpic.patch | 37 ++++++++++++++++++++ .../6.1.0/893-bfin-add-libgcc-linker-script.patch | 20 +++++++++++ 3 files changed, 57 insertions(+), 24 deletions(-) delete mode 100644 package/gcc/6.1.0/892-disable-dwarf-bfin.patch create mode 100644 package/gcc/6.1.0/892-fix-dwarf-fdpic.patch create mode 100644 package/gcc/6.1.0/893-bfin-add-libgcc-linker-script.patch
package/gcc/6.1.0/892-disable-dwarf-bfin.patch deleted +0 -24
@@ -1,24 +0,0 @@ -Dwarf support does not compile on Blackfin - -Reported upstream: -https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68468 - -Signed-off-by: Waldemar Brodkorb <[email protected]> - -diff -Nur gcc-6.1.0.orig/libgcc/config.host gcc-6.1.0/libgcc/config.host ---- gcc-6.1.0.orig/libgcc/config.host 2016-02-26 21:02:28.000000000 +0100 -+++ gcc-6.1.0/libgcc/config.host 2016-05-12 19:26:30.973350274 +0200 -@@ -230,6 +230,13 @@ - ;; - esac - ;; -+bfin-*-*linux*) -+ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux" -+ extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o" -+ if test x$enable_vtable_verify = xyes; then -+ extra_parts="$extra_parts vtv_start.o vtv_end.o vtv_start_preinit.o vtv_end_preinit.o" -+ fi -+ ;; - *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu) - tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux" - extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch new file +37 -0
@@ -0,0 +1,37 @@ +Fix DWARF compilation for FDPIC targets + +Signed-off-by: Waldemar Brodkorb <[email protected]> + +diff -Nur gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c +--- gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c 2016-01-04 15:30:50.000000000 +0100 ++++ gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c 2016-08-05 02:17:40.424195128 +0200 +@@ -124,7 +124,11 @@ + { + _Unwind_Ptr pc_low; + _Unwind_Ptr pc_high; ++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__ ++ struct elf32_fdpic_loadaddr load_base; ++#else + _Unwind_Ptr load_base; ++#endif + const ElfW(Phdr) *p_eh_frame_hdr; + const ElfW(Phdr) *p_dynamic; + struct frame_hdr_cache_element *link; +@@ -163,7 +167,7 @@ + struct unw_eh_callback_data *data = (struct unw_eh_callback_data *) ptr; + const ElfW(Phdr) *phdr, *p_eh_frame_hdr, *p_dynamic; + long n, match; +-#ifdef __FRV_FDPIC__ ++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__ + struct elf32_fdpic_loadaddr load_base; + #else + _Unwind_Ptr load_base; +@@ -347,7 +351,7 @@ + break; + } + } +-# elif defined __FRV_FDPIC__ && defined __linux__ ++# elif (defined __FRV_FDPIC__ || defined __BFIN_FDPIC__) && defined __linux__ + data->dbase = load_base.got_value; + # else + # error What is DW_EH_PE_datarel base on this platform?
package/gcc/6.1.0/893-bfin-add-libgcc-linker-script.patch new file +20 -0
@@ -0,0 +1,20 @@ +Add libgcc linker script for Blackfin FDPIC. + +Solves following linking error: +# bfin-openadk-linux-uclibc-g++ -o foo t.c +bfin-openadk-linux-uclibc/bin/ld: foo: hidden symbol `___udivsi3' in libgcc.a(_udivsi3.o) is referenced by DSO + +Signed-off-by: Waldemar Brodkorb <[email protected]> + +diff -Nur gcc-6.1.0.orig/libgcc/config.host gcc-6.1.0/libgcc/config.host +--- gcc-6.1.0.orig/libgcc/config.host 2016-02-26 21:02:28.000000000 +0100 ++++ gcc-6.1.0/libgcc/config.host 2016-07-25 02:47:05.818797217 +0200 +@@ -444,7 +444,7 @@ + md_unwind_header=bfin/linux-unwind.h + ;; + bfin*-linux-uclibc*) +- tmake_file="$tmake_file bfin/t-bfin bfin/t-crtstuff t-libgcc-pic t-fdpbit bfin/t-linux" ++ tmake_file="$tmake_file bfin/t-bfin bfin/t-crtstuff t-libgcc-pic t-slibgcc-libgcc t-fdpbit bfin/t-linux" + # No need to build crtbeginT.o on uClibc systems. Should probably + # be moved to the OS specific section above. + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
Signature · 1 line
1.7.10.4
RFC PATCH 1/1 bfin: fix two issues with internal toolchain
Hello,
Quoted 5 lines · Waldemar Brodkorb
And libgcc_s.so.1 provides it:
./output/host/usr/bin/bfin-buildroot-linux-uclibc-nm ./output/host/usr/bfin-buildroot-linux-uclibc/sysroot/lib/libgcc_s.so.1|grep_Unwind_GetRegionStart00005d0ct__Unwind_GetRegionStart
We are currently discussing it on IRC, but I believe the problem is that "t" indicates that the symbol is not visible. It should be a "T".
Quoted 10 lines
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch new file +4
-0@@ -0,0 +1,37 @@ +Fix DWARF compilation for FDPIC targets + +Signed-off-by: Waldemar Brodkorb <[email protected]> +
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch line 14
Quoted 10 lines
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch new file +10
-0+diff -Nur gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c +--- gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c 2016-01-04 15:30:50.000000000 +0100 ++++ gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c 2016-08-05 02:17:40.424195128 +0200 +@@ -124,7 +124,11 @@ + { + _Unwind_Ptr pc_low; + _Unwind_Ptr pc_high; ++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__ ++ struct elf32_fdpic_loadaddr load_base; ++#else
I'm surprised by this part of the patch, since you are changing the behavior for __FRV_FDPIC__ as well. It wasn't working before?
In all other chunks you simply add __BFIN_FDPIC__ as behaving the same as __FRV_FDPIC__ but you're not doing the same here. Is this expected?
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch line 15
Quoted 1 line
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch new file +1
-0++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__
Obvious question: is there a symbol that says "I'm using FDPIC" and which would make such conditions simpler?
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
RFC PATCH 1/1 bfin: fix two issues with internal toolchain
Hi Thomas,
Thomas Petazzoni wrote,
Quoted 4 lines
Hello,
On Fri, 5 Aug 2016 21:52:47 +0200, Waldemar Brodkorb wrote:
Quoted 8 lines
Quoted 5 lines
And libgcc_s.so.1 provides it:
./output/host/usr/bin/bfin-buildroot-linux-uclibc-nm ./output/host/usr/bfin-buildroot-linux-uclibc/sysroot/lib/libgcc_s.so.1|grep_Unwind_GetRegionStart00005d0ct__Unwind_GetRegionStartWe are currently discussing it on IRC, but I believe the problem is that "t" indicates that the symbol is not visible. It should be a "T".
You are right, this seems to be the problem. You nailed it down! It seems ELF has two different concepts for symbol visibility:
https://www.technovelty.org/code/why-symbol-visibility-is-good.html
The symbols in the libgcc_s.so.1 generated by internal toolchain are bind "LOCAL", so not visible for linking the c++ application. The Unwind* symbols in libgcc_s.so.1 from the external toolchain are bind "GLOBAL".
Next thing is to find the reason for it.
Quoted 15 lines
Quoted 15 lines
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch new file +9
-0@@ -0,0 +1,37 @@ +Fix DWARF compilation for FDPIC targets + +Signed-off-by: Waldemar Brodkorb <[email protected]> + +diff -Nur gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c +--- gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c 2016-01-04 15:30:50.000000000 +0100 ++++ gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c 2016-08-05 02:17:40.424195128 +0200 +@@ -124,7 +124,11 @@ + {
Quoted 8 lines
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch line 14
Quoted 5 lines
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch new file +5
-0+ _Unwind_Ptr pc_low; + _Unwind_Ptr pc_high; ++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__ ++ struct elf32_fdpic_loadaddr load_base; ++#elseI'm surprised by this part of the patch, since you are changing the behavior for
__FRV_FDPIC__as well. It wasn't working before?
No, DWARF compiling for FR-V architecture is broken/bitrotted as well. So this patch will be what I am suggesting upstream.
Quoted 7 lines
In all other chunks you simply add
__BFIN_FDPIC__as behaving the same as__FRV_FDPIC__but you're not doing the same here. Is this expected?package/gcc/6.1.0/892-fix-dwarf-fdpic.patch line 15
Quoted 1 line
package/gcc/6.1.0/892-fix-dwarf-fdpic.patch new file +1
-0++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__Obvious question: is there a symbol that says "I'm using FDPIC" and which would make such conditions simpler?
There is a symbol __FDPIC__ for Bfin and FR-V, but it is exposed _after_ the full gcc is build and can not be used while bootstrapping the toolchain. I tried it.
best regards
Waldemar
RFC PATCH 1/1 bfin: fix two issues with internal toolchain
In reply to Waldemar BrodkorbHi,
Waldemar Brodkorb wrote,
I think the patch is okay and should be used. But I give up on the remaining problem for this release.
I tried all version of binutils from 2.27 down to ADI toolchain binutils 2.21. It seems not a binutils or linker problem.
I tried to convert the LOCAL symbols with objcopy to GLOBAL, but the problem persist.
I recognized that the missing symbols in libstdc++.so are NOTYPE, but in the working external toolchain they are FUNC.
Without help from some Blackfin developer from Analog Devices I see no chance to fix it right now.
@Thomas: Can you disable C++ for internal Blackfin toolchain? Thanks.
best regards
Waldemar
Quoted 153 lines
Allows to compile DWARF EH.
Signed-off-by Waldemar Brodkorb <[email protected]>---
Hi,
this is my present work on the Blackfin C++ issues with the internal toolchain. There is still following problem:$ ./output/host/usr/bin/bfin-buildroot-linux-uclibc-g++ -o foo foo.cc /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/lib/libstdc++.so: undefined reference to `_Unwind_GetRegionStart' .. $ cat foo.cc #include <iostream> int main(void) { std::cout << "hello, world\n"; }But libstdc++ should search for
__Unwind_GetRegionStart:
nm /home/wbx/buildroot/output/host/usr/lib/gcc/bfin-buildroot-linux-uclibc/6.1.0/../../../../bfin-buildroot-linux-uclibc/lib/libstdc++.so|grep _Unwind_GetRegionStart<
U__Unwind_GetRegionStartAnd libgcc_s.so.1 provides it:
./output/host/usr/bin/bfin-buildroot-linux-uclibc-nm ./output/host/usr/bfin-buildroot-linux-uclibc/sysroot/lib/libgcc_s.so.1|grep_Unwind_GetRegionStart00005d0ct__Unwind_GetRegionStartSo why is ld trying to find
_Unwind_GetRegionStartinstead of__Unwind_GetRegionStartwhen linking?
Does ld ignores__USER_LABEL_PREFIX__?Any ideas and help is really appreciated.
Here are some g++ verbose output logs from internal and external buildroot toolchain:
http://debug.openadk.org/buildroot/--- package/gcc/6.1.0/892-disable-dwarf-bfin.patch | 24 ------------- package/gcc/6.1.0/892-fix-dwarf-fdpic.patch | 37 ++++++++++++++++++++ .../6.1.0/893-bfin-add-libgcc-linker-script.patch | 20 +++++++++++ 3 files changed, 57 insertions(+), 24 deletions(-) delete mode 100644 package/gcc/6.1.0/892-disable-dwarf-bfin.patch create mode 100644 package/gcc/6.1.0/892-fix-dwarf-fdpic.patch create mode 100644 package/gcc/6.1.0/893-bfin-add-libgcc-linker-script.patchpackage/gcc/6.1.0/892-disable-dwarf-bfin.patch deleted +0
-24@@ -1,24 +0,0 @@ -Dwarf support does not compile on Blackfin - -Reported upstream: -https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68468 - -Signed-off-by: Waldemar Brodkorb <[email protected]> - -diff -Nur gcc-6.1.0.orig/libgcc/config.host gcc-6.1.0/libgcc/config.host ---- gcc-6.1.0.orig/libgcc/config.host 2016-02-26 21:02:28.000000000 +0100 -+++ gcc-6.1.0/libgcc/config.host 2016-05-12 19:26:30.973350274 +0200 -@@ -230,6 +230,13 @@ - ;; - esac - ;; -+bfin-*-*linux*) -+ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux" -+ extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o" -+ if test x$enable_vtable_verify = xyes; then -+ extra_parts="$extra_parts vtv_start.o vtv_end.o vtv_start_preinit.o vtv_end_preinit.o" -+ fi -+ ;; - *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu) - tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux" - extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"package/gcc/6.1.0/892-fix-dwarf-fdpic.patch new file +37
-0@@ -0,0 +1,37 @@ +Fix DWARF compilation for FDPIC targets + +Signed-off-by: Waldemar Brodkorb <[email protected]> + +diff -Nur gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c +--- gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c 2016-01-04 15:30:50.000000000 +0100 ++++ gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c 2016-08-05 02:17:40.424195128 +0200 +@@ -124,7 +124,11 @@ + { + _Unwind_Ptr pc_low; + _Unwind_Ptr pc_high; ++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__ ++ struct elf32_fdpic_loadaddr load_base; ++#else + _Unwind_Ptr load_base; ++#endif + const ElfW(Phdr) *p_eh_frame_hdr; + const ElfW(Phdr) *p_dynamic; + struct frame_hdr_cache_element *link; +@@ -163,7 +167,7 @@ + struct unw_eh_callback_data *data = (struct unw_eh_callback_data *) ptr; + const ElfW(Phdr) *phdr, *p_eh_frame_hdr, *p_dynamic; + long n, match; +-#ifdef __FRV_FDPIC__ ++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__ + struct elf32_fdpic_loadaddr load_base; + #else + _Unwind_Ptr load_base; +@@ -347,7 +351,7 @@ + break; + } + } +-# elif defined __FRV_FDPIC__ && defined __linux__ ++# elif (defined __FRV_FDPIC__ || defined __BFIN_FDPIC__) && defined __linux__ + data->dbase = load_base.got_value; + # else + # error What is DW_EH_PE_datarel base on this platform?package/gcc/6.1.0/893-bfin-add-libgcc-linker-script.patch new file +20
-0@@ -0,0 +1,20 @@ +Add libgcc linker script for Blackfin FDPIC. + +Solves following linking error: +# bfin-openadk-linux-uclibc-g++ -o foo t.c +bfin-openadk-linux-uclibc/bin/ld: foo: hidden symbol `___udivsi3' in libgcc.a(_udivsi3.o) is referenced by DSO + +Signed-off-by: Waldemar Brodkorb <[email protected]> + +diff -Nur gcc-6.1.0.orig/libgcc/config.host gcc-6.1.0/libgcc/config.host +--- gcc-6.1.0.orig/libgcc/config.host 2016-02-26 21:02:28.000000000 +0100 ++++ gcc-6.1.0/libgcc/config.host 2016-07-25 02:47:05.818797217 +0200 +@@ -444,7 +444,7 @@ + md_unwind_header=bfin/linux-unwind.h + ;; + bfin*-linux-uclibc*) +- tmake_file="$tmake_file bfin/t-bfin bfin/t-crtstuff t-libgcc-pic t-fdpbit bfin/t-linux" ++ tmake_file="$tmake_file bfin/t-bfin bfin/t-crtstuff t-libgcc-pic t-slibgcc-libgcc t-fdpbit bfin/t-linux" + # No need to build crtbeginT.o on uClibc systems. Should probably + # be moved to the OS specific section above. + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"Signature · 6 lines
1.7.10.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot