From 8c2f2867d8e158de8dad4c03462d436b4e66c412 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 29 Mar 2019 12:37:51 +0800 Subject: [PATCH] =?UTF-8?q?esp=5From:=20don=E2=80=99t=20include=20locale?= =?UTF-8?q?=20functions=20when=20compiling=20with=20newlib=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/esp_rom/CMakeLists.txt | 4 ++++ components/esp_rom/component.mk | 4 ++++ .../esp32/ld/esp32.rom.newlib-funcs.ld | 8 -------- .../esp32/ld/esp32.rom.newlib-locale.ld | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 components/esp_rom/esp32/ld/esp32.rom.newlib-locale.ld diff --git a/components/esp_rom/CMakeLists.txt b/components/esp_rom/CMakeLists.txt index 63a028172..cbf6f3dcb 100644 --- a/components/esp_rom/CMakeLists.txt +++ b/components/esp_rom/CMakeLists.txt @@ -27,6 +27,10 @@ else() target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-nano.ld") endif() + if(NOT GCC_NOT_5_2_0) + target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-locale.ld") + endif() + if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH) target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.spiflash.ld") endif() diff --git a/components/esp_rom/component.mk b/components/esp_rom/component.mk index f53b15596..468132c12 100644 --- a/components/esp_rom/component.mk +++ b/components/esp_rom/component.mk @@ -16,6 +16,10 @@ ifdef CONFIG_NEWLIB_NANO_FORMAT LINKER_SCRIPTS += esp32.rom.newlib-nano.ld endif +ifneq ($(GCC_NOT_5_2_0), 1) +LINKER_SCRIPTS += esp32.rom.newlib-locale.ld +endif + ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH LINKER_SCRIPTS += esp32.rom.spiflash.ld endif diff --git a/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld b/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld index ed7c4910e..7a4c772e8 100644 --- a/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld +++ b/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld @@ -63,12 +63,6 @@ __itoa = 0x40056678; itoa = 0x400566b4; labs = 0x40056370; ldiv = 0x40056378; -__locale_charset = 0x40059540; -__locale_cjk_lang = 0x40059558; -localeconv = 0x4005957c; -_localeconv_r = 0x40059560; -__locale_mb_cur_max = 0x40059548; -__locale_msgcharset = 0x40059550; localtime = 0x400595dc; localtime_r = 0x400595fc; longjmp = 0x400562cc; @@ -87,8 +81,6 @@ __sccl = 0x4000c498; __sclose = 0x400011b8; __seofread = 0x40001148; setjmp = 0x40056268; -setlocale = 0x40059568; -_setlocale_r = 0x4005950c; __sflush_r = 0x400591e0; __sfmoreglue = 0x40001dc8; __sfp = 0x40001e90; diff --git a/components/esp_rom/esp32/ld/esp32.rom.newlib-locale.ld b/components/esp_rom/esp32/ld/esp32.rom.newlib-locale.ld new file mode 100644 index 000000000..81e22aaf3 --- /dev/null +++ b/components/esp_rom/esp32/ld/esp32.rom.newlib-locale.ld @@ -0,0 +1,19 @@ +/* These are the locale-related newlib functions present in ESP32 ROM. + ESP32 ROM contains newlib version 2.2.0, and these functions should not be + used when compiling with newlib version 3, since locale implementation is + different there. + + Unlike other ROM functions which are exported using PROVIDE, which declares + weak symbols, newlib related functions are exported using assignment, + which declares strong symbols. This is done so that ROM functions are always + used instead of the ones provided by libc.a. + */ + +__locale_charset = 0x40059540; +__locale_cjk_lang = 0x40059558; +localeconv = 0x4005957c; +_localeconv_r = 0x40059560; +__locale_mb_cur_max = 0x40059548; +__locale_msgcharset = 0x40059550; +setlocale = 0x40059568; +_setlocale_r = 0x4005950c;