Linker returns failure
Posted: Tue Sep 25, 2018 11:15 am
Error :
Is it because there are too many globals ?
This workspace has around 25 files. I have another workspace that has almost the exact same code with a few extra files that compiles just fine. I was manually moving some changes from one workspace to another when I ran into the problem.
In one of the cpp files, there is a function with a "switch" block. If I comment out the contents of just that switch block, there is no problem. I tried retaining that code and taking a few other files out of compilation but the problem persists...
When it does compile (after removing the switch block contents), the output shows :
UPDATE: From within the switch case, an API from another file was being called. The API references a global array with 8192 elements of struct :
If I reduce the size of this array, linking is fine. So, it is because my data segment is getting too huge ? Is there any workarounds available ? Move large allocations to heap ?
Code: Select all
c:/users/stanzlavos/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\STANZL~1\AppData\Local\Temp\arduino_build_739272/IRControl.ino.elf section `.data' will not fit in region `dram0_0_seg'
c:/users/stanzlavos/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: address 0x40009a98 of C:\Users\STANZL~1\AppData\Local\Temp\arduino_build_739272/IRControl.ino.elf section `.bss' is not within region `dram0_0_seg'
c:/users/stanzlavos/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: address 0x40009a98 of C:\Users\STANZL~1\AppData\Local\Temp\arduino_build_739272/IRControl.ino.elf section `.bss' is not within region `dram0_0_seg'
collect2.exe: error: ld returned 1 exit status
Is it because there are too many globals ?
This workspace has around 25 files. I have another workspace that has almost the exact same code with a few extra files that compiles just fine. I was manually moving some changes from one workspace to another when I ran into the problem.
In one of the cpp files, there is a function with a "switch" block. If I comment out the contents of just that switch block, there is no problem. I tried retaining that code and taking a few other files out of compilation but the problem persists...
When it does compile (after removing the switch block contents), the output shows :
Code: Select all
Sketch uses 376748 bytes (36%) of program storage space. Maximum is 1044464 bytes.
Global variables use 39504 bytes (48%) of dynamic memory, leaving 42416 bytes for local variables. Maximum is 81920 bytes.
UPDATE: From within the switch case, an API from another file was being called. The API references a global array with 8192 elements of struct :
Code: Select all
typedef struct
{
int type;
int bits;
unsigned long value;
} ir_send_cmd_t;
If I reduce the size of this array, linking is fine. So, it is because my data segment is getting too huge ? Is there any workarounds available ? Move large allocations to heap ?