esp-idf/components/esp_rom/esp32/ld
Ivan Grokhotkov 096c013675
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-02-07 11:23:59 +01:00
..
esp32.rom.api.ld rom/tjpgd: unify library & add rom patch 2021-09-01 14:42:17 +08:00
esp32.rom.eco3.ld secure_boot: Secure Boot V2 verify app signature on update (without Secure boot) 2021-03-15 12:30:20 +00:00
esp32.rom.ld bugfix/fix crash when lmp flooding 2021-05-24 12:08:03 +08:00
esp32.rom.libgcc.ld esp32: Use FPU for floating point divide, power, complex multiplications 2019-05-29 10:14:31 +10:00
esp32.rom.newlib-data.ld newlib: add _RETARGETABLE_LOCKING support 2020-12-29 16:18:04 +01:00
esp32.rom.newlib-funcs.ld esp_rom: remove functions which depend on sizeof(struct stat) 2022-02-07 11:23:59 +01:00
esp32.rom.newlib-locale.ld esp_rom: don’t include locale functions when compiling with newlib 3 2019-04-10 13:52:30 +08:00
esp32.rom.newlib-nano.ld esp_rom: export newlib functions as strong symbols 2019-04-10 13:52:30 +08:00
esp32.rom.newlib-time.ld esp_rom: remove functions which depend on sizeof(struct stat) 2022-02-07 11:23:59 +01:00
esp32.rom.redefined.ld Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
esp32.rom.spiflash.ld Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
esp32.rom.syscalls.ld Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00