uclibc++: bump to 0.2.5
This commit is contained in:
parent
8bf622495d
commit
0ebb9fa5f5
@ -9,19 +9,18 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=uclibc++
|
||||
PKG_VERSION:=0.2.4
|
||||
PKG_VERSION:=0.2.5
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=uClibc++-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=http://cxx.uclibc.org/src/
|
||||
PKG_HASH:=be16fc6a6eb2e59df420ee41e7042f38e27ebaf5c2762d90e75803364a7b00db
|
||||
|
||||
PKG_SOURCE:=uClibc++-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=https://cxx.uclibc.org/src/
|
||||
PKG_HASH:=596fb9ed7295564ce4c70ae6076a18f92e72f70310d70c98520bbca85c77895a
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/uClibc++-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=LGPL-2.1-or-later
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_LICENSE:=LGPL-2.1+
|
||||
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@ -30,7 +29,7 @@ define Package/uclibcxx
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=C++ library for embedded systems
|
||||
URL:=http://cxx.uclibc.org/src/
|
||||
URL:=https://cxx.uclibc.org/
|
||||
endef
|
||||
|
||||
UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
|
||||
@ -45,7 +44,8 @@ UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
|
||||
-e 's/mipsel.*/mips/' \
|
||||
)
|
||||
|
||||
TARGET_CFLAGS += $(FPIC)
|
||||
TARGET_CFLAGS += $(FPIC) -nostdinc++ -std=c++11
|
||||
TARGET_LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
TARGET_CXX=$(TARGET_CXX_NOCACHE)
|
||||
@ -56,24 +56,15 @@ SSP_LIB=-lssp_nonshared
|
||||
endif
|
||||
|
||||
MAKE_FLAGS:= \
|
||||
TOPDIR="$(PKG_BUILD_DIR)/" \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
CPU_CFLAGS="$(TARGET_CFLAGS)" \
|
||||
CROSS="$(TARGET_CROSS)" \
|
||||
LDFLAGS="-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs $(TARGET_LDFLAGS)" \
|
||||
CP="$(CP)" \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
GEN_LIBS="-lc $(LIBGCC_S) $(SSP_LIB)" \
|
||||
GEN_CFLAGS="-std=gnu++98 -nostdinc++" \
|
||||
check_as_needed=
|
||||
|
||||
# check_as_needed overrides dependency on libgcc_s
|
||||
|
||||
define Build/Prepare
|
||||
$(PKG_UNPACK)
|
||||
$(SED) 's/\r$$$$//' $(PKG_BUILD_DIR)/include/unwind-cxx.h
|
||||
$(Build/Patch)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
if [ -f ./files/config.$(UCLIBC_TARGET_ARCH) ]; then \
|
||||
cp ./files/config.$(UCLIBC_TARGET_ARCH) $(PKG_BUILD_DIR)/.config; \
|
||||
|
||||
10
package/libs/uclibc++/files/config.default
Executable file → Normal file
10
package/libs/uclibc++/files/config.default
Executable file → Normal file
@ -8,7 +8,7 @@
|
||||
UCLIBCXX_HAS_FLOATS=y
|
||||
# UCLIBCXX_HAS_LONG_DOUBLE is not set
|
||||
# UCLIBCXX_HAS_TLS is not set
|
||||
WARNINGS="-Wall"
|
||||
UCLIBCXX_WARNINGS=""
|
||||
BUILD_EXTRA_LIBRARIES=""
|
||||
HAVE_DOT_CONFIG=y
|
||||
|
||||
@ -23,10 +23,10 @@ UCLIBCXX_SUPPORT_CIN=y
|
||||
UCLIBCXX_SUPPORT_COUT=y
|
||||
UCLIBCXX_SUPPORT_CERR=y
|
||||
UCLIBCXX_SUPPORT_CLOG=y
|
||||
UCLIBCXX_SUPPORT_WCIN=y
|
||||
UCLIBCXX_SUPPORT_WCOUT=y
|
||||
UCLIBCXX_SUPPORT_WCERR=y
|
||||
UCLIBCXX_SUPPORT_WCLOG=y
|
||||
# UCLIBCXX_SUPPORT_WCIN is not set
|
||||
# UCLIBCXX_SUPPORT_WCOUT is not set
|
||||
# UCLIBCXX_SUPPORT_WCERR is not set
|
||||
# UCLIBCXX_SUPPORT_WCLOG is not set
|
||||
|
||||
#
|
||||
# STL and Code Expansion
|
||||
|
||||
10
package/libs/uclibc++/patches/001-no-ansi.patch
Normal file
10
package/libs/uclibc++/patches/001-no-ansi.patch
Normal file
@ -0,0 +1,10 @@
|
||||
--- a/Rules.mak
|
||||
+++ b/Rules.mak
|
||||
@@ -232,7 +232,6 @@ endif
|
||||
GEN_CXXFLAGS:=-nostdinc++
|
||||
GEN_CXXFLAGS+=$(if $(CXXFLAG_-fvisibility-inlines-hidden),-DGCC_HASCLASSVISIBILITY)
|
||||
CXXFLAGS:=$(CFLAGS)
|
||||
-CFLAGS += -ansi
|
||||
|
||||
LIBGCC:=$(shell $(CC) -print-libgcc-file-name)
|
||||
LIBGCC_DIR:=$(dir $(LIBGCC))
|
||||
@ -1,11 +0,0 @@
|
||||
--- a/bin/Makefile
|
||||
+++ b/bin/Makefile
|
||||
@@ -13,7 +13,7 @@ install:
|
||||
$(INSTALL) -m 755 $(WRAPPER) $(PREFIX)$(UCLIBCXX_RUNTIME_BINDIR)
|
||||
|
||||
$(WRAPPER): Makefile
|
||||
- echo '#!/bin/sh' > $@
|
||||
+ echo '#!/usr/bin/env bash' > $@
|
||||
echo '' >> $@
|
||||
echo 'WRAPPER_INCLUDEDIR="$${WRAPPER_INCLUDEDIR:=-I$(UCLIBCXX_RUNTIME_INCLUDEDIR)}"' >> $@
|
||||
echo 'WRAPPER_LIBDIR="$${WRAPPER_LIBDIR:=-L$(UCLIBCXX_RUNTIME_LIBDIR)}"' >> $@
|
||||
35
package/libs/uclibc++/patches/002-undef-functions.patch
Normal file
35
package/libs/uclibc++/patches/002-undef-functions.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From 8245f62c1e7aba150f666b3c3a1dda646dee6d4b Mon Sep 17 00:00:00 2001
|
||||
From: Rosen Penev <rosenp@gmail.com>
|
||||
Date: Fri, 27 Sep 2019 13:12:44 -0700
|
||||
Subject: [PATCH] cstdio: Add undef for four functions
|
||||
|
||||
When compiling with uClibc-ng, these functions get defined as macros and
|
||||
become unavailable for std.
|
||||
|
||||
Fixes programs that use the std versions of these functions.
|
||||
|
||||
This matches libstdcpp behavior.
|
||||
|
||||
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
||||
---
|
||||
include/cstdio | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
--- a/include/cstdio
|
||||
+++ b/include/cstdio
|
||||
@@ -21,6 +21,15 @@
|
||||
#ifndef __HEADER_CSTDIO
|
||||
#define __HEADER_CSTDIO 1
|
||||
|
||||
+#undef clearerr
|
||||
+#undef feof
|
||||
+#undef ferror
|
||||
+#undef fgetc
|
||||
+#undef fputc
|
||||
+#undef getc
|
||||
+#undef getchar
|
||||
+#undef putc
|
||||
+#undef putchar
|
||||
|
||||
namespace std{
|
||||
using ::FILE;
|
||||
10
package/libs/uclibc++/patches/003-no-fPIC.patch
Normal file
10
package/libs/uclibc++/patches/003-no-fPIC.patch
Normal file
@ -0,0 +1,10 @@
|
||||
--- a/Rules.mak
|
||||
+++ b/Rules.mak
|
||||
@@ -185,7 +185,6 @@ export UCLIBCXX_RUNTIME_PREFIX UCLIBCXX_
|
||||
|
||||
WRAPPER = $(top_builddir)bin/g++-uc
|
||||
OPTIMIZATION:=
|
||||
-PICFLAG:=-fPIC
|
||||
|
||||
# use '-Os' optimization if available, else use -O2, allow Config to override
|
||||
$(eval $(call check-gcc-var,-Os))
|
||||
@ -0,0 +1,143 @@
|
||||
From 8151579eb36d9366632242415ff3f5177fa5e1e2 Mon Sep 17 00:00:00 2001
|
||||
From: Rosen Penev <rosenp@gmail.com>
|
||||
Date: Thu, 3 Oct 2019 18:58:43 -0700
|
||||
Subject: [PATCH] uClibc++: Make long long available to C++11
|
||||
|
||||
C++11 makes long long available. It is no longer a GNU extension.
|
||||
|
||||
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
||||
---
|
||||
include/istream | 4 ++--
|
||||
include/istream_helpers | 2 +-
|
||||
include/ostream | 8 ++++----
|
||||
include/ostream_helpers | 8 ++++----
|
||||
tests/sstreamtest.cpp | 4 ++--
|
||||
5 files changed, 13 insertions(+), 13 deletions(-)
|
||||
|
||||
--- a/include/istream
|
||||
+++ b/include/istream
|
||||
@@ -72,7 +72,7 @@ namespace std{
|
||||
basic_istream<charT,traits>& operator>>(void*& p);
|
||||
basic_istream<charT,traits>& operator>>(basic_streambuf<char_type,traits>* sb);
|
||||
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
basic_istream<charT,traits>& operator>>(long long& n);
|
||||
basic_istream<charT,traits>& operator>>(unsigned long long& n);
|
||||
#endif
|
||||
@@ -455,7 +455,7 @@ namespace std{
|
||||
return *this;
|
||||
}
|
||||
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(long long& n)
|
||||
{
|
||||
--- a/include/istream_helpers
|
||||
+++ b/include/istream_helpers
|
||||
@@ -301,7 +301,7 @@ namespace std{
|
||||
};
|
||||
|
||||
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long long>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, long long & var)
|
||||
--- a/include/ostream
|
||||
+++ b/include/ostream
|
||||
@@ -85,7 +85,7 @@ namespace std {
|
||||
basic_ostream<charT,traits>& operator<<(long double f);
|
||||
basic_ostream<charT,traits>& operator<<(void* p);
|
||||
basic_ostream<charT,traits>& operator<<(basic_streambuf<char_type,traits>* sb);
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
basic_ostream<charT,traits>& operator<<(long long n);
|
||||
basic_ostream<charT,traits>& operator<<(unsigned long long n);
|
||||
#endif
|
||||
@@ -221,7 +221,7 @@ namespace std {
|
||||
return *this;
|
||||
}
|
||||
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long long n)
|
||||
{
|
||||
sentry s(*this);
|
||||
@@ -487,7 +487,7 @@ namespace std {
|
||||
#endif
|
||||
|
||||
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
//Support for output of long long data types
|
||||
|
||||
@@ -509,7 +509,7 @@ template<class Ch, class Tr> _UCXXEXPORT
|
||||
}
|
||||
|
||||
|
||||
-#endif //__STRICT_ANSI__
|
||||
+#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
|
||||
|
||||
--- a/include/ostream_helpers
|
||||
+++ b/include/ostream_helpers
|
||||
@@ -142,7 +142,7 @@ namespace std{
|
||||
}
|
||||
};
|
||||
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, signed long long int>{
|
||||
public:
|
||||
@@ -237,7 +237,7 @@ namespace std{
|
||||
};
|
||||
|
||||
|
||||
-#endif //__STRICT_ANSI__
|
||||
+#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, double>{
|
||||
public:
|
||||
@@ -357,7 +357,7 @@ namespace std{
|
||||
}
|
||||
};
|
||||
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, signed long long int>{
|
||||
public:
|
||||
@@ -428,7 +428,7 @@ namespace std{
|
||||
};
|
||||
|
||||
|
||||
-#endif //__STRICT_ANSI__
|
||||
+#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, double>{
|
||||
public:
|
||||
--- a/tests/sstreamtest.cpp
|
||||
+++ b/tests/sstreamtest.cpp
|
||||
@@ -9,7 +9,7 @@ int main(){
|
||||
int i;
|
||||
std::string s;
|
||||
char c;
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
long long ll;
|
||||
unsigned long long ull;
|
||||
#endif
|
||||
@@ -32,7 +32,7 @@ int main(){
|
||||
|
||||
|
||||
|
||||
-#ifndef __STRICT_ANSI__
|
||||
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
a.str("678 76 54");
|
||||
a >> ll >> ull >> s;
|
||||
std::cout << "ll (should be 678): " << ll << std::endl;
|
||||
@ -0,0 +1,37 @@
|
||||
From 7f6dd860818512c0eb313320308b22ba7e2c7205 Mon Sep 17 00:00:00 2001
|
||||
From: Rosen Penev <rosenp@gmail.com>
|
||||
Date: Fri, 4 Oct 2019 20:06:53 -0700
|
||||
Subject: [PATCH] istream_helpers: Fix sscanf typo
|
||||
|
||||
This caused readin not to work properly with long long types.
|
||||
|
||||
Found accidentally through a glibc warning
|
||||
(declared with warn_unused_result).
|
||||
|
||||
Tested with gptfdisk on OpenWrt.
|
||||
|
||||
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
||||
---
|
||||
include/istream_helpers | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/include/istream_helpers
|
||||
+++ b/include/istream_helpers
|
||||
@@ -317,7 +317,7 @@ namespace std{
|
||||
sscanf(temp.c_str(), "%llo", (unsigned long long *)&var );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
- scanf(temp.c_str(), "%llX", (unsigned long long *)&var );
|
||||
+ sscanf(temp.c_str(), "%llX", (unsigned long long *)&var );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%llx", (unsigned long long *)&var);
|
||||
}
|
||||
@@ -344,7 +344,7 @@ namespace std{
|
||||
sscanf(temp.c_str(), "%llo", &var );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
- scanf(temp.c_str(), "%llX", &var );
|
||||
+ sscanf(temp.c_str(), "%llX", &var );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%llx", &var);
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
--- a/include/typeinfo
|
||||
+++ b/include/typeinfo
|
||||
@@ -44,6 +44,7 @@ namespace __cxxabiv1
|
||||
class __class_type_info;
|
||||
} // namespace __cxxabiv1
|
||||
|
||||
+#ifndef __GXX_MERGED_TYPEINFO_NAMES
|
||||
#if !__GXX_WEAK__
|
||||
// If weak symbols are not supported, typeinfo names are not merged.
|
||||
#define __GXX_MERGED_TYPEINFO_NAMES 0
|
||||
@@ -51,6 +52,7 @@ namespace __cxxabiv1
|
||||
// On platforms that support weak symbols, typeinfo names are merged.
|
||||
#define __GXX_MERGED_TYPEINFO_NAMES 1
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
--- a/include/unwind-cxx.h
|
||||
+++ b/include/unwind-cxx.h
|
||||
@@ -173,6 +173,7 @@ extern std::unexpected_handler __unexpec
|
||||
|
||||
// This is the exception class we report -- "GNUCC++\0".
|
||||
const _Unwind_Exception_Class __gxx_exception_class
|
||||
+#ifndef __ARM_EABI_UNWINDER__
|
||||
= ((((((((_Unwind_Exception_Class) 'G'
|
||||
<< 8 | (_Unwind_Exception_Class) 'N')
|
||||
<< 8 | (_Unwind_Exception_Class) 'U')
|
||||
@@ -181,6 +182,9 @@ const _Unwind_Exception_Class __gxx_exce
|
||||
<< 8 | (_Unwind_Exception_Class) '+')
|
||||
<< 8 | (_Unwind_Exception_Class) '+')
|
||||
<< 8 | (_Unwind_Exception_Class) '\0');
|
||||
+#else
|
||||
+= "GNUC++";
|
||||
+#endif
|
||||
|
||||
// GNU C++ personality routine, Version 0.
|
||||
extern "C" _Unwind_Reason_Code __gxx_personality_v0
|
||||
@ -1,23 +0,0 @@
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -3,9 +3,9 @@ include $(TOPDIR)Rules.mak
|
||||
|
||||
WR_CXX := WRAPPER_INCLUDEDIR=-I$(TOPDIR)include $(TOPDIR)bin/g++-uc
|
||||
|
||||
-LDFLAGS += -nodefaultlibs -shared -Wl,-soname,$(SHARED_MAJORNAME) $(BUILD_EXTRA_LIBRARIES)
|
||||
+EXTRA_LDFLAGS += -nodefaultlibs -shared -Wl,-soname,$(SHARED_MAJORNAME) $(BUILD_EXTRA_LIBRARIES)
|
||||
ifneq ($(DODEBUG),y)
|
||||
-LDFLAGS += -Wl,-s
|
||||
+EXTRA_LDFLAGS += -Wl,-s
|
||||
endif
|
||||
|
||||
SRCS = $(wildcard *.cpp)
|
||||
@@ -60,7 +60,7 @@ $(LIBNAME).a: libgcc_eh libsupc $(EXOBJS
|
||||
$(RANLIB) $@
|
||||
|
||||
$(SHARED_FULLNAME): libgcc_eh libsupc $(EXOBJS)
|
||||
- $(CC) $(LDFLAGS) -o $@ $(EXOBJS) $(SUPOBJS) $(GCCOBJS) $(LIBS)
|
||||
+ $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $(EXOBJS) $(SUPOBJS) $(GCCOBJS) $(LIBS)
|
||||
$(LN) $@ $(SHARED_MAJORNAME)
|
||||
$(LN) $(SHARED_MAJORNAME) $(LIBNAME).so
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
--- a/include/ostream
|
||||
+++ b/include/ostream
|
||||
@@ -294,7 +294,7 @@ namespace std {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
- template <class charT,class traits = char_traits<charT> >
|
||||
+ template <class charT,class traits>
|
||||
class _UCXXEXPORT basic_ostream<charT,traits>::sentry
|
||||
{
|
||||
bool ok;
|
||||
--- a/include/istream
|
||||
+++ b/include/istream
|
||||
@@ -340,7 +340,7 @@ namespace std{
|
||||
|
||||
};
|
||||
|
||||
- template <class charT,class traits = char_traits<charT> > class _UCXXEXPORT basic_istream<charT,traits>::sentry {
|
||||
+ template <class charT,class traits> class _UCXXEXPORT basic_istream<charT,traits>::sentry {
|
||||
bool ok;
|
||||
public:
|
||||
explicit _UCXXEXPORT sentry(basic_istream<charT,traits>& os, bool noskipws = false){
|
||||
@ -1,114 +0,0 @@
|
||||
From 1dc865b8bbb3911abc8ce53c7ae8a59dc90f6fc3 Mon Sep 17 00:00:00 2001
|
||||
From: Ivan Kold <pixus.ru@gmail.com>
|
||||
Date: Thu, 3 Mar 2016 12:56:30 -0800
|
||||
Subject: [PATCH] Fix throw statement causing memory corruption
|
||||
|
||||
The __cxxabiv1::__cxa_throw in the GCC's libsupc++ expects
|
||||
sizeof(__cxa_refcounted_exception) bytes be allocated before
|
||||
exception object.
|
||||
uClibc++ allocates only sizeof(__cxa_exception) before an
|
||||
exception object.
|
||||
The __cxxabiv1::__cxa_throw writes in memory before allocated:
|
||||
// gcc-5.2.0/libstdc++-v3/libsupc++/eh_throw.cc:69
|
||||
__cxa_refcounted_exception *header
|
||||
= __get_refcounted_exception_header_from_obj (obj);
|
||||
header->referenceCount = 1;
|
||||
|
||||
Signed-off-by: Ivan Kold <pixus.ru@gmail.com>
|
||||
---
|
||||
include/unwind-cxx.h | 34 +++++++++++++++++++++++++++++++++-
|
||||
src/eh_alloc.cpp | 8 ++++----
|
||||
2 files changed, 37 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/include/unwind-cxx.h
|
||||
+++ b/include/unwind-cxx.h
|
||||
@@ -1,5 +1,5 @@
|
||||
// -*- C++ -*- Exception handling and frame unwind runtime interface routines.
|
||||
-// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
+// Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of GCC.
|
||||
//
|
||||
@@ -13,6 +13,10 @@
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
+// Under Section 7 of GPL version 3, you are granted additional
|
||||
+// permissions described in the GCC Runtime Library Exception, version
|
||||
+// 3.1, as published by the Free Software Foundation.
|
||||
+//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with GCC; see the file COPYING. If not, write to
|
||||
// the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
@@ -40,6 +44,12 @@
|
||||
#include <cstddef>
|
||||
#include "unwind.h"
|
||||
|
||||
+// Original unwind-cxx.h also includes bits/atomic_word.h which is CPU-specific,
|
||||
+// but always defines _Atomic_word as typedef int .
|
||||
+// Only thing that differs is memory-barrier macroses.
|
||||
+typedef int _Atomic_word;
|
||||
+
|
||||
+
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace __cxxabiv1
|
||||
@@ -79,6 +89,13 @@ struct __cxa_exception
|
||||
_Unwind_Exception unwindHeader;
|
||||
};
|
||||
|
||||
+struct __cxa_refcounted_exception
|
||||
+{
|
||||
+ // Manage this header.
|
||||
+ _Atomic_word referenceCount;
|
||||
+ // __cxa_exception must be last, and no padding can be after it.
|
||||
+ __cxa_exception exc;
|
||||
+};
|
||||
|
||||
// A dependent C++ exception object consists of a header, which is a wrapper
|
||||
// around an unwind object header with additional C++ specific information,
|
||||
@@ -210,6 +227,21 @@ __get_exception_header_from_ue (_Unwind_
|
||||
return reinterpret_cast<__cxa_exception *>(exc + 1) - 1;
|
||||
}
|
||||
|
||||
+// Acquire the C++ refcounted exception header from the C++ object.
|
||||
+static inline __cxa_refcounted_exception *
|
||||
+__get_refcounted_exception_header_from_obj (void *ptr)
|
||||
+{
|
||||
+ return reinterpret_cast<__cxa_refcounted_exception *>(ptr) - 1;
|
||||
+}
|
||||
+
|
||||
+// Acquire the C++ refcounted exception header from the generic exception
|
||||
+// header.
|
||||
+static inline __cxa_refcounted_exception *
|
||||
+__get_refcounted_exception_header_from_ue (_Unwind_Exception *exc)
|
||||
+{
|
||||
+ return reinterpret_cast<__cxa_refcounted_exception *>(exc + 1) - 1;
|
||||
+}
|
||||
+
|
||||
} /* namespace __cxxabiv1 */
|
||||
|
||||
#pragma GCC visibility pop
|
||||
--- a/src/eh_alloc.cpp
|
||||
+++ b/src/eh_alloc.cpp
|
||||
@@ -30,16 +30,16 @@ extern "C" void * __cxa_allocate_excepti
|
||||
void *retval;
|
||||
//The sizeof crap is required by Itanium ABI because we need to provide space for
|
||||
//accounting information which is implementaion (gcc) specified
|
||||
- retval = malloc (thrown_size + sizeof(__cxa_exception));
|
||||
+ retval = malloc (thrown_size + sizeof(__cxa_refcounted_exception));
|
||||
if (0 == retval){
|
||||
std::terminate();
|
||||
}
|
||||
- memset (retval, 0, sizeof(__cxa_exception));
|
||||
- return (void *)((unsigned char *)retval + sizeof(__cxa_exception));
|
||||
+ memset (retval, 0, sizeof(__cxa_refcounted_exception));
|
||||
+ return (void *)((unsigned char *)retval + sizeof(__cxa_refcounted_exception));
|
||||
}
|
||||
|
||||
extern "C" void __cxa_free_exception(void *vptr) throw(){
|
||||
- free( (char *)(vptr) - sizeof(__cxa_exception) );
|
||||
+ free( (char *)(vptr) - sizeof(__cxa_refcounted_exception) );
|
||||
}
|
||||
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
--- a/src/del_op.cpp
|
||||
+++ b/src/del_op.cpp
|
||||
@@ -24,3 +24,7 @@
|
||||
_UCXXEXPORT void operator delete(void* ptr) throw(){
|
||||
free(ptr);
|
||||
}
|
||||
+
|
||||
+_UCXXEXPORT void operator delete(void* ptr, size_t size) throw(){
|
||||
+ free(ptr);
|
||||
+}
|
||||
--- a/src/del_opv.cpp
|
||||
+++ b/src/del_opv.cpp
|
||||
@@ -24,3 +24,7 @@
|
||||
_UCXXEXPORT void operator delete[](void * ptr) throw(){
|
||||
free(ptr);
|
||||
}
|
||||
+
|
||||
+_UCXXEXPORT void operator delete[](void * ptr, size_t size) throw(){
|
||||
+ free(ptr);
|
||||
+}
|
||||
@ -1,40 +0,0 @@
|
||||
From 946b29e62927eadfc4e87f27b8d30e5974b78c4c Mon Sep 17 00:00:00 2001
|
||||
From: Ben Kelly <ben@benjii.net>
|
||||
Date: Mon, 6 Feb 2017 13:08:25 +0200
|
||||
Subject: [PATCH] Bugfix erase() on derived __base_associative
|
||||
|
||||
When calling erase() on a containers derived from __base_associative
|
||||
(e.g. multimap) and providing a pair of iterators a segfault will
|
||||
occur.
|
||||
|
||||
Example code to reproduce:
|
||||
|
||||
typedef std::multimap<int, int> testmap;
|
||||
testmap t;
|
||||
t.insert(std::pair<int, int>(1, 1));
|
||||
t.insert(std::pair<int, int>(2, 1));
|
||||
t.insert(std::pair<int, int>(3, 1));
|
||||
t.erase(t.begin(), t.end());
|
||||
|
||||
Signed-off-by: Ben Kelly <ben@benjii.net>
|
||||
---
|
||||
include/associative_base | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/include/associative_base b/include/associative_base
|
||||
index 27ae0ef..be8b27f 100644
|
||||
--- a/include/associative_base
|
||||
+++ b/include/associative_base
|
||||
@@ -200,8 +200,7 @@ public:
|
||||
}
|
||||
void erase(iterator first, iterator last){
|
||||
while(first != last){
|
||||
- backing.erase(first.base_iterator());
|
||||
- ++first;
|
||||
+ first = backing.erase(first.base_iterator());
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
||||
Loading…
Reference in New Issue
Block a user