esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.newlib-funcs.ld
Ivan Grokhotkov 24c20d188e esp_rom: remove functions which depend on sizeof(struct stat)
...and all their callers.

With the upcoming switch from sizeof(time_t)==4 to sizeof(time_t)==8,
sizeof(struct stat) is also increasing.

A few newlib functions present in ROM allocate 'struct stat' on the
stack and call _fstat_r on this structure. The implementation of
fstat is provided in ESP-IDF. This implementation will often do
memset(st, 0, sizeof(*st)), where st is 'struct stat*', before setting
some fields of this structure. If IDF is built with sizeof(st)
different from sizeof(st) which ROM was built with, this will lead
to an out-of-bounds write and a stack corruption.

This commit removes problematic ROM functions from the linker script.
Here are the functions which allocate 'struct stat':
* _isatty_r (in ROM)
* __swhatbuf_r, called by __smakebuf_r, called by __swsetup_r and
  __srefill_r (in ROM)
* _fseeko_r (not in ROM)
* glob2 (not in ROM)
* _gettemp (not in ROM)

As a result, these functions are used from libc.a, and use correct
size of 'stat' structure.

Closes https://github.com/espressif/esp-idf/issues/7980
2022-01-06 15:20:04 +01:00

111 lines
2.8 KiB
Plaintext

/**
* These are the newlib functions present in ESP32-S2 ROM.
* See also esp32s2.rom.newlib-data.ld for the list of .data/.bss symbols used by these functions.
* Unlike other ROM functions which are exported using PROVIDE, which declare 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.
*/
abs = 0x40000618;
__ascii_mbtowc = 0x40007a04;
__ascii_wctomb = 0x400018d0;
PROVIDE ( __assert = 0x4001a430 );
PROVIDE ( __assert_func = 0x4001a408 );
bzero = 0x400078c8;
_cleanup_r = 0x4001a480;
creat = 0x4000788c;
div = 0x40000620;
fclose = 0x4001a804;
_fclose_r = 0x4001a714;
fflush = 0x40001bb8;
_fflush_r = 0x40001b30;
__fp_unlock_all = 0x4001a64c;
__fputwc = 0x40001770;
fputwc = 0x40001864;
_fputwc_r = 0x400017f8;
_fwalk = 0x4001bcec;
_fwalk_reent = 0x4001bd24;
isalnum = 0x400078d8;
isalpha = 0x400078e8;
isascii = 0x4001aaec;
isblank = 0x400078f8;
iscntrl = 0x40007918;
isdigit = 0x40007930;
isgraph = 0x40007968;
islower = 0x40007948;
isprint = 0x40007980;
ispunct = 0x40007994;
isspace = 0x400079ac;
isupper = 0x400079c4;
labs = 0x40000648;
ldiv = 0x40000650;
__locale_ctype_ptr = 0x40001c2c;
__locale_ctype_ptr_l = 0x40001c24;
__locale_mb_cur_max = 0x40001c0c;
longjmp = 0x400005a4;
_mbtowc_r = 0x400079e0;
memccpy = 0x4001ab00;
memchr = 0x4001ab24;
memcmp = 0x4001ab40;
memcpy = 0x4001aba8;
memmove = 0x4001acb0;
memrchr = 0x4001acec;
memset = 0x4001ad3c;
open = 0x400080c4;
qsort = 0x400006f4;
rand_r = 0x40007af4;
__sclose = 0x4001a700;
__seofread = 0x4001a690;
setjmp = 0x40000540;
setlocale = 0x40001c44;
_setlocale_r = 0x40001bdc;
__sflush_r = 0x400019dc;
__sfmoreglue = 0x4001a4c8;
__sfp = 0x4001a590;
__sfp_lock_acquire = 0x4001a508;
__sfp_lock_release = 0x4001a514;
__sinit = 0x4001a538;
__sinit_lock_acquire = 0x4001a520;
__sinit_lock_release = 0x4001a52c;
srand = 0x40007a24;
__sread = 0x4001a660;
__sseek = 0x4001a6cc;
strcasecmp = 0x40007b38;
strcasestr = 0x40007b7c;
strcat = 0x4001ad90;
strchr = 0x4001adb0;
strcmp = 0x40007be4;
strcoll = 0x40007ce8;
strcpy = 0x40007cfc;
strcspn = 0x4001adcc;
strdup = 0x40007d84;
_strdup_r = 0x40007d98;
strlcat = 0x40007db8;
strlcpy = 0x4001adf8;
strlen = 0x40007e08;
strlwr = 0x40007e68;
strncasecmp = 0x40007e94;
strncat = 0x4001ae34;
strncmp = 0x4001ae64;
strncpy = 0x40007f20;
strndup = 0x40007fe8;
_strndup_r = 0x40007ffc;
strnlen = 0x4001ae9c;
strrchr = 0x40008040;
strsep = 0x4000806c;
strspn = 0x4001aebc;
strstr = 0x4001aee8;
__strtok_r = 0x4001af18;
strtok_r = 0x4001af7c;
strupr = 0x40008084;
__swbuf = 0x4000167c;
__swbuf_r = 0x400015bc;
__swrite = 0x4001a698;
toascii = 0x4001af90;
tolower = 0x40008158;
toupper = 0x40008174;
wcrtomb = 0x400012f4;
_wcrtomb_r = 0x400012a0;
_wctomb_r = 0x400018ac;