tum-ei-eda / etiss

Extendable Translating Instruction Set Simulator
https://tum-ei-eda.github.io/etiss/
Other
29 stars 36 forks source link

SimpleMemSystem ignores empty ELF segments #52

Closed wysiwyng closed 3 years ago

wysiwyng commented 3 years ago

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 3 years ago

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.

wysiwyng commented 3 years ago

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: https://github.com/tum-ei-eda/etiss/blob/ea71e6191877d9f162227cfa3191b64dcafb53f7/src/SimpleMemSystem.cpp#L156 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.