bfin: fix issues with internal toolchain, re-enable C++ support

The three patches allow to compile applications using TLS emulation from
libgcc or C++ applications.

The patches 892-libgcc-mkmap-symver-support-skip_underscore.patch and
893-libgcc-config-bfin-use-the-generic-linker-version-in.patch fixes how
libgcc is generated, by making the necessary libgcc symbols declared
"GLOBAL", and therefore visible outside of libgcc. This fixes a large
number of undefined reference issues (for either C++ applications or
applications using TLS emulation). This was reported as gcc PR74748.

The patch 894-libgcc-fix-DWARF-compilation-with-FDPIC-targets.patch
allows to build DWARF in FDPIC mode. This patch replaces the older
892-disable-dwarf-bfin.patch, as instead of disabling DWARF support, it
fixes it. This was reported as gcc PR68468.

In order to get C++ working without unresolved symbols, we also need to
disable symbol versioning (--disable-symvers). This is a remaining issue
in gcc which will be investigated at a later point.

Since this commit fixes C++ support in Blackfin, it re-enables the
selection of C++ support for this architecture.

Fixes:
  (alsa-lib emutls)
  http://autobuild.buildroot.net/results/8544ce58d75820666579db93a25ca5656a8efa8e/
  (cairo emutls)
  http://autobuild.buildroot.net/results/88b02a5dd5408318941ccbfcea0a9cbaa331500a/
  (audiofile c++)
  http://autobuild.buildroot.net/results/394e530c5dcd9ccb590eb151aeaadb37d11e0e39/
  (assimp c++)
  http://autobuild.buildroot.net/results/01f4be126c2d786a5ad7f220c2cf60539888a480/
  (bellagio c++)
  http://autobuild.buildroot.net/results/ada/ada44228bf13ec05382275bd6571396f5ba2b1f7/

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Tested-by: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
Waldemar Brodkorb 2016-08-19 22:25:12 +02:00 committed by Thomas Petazzoni
parent 548657513d
commit 0d8a05c38e
6 changed files with 2113 additions and 27 deletions

View File

@ -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 <wbx@openadk.org>
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"

View File

@ -0,0 +1,74 @@
From ae9c3e354440c4a0f105a9eabfb2f77be085ebc1 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Thu, 18 Aug 2016 17:59:16 +0200
Subject: [PATCH] libgcc/mkmap-symver: support skip_underscore
Some platforms, such as Blackfin, have a special prefix for assembly
symbols as opposed to C symbols. For this reason, a function named
"foo()" in C will in fact be visible as a symbol called "_foo" in the
ELF binary.
The current linker version script logic in libgcc doesn't take into
account this situation properly. The Blackfin specific
libgcc/config/bfin/libgcc-glibc.ver has an additional "_" in front of
every symbol so that it matches the output of "nm" (which gets parsed to
produce the final linker version script). But due to this additional
"_", ld no longer matches with the symbols since "ld" does the matching
with the original symbol name, not the one prefixed with "_".
Due to this, none of the symbols in libgcc/config/bfin/libgcc-glibc.ver
are actually matched with symbols in libgcc. This causes all libgcc
symbols to be left as "LOCAL", which causes lots of "undefined
reference" whenever some C or C++ code that calls a function of libgcc
is compiled.
To address this, this commit introduces a "skip_underscore" variable to
the mkmap-symver script. It tells mkmap-symver to ignore the leading
underscore from the "nm" output.
Note that this new argument is different from the existing
"leading_underscore" argument, which *adds* an additional underscore to
the generated linker version script.
Having this functionality paves the way to using the generic linker
version information for Blackfin, instead of using a custom one.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
libgcc/ChangeLog | 5 +++++
libgcc/mkmap-symver.awk | 6 +++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 6559564..129e43f 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-19 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+ PR gcc/74748
+ * libgcc/mkmap-symver.awk: add support for skip_underscore
+
2016-04-27 Release Manager
* GCC 6.1.0 released.
diff --git a/libgcc/mkmap-symver.awk b/libgcc/mkmap-symver.awk
index 266832a..30bb179 100644
--- a/libgcc/mkmap-symver.awk
+++ b/libgcc/mkmap-symver.awk
@@ -47,7 +47,11 @@ state == "nm" && ($1 == "U" || $2 == "U") {
state == "nm" && NF == 3 {
split ($3, s, "@")
- def[s[1]] = 1;
+ if (skip_underscore)
+ symname = substr(s[1], 2);
+ else
+ symname = s[1];
+ def[symname] = 1;
sawsymbol = 1;
next;
}
--
2.7.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
From 9d9f97ca5d1ceba66677bf406c9b31027dc1f22e Mon Sep 17 00:00:00 2001
From: Waldemar Brodkorb <wbx@openadk.org>
Date: Fri, 19 Aug 2016 13:54:46 +0200
Subject: [PATCH] libgcc: fix DWARF compilation with FDPIC targets
The build of unwind-dw2-fde-dip.c currently fails for FDPIC targets with
the following error:
libgcc/unwind-dw2-fde-dip.c:167:31: error: storage size of 'load_base' isn't known
struct elf32_fdpic_loadaddr load_base;
This patch addresses that by defining load_base with the appropriate
type on FDPIC targets. It has been tested on FRV and Blackfin.
Fixes PR gcc/68468.
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
libgcc/ChangeLog | 5 +++++
libgcc/unwind-dw2-fde-dip.c | 8 ++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 36c0194..2e78d20 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-19 Waldemar Brodkorb <wbx@openadk.org>
+
+ PR gcc/68468
+ * libgcc/unwind-dw2-fde-dip.c: fix build on FDPIC targets.
+
2016-08-19 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
PR gcc/74748
diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
index f7a1c3f..801bce8 100644
--- a/libgcc/unwind-dw2-fde-dip.c
+++ b/libgcc/unwind-dw2-fde-dip.c
@@ -124,7 +124,11 @@ static struct frame_hdr_cache_element
{
_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 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
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 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
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?
--
2.7.4

View File

@ -120,9 +120,6 @@ config BR2_EXTRA_GCC_CONFIG_OPTIONS
config BR2_TOOLCHAIN_BUILDROOT_CXX
bool "Enable C++ support"
select BR2_INSTALL_LIBSTDCPP
# C++ support currently broken for Blackfin, under
# investigation.
depends on !BR2_bfin
help
Enable this option if you want your toolchain to support the
C++ language and you want C++ libraries to be installed on

View File

@ -74,6 +74,10 @@ HOST_GCC_FINAL_CONF_OPTS += "--with-multilib-list=m4a,m4a-nofpu"
HOST_GCC_FINAL_GCC_LIB_DIR = $(HOST_DIR)/usr/$(GNU_TARGET_NAME)/lib/!m4*
endif
ifeq ($(BR2_bfin),y)
HOST_GCC_FINAL_CONF_OPTS += --disable-symvers
endif
# Disable shared libs like libstdc++ if we do static since it confuses linking
ifeq ($(BR2_STATIC_LIBS),y)
HOST_GCC_FINAL_CONF_OPTS += --disable-shared