tum-ei-eda/etiss

SimpleMemSystem ignores empty ELF segments

Closed this issue · 2 comments

See title. Empty segments might result from minimal programs where the RAM segment is left empty by the compiler (i.e. no data in .data and .bss sections) but should still get allocated for heap and stack use.

JoGei commented

Currently, the ELF-Interpreter/loader in SimpleMemSystem only interprets ELF Segments, i.e., program headers (see loop over ELFIO::reader::segments here).
If you want to include memory sections defined outside of what the executable "needs", we might need to implement some form of algorithm including the ELF sections, too. However, there is nothing we can generate that does not also specify its size in the ELF.

Do you have a minimal example ready? Then I would update the SimpleMemSystem to support that behavior.

Sorry about the confusing terminology, .data and .bss are of course sections. I think what I need is that the elfloader does not skip ELF segments which have a non-zero "memory size" but a zero "file size", i.e. are not filled by anything by the compiler. Currently the reason why "empty" segments are skipped is this if statement:

if (mseg && seg->get_data())

which checks whether there is any data in a segment. Simply removing the second condition does the trick for me in my case, but might create other issues.

A different mechanism of specifying memory sizes is anyways a good idea to have, especially if you cannot modify the linker script to suit ETISS' needs.