esp-idf/components/esp_rom/esp32s2/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
..
esp32s2.rom.api.ld spi_flash: refactor spi_flash.h to esp_rom_spiflash.h but keep the content in spi_flash.h 2021-12-30 14:12:31 +08:00
esp32s2.rom.ld fix: add spi_flash.h for s2, s3, c3 targets in cpu_start.c 2021-01-27 12:35:49 +08:00
esp32s2.rom.libgcc.ld esp_rom: splict libgcc and libc outof rom.ld bundle file 2020-01-23 00:27:47 +08:00
esp32s2.rom.newlib-data.ld newlib: add _RETARGETABLE_LOCKING support 2020-12-29 16:18:04 +01:00
esp32s2.rom.newlib-funcs.ld esp_rom: remove functions which depend on sizeof(struct stat) 2022-01-06 15:20:04 +01:00
esp32s2.rom.newlib-nano.ld esp32s2: esp_rom: separate nano formatting functions, fix newlib tests 2020-01-23 18:07:37 +01:00
esp32s2.rom.newlib-time.ld esp_rom: remove functions which depend on sizeof(struct stat) 2022-01-06 15:20:04 +01:00
esp32s2.rom.spiflash.ld spi_flash: fix the reading issue using the ROM functions in the ROM 2020-02-26 11:12:09 +08:00