From ee001e0231f94e6a206fe1367ec8f4412c7c05e2 Mon Sep 17 00:00:00 2001 From: Joost Nieuwenhuijse Date: Wed, 16 May 2018 17:53:17 +0200 Subject: [PATCH 1/3] Move large lib_a-svfwprintf to flash lib_a-svfwprintf may get included when linking against libstdc++ This will overflow IRAM https://github.com/SuperHouse/esp-open-rtos/issues/623 --- ld/program.ld | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ld/program.ld b/ld/program.ld index 0718d6f..5b9031f 100644 --- a/ld/program.ld +++ b/ld/program.ld @@ -113,7 +113,11 @@ SECTIONS *libc.a:*bzero.o(.literal .text .literal.* .text.*) *libc.a:*lock.o(.literal .text .literal.* .text.*) - *libc.a:*printf.o(.literal .text .literal.* .text.*) + *libc.a:*-printf.o(.literal .text .literal.* .text.*) + *libc.a:*-sprintf.o(.literal .text .literal.* .text.*) + *libc.a:*-fprintf.o(.literal .text .literal.* .text.*) + *libc.a:*-svfprintf.o(.literal .text .literal.* .text.*) + *libc.a:*-vfprintf.o(.literal .text .literal.* .text.*) *libc.a:*findfp.o(.literal .text .literal.* .text.*) *libc.a:*fputwc.o(.literal .text .literal.* .text.*) From 233f9a6a313a697071de8c3fe08dd3630e3e9785 Mon Sep 17 00:00:00 2001 From: Joost Nieuwenhuijse Date: Wed, 16 May 2018 17:54:56 +0200 Subject: [PATCH 2/3] Change linker script to support C++ exceptions See: https://github.com/espressif/esp-idf/issues/459 https://github.com/jcmvbkbc/crosstool-NG/issues/54 --- ld/program.ld | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ld/program.ld b/ld/program.ld index 5b9031f..e169abd 100644 --- a/ld/program.ld +++ b/ld/program.ld @@ -253,10 +253,13 @@ SECTIONS *(.gnu.linkonce.r.*) __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); *(.xt_except_table) - *(.gcc_except_table) + *(.gcc_except_table .gcc_except_table.*) *(.gnu.linkonce.e.*) *(.gnu.version_r) - *(.eh_frame) + . = (. + 3) & ~ 3; + __eh_frame = ABSOLUTE(.); + KEEP(*(.eh_frame)) + . = (. + 7) & ~ 3; . = ALIGN(4); *(.dynamic) *(.gnu.version_d) From 2985d1d11ef28804fb1777e147aeefc2b7e5f8ca Mon Sep 17 00:00:00 2001 From: Joost Nieuwenhuijse Date: Wed, 16 May 2018 17:56:15 +0200 Subject: [PATCH 3/3] Make operator new / delete weak so you can implement your own, e.g. if you need a throwing operator new. --- core/cplusplus_operators.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/cplusplus_operators.cpp b/core/cplusplus_operators.cpp index 86f4477..b263838 100644 --- a/core/cplusplus_operators.cpp +++ b/core/cplusplus_operators.cpp @@ -4,22 +4,22 @@ #include #include -void *operator new(size_t size) +void * __attribute__((weak)) operator new(size_t size) { return malloc(size); } -void *operator new[](size_t size) +void * __attribute__((weak)) operator new[](size_t size) { return malloc(size); } -void operator delete(void * ptr) +void __attribute__((weak)) operator delete(void * ptr) { free(ptr); } -void operator delete[](void * ptr) +void __attribute__((weak)) operator delete[](void * ptr) { free(ptr); }